Skip to content

Commit 159caa1

Browse files
authored
pypi doesn't support local version :( (#165)
1 parent 3b31903 commit 159caa1

File tree

2 files changed

+36
-54
lines changed

2 files changed

+36
-54
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ name: Release
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
USE_LOCAL_VERSION:
7+
description: 'use local version for wheel'
8+
type: number
9+
default: 1
10+
BUNDLE_MLIR_PYTHON_BINDINGS:
11+
description: 'bundle mlir python bindings'
12+
type: number
13+
default: 1
514
release:
615
types:
716
- published
@@ -77,7 +86,8 @@ jobs:
7786
run: |
7887
7988
echo "BINDINGS_VERSION=$(python scripts/get_latest_bindings.py ${{ matrix.gpu }})" >> $GITHUB_ENV
80-
echo "BUNDLE_MLIR_PYTHON_BINDINGS=1" >> $GITHUB_ENV
89+
echo "BUNDLE_MLIR_PYTHON_BINDINGS=${{ inputs.BUNDLE_MLIR_PYTHON_BINDINGS && inputs.BUNDLE_MLIR_PYTHON_BINDINGS || 1 }}" >> $GITHUB_ENV
90+
echo "USE_LOCAL_VERSION=${{ inputs.USE_LOCAL_VERSION && inputs.USE_LOCAL_VERSION || 1 }}" >> $GITHUB_ENV
8191
echo "PLAT=$(python scripts/get_latest_bindings.py ${{ matrix.gpu }} --only-plat)" >> $GITHUB_ENV
8292
echo "GPU=${{ matrix.gpu }}" >> $GITHUB_ENV
8393
@@ -171,32 +181,3 @@ jobs:
171181
with:
172182
path: dist/*.tar.gz
173183
name: build_artifact-sdist
174-
175-
upload_pypi:
176-
177-
needs: [build, build_sdist]
178-
179-
if: github.event_name != 'pull_request'
180-
181-
runs-on: ubuntu-latest
182-
183-
environment: pypi
184-
185-
permissions:
186-
id-token: write
187-
188-
steps:
189-
190-
- uses: actions/download-artifact@v4
191-
with:
192-
pattern: build_artifact-*
193-
path: dist
194-
merge-multiple: true
195-
196-
- uses: pypa/gh-action-pypi-publish@release/v1
197-
with:
198-
repository-url: https://test.pypi.org/legacy/
199-
user: __token__
200-
password: ${{ secrets.TEST_PYPI_PASSWORD }}
201-
skip-existing: false
202-
verbose: true

setup.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,30 @@ def build_extension(self, ext: CMakeExtension) -> None:
5656

5757

5858
now = datetime.now()
59-
version_s = f"0.0.8.{now.year}{now.month:02}{now.day:02}{now.hour:02}+"
60-
61-
62-
local_version = []
63-
GPU = os.getenv("GPU", None)
64-
if GPU not in {None, "none"}:
65-
local_version += [GPU]
66-
67-
try:
68-
short_hash = run_git(
69-
["rev-parse", "--short", "HEAD"],
70-
Path(__file__).parent,
71-
).parse_success(
72-
parse=str,
73-
error_msg="branch err (abbrev-err)",
74-
)
75-
except Exception as e:
76-
short_hash = "no-hash"
77-
78-
if local_version:
79-
version_s += ".".join(local_version + [short_hash])
80-
else:
81-
version_s += short_hash
59+
version_s = f"0.0.8.{now.year}{now.month:02}{now.day:02}{now.hour:02}"
60+
61+
if bool(int(os.getenv("USE_LOCAL_VERSION", True) or 1)):
62+
version_s += "+"
63+
local_version = []
64+
GPU = os.getenv("GPU", None)
65+
if GPU not in {None, "none"}:
66+
local_version += [GPU]
67+
68+
try:
69+
short_hash = run_git(
70+
["rev-parse", "--short", "HEAD"],
71+
Path(__file__).parent,
72+
).parse_success(
73+
parse=str,
74+
error_msg="branch err (abbrev-err)",
75+
)
76+
except Exception as e:
77+
short_hash = "no-hash"
78+
79+
if local_version:
80+
version_s += ".".join(local_version + [short_hash])
81+
else:
82+
version_s += short_hash
8283

8384
packages = (
8485
[HOST_MLIR_PYTHON_PACKAGE_PREFIX]
@@ -96,7 +97,7 @@ def build_extension(self, ext: CMakeExtension) -> None:
9697

9798
cmdclass = {"build_py": MyInstallData}
9899
ext_modules = []
99-
if bool(os.getenv("BUNDLE_MLIR_PYTHON_BINDINGS", False)):
100+
if bool(int(os.getenv("BUNDLE_MLIR_PYTHON_BINDINGS", False) or 0)):
100101
cmdclass["build_ext"] = CMakeBuild
101102
ext_modules += [CMakeExtension(HOST_MLIR_PYTHON_PACKAGE_PREFIX, sourcedir=".")]
102103

0 commit comments

Comments
 (0)