Skip to content

Commit

Permalink
Attempt to set Python package version to the snapshot identifier.
Browse files Browse the repository at this point in the history
This should make the releases sort properly when `pip`'s
`-f`/`--find-links` argument is used.
  • Loading branch information
silvasean committed Mar 30, 2022
1 parent 969785d commit 8250f50
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/releaseSnapshotPackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"}'
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,6 +39,7 @@
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):
Expand Down Expand Up @@ -108,7 +113,7 @@ def build_extension(self, 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",
Expand Down

0 comments on commit 8250f50

Please sign in to comment.