Attempt to set Python package version to the snapshot identifier.

This should make the releases sort properly when `pip`'s
`-f`/`--find-links` argument is used.
pull/721/head snapshot-20220330.358
Sean Silva 2022-03-30 17:51:52 +00:00
parent 969785d1b6
commit 8250f50c81
3 changed files with 11 additions and 2 deletions

View File

@ -10,6 +10,9 @@ on:
release_id:
description: 'Release id to upload artifacts to'
default: ''
python_package_version:
description: 'Version to use for creating the Python package'
default: ''
jobs:
build:
@ -79,6 +82,7 @@ jobs:
python -m pip install wheel
TORCH_MLIR_CMAKE_BUILD_DIR="$GITHUB_WORKSPACE/build" \
TORCH_MLIR_CMAKE_BUILD_DIR_ALREADY_BUILT=1 \
TORCH_MLIR_PYTHON_PACKAGE_VERSION="${{ github.event.inputs.python_package_version }}" \
./build_tools/build_python_wheels.sh
# If we were given a release_id, then upload the package we just built

View File

@ -56,4 +56,4 @@ jobs:
workflow: Build and Test
token: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }}
ref: "${{ env.tag_name }}"
inputs: '{"release_id": "${{ steps.create_release.outputs.id }}"}'
inputs: '{"release_id": "${{ steps.create_release.outputs.id }}", "python_package_version": "${{ env.package_version }}"}'

View File

@ -20,6 +20,10 @@
# prevent this script from attempting to build the directory, and will simply
# use the (presumed already built) directory as-is.
#
# The package version can be set with the TORCH_MLIR_PYTHON_PACKAGE_VERSION
# environment variable. For example, this can be "20220330.357" for a snapshot
# release on 2022-03-30 with build number 357.
#
# Implementation notes:
# The contents of the wheel is just the contents of the `python_packages`
# directory that our CMake build produces. We go through quite a bit of effort
@ -35,6 +39,7 @@ from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from setuptools.command.build_py import build_py
PACKAGE_VERSION = os.environ.get("TORCH_MLIR_PYTHON_PACKAGE_VERSION") or "0.0.1"
# Build phase discovery is unreliable. Just tell it what phases to run.
class CustomBuild(_build):
@ -108,7 +113,7 @@ class NoopBuildExtension(build_ext):
setup(
name="torch-mlir",
version="0.0.1",
version=f"{PACKAGE_VERSION}",
author="Sean Silva",
author_email="silvasean@google.com",
description="First-class interop between PyTorch and MLIR",