Skip to content

Commit 2039b31

Browse files
Fix minor issues in pypi workflow (#50)
1 parent 9d7807b commit 2039b31

File tree

4 files changed

+49
-19
lines changed

4 files changed

+49
-19
lines changed

.github/workflows/prerelease.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,18 @@ jobs:
3030
runs-on: ${{ matrix.os }}
3131
needs: [create_version]
3232
strategy:
33-
fail-fast: false
33+
fail-fast: true
3434
matrix:
35-
include:
36-
- os: ubuntu-24.04
37-
arch: x86_64
38-
- os: macos-13
39-
arch: auto
35+
os: [ubuntu-24.04, macos-13]
36+
python-version: ['3.10', '3.11', '3.12']
37+
4038

4139
steps:
4240
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
4341
- name: Set up Python
4442
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5
4543
with:
46-
python-version: '3.10'
44+
python-version: ${{ matrix.python-version }}
4745

4846
- uses: actions/download-artifact@master
4947
with:
@@ -57,13 +55,22 @@ jobs:
5755
disk-cache: ${{ github.workflow }}
5856
repository-cache: true
5957

58+
- name: Set Python Version
59+
env:
60+
TARGET_PYTHON: ${{ matrix.python-version }}
61+
run: |
62+
echo "set version to ${TARGET_PYTHON}"
63+
python _update_bazel_py_version.py $TARGET_PYTHON
64+
6065
- name: Build package
66+
env:
67+
TARGET_PYTHON: ${{ matrix.python-version }}
6168
run: |
62-
bazel build --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel
69+
bazel build --define TARGET_VERSION="$(python -c "print(\"py${TARGET_PYTHON}\".replace(\".\", \"\"))")" --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel
6370
6471
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
6572
with:
66-
name: python-wheels-${{ matrix.os }}
73+
name: python-wheels-${{ matrix.os }}-${{ matrix.python-version }}
6774
path: ./bazel-bin/*.whl
6875

6976
release-wheels:
@@ -88,6 +95,7 @@ jobs:
8895
packages_dir: wheelhouse/
8996
verbose: true
9097

98+
9199
- name: Publish package to pypi
92100
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
93101
with:

.github/workflows/stable-release-workflow.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,17 @@ jobs:
2929
runs-on: ${{ matrix.os }}
3030
needs: [create_version]
3131
strategy:
32-
fail-fast: false
32+
fail-fast: true
3333
matrix:
34-
include:
35-
- os: ubuntu-24.04
36-
arch: x86_64
37-
- os: macos-13
38-
arch: auto
34+
os: [ubuntu-24.04, macos-13]
35+
python-version: ['3.10', '3.11', '3.12']
3936

4037
steps:
4138
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
4239
- name: Set up Python
4340
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5
4441
with:
45-
python-version: '3.10'
42+
python-version: ${{ matrix.python-version }}
4643

4744
- uses: actions/download-artifact@master
4845
with:
@@ -56,13 +53,22 @@ jobs:
5653
disk-cache: ${{ github.workflow }}
5754
repository-cache: true
5855

56+
- name: Set Python Version
57+
env:
58+
TARGET_PYTHON: ${{ matrix.python-version }}
59+
run: |
60+
echo "set version to ${TARGET_PYTHON}"
61+
python _update_bazel_py_version.py $TARGET_PYTHON
62+
5963
- name: Build package
64+
env:
65+
TARGET_PYTHON: ${{ matrix.python-version }}
6066
run: |
61-
bazel build --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel
67+
bazel build --define TARGET_VERSION="$(python -c "print(\"py${TARGET_PYTHON}\".replace(\".\", \"\"))")" --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel
6268
6369
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
6470
with:
65-
name: python-wheels-${{ matrix.os }}
71+
name: python-wheels-${{ matrix.os }}-${{ matrix.python-version }}
6672
path: ./bazel-bin/*.whl
6773

6874
release-wheels:
@@ -78,7 +84,6 @@ jobs:
7884
merge-multiple: true
7985
path: wheelhouse/
8086

81-
8287
- name: Publish package to testpypi
8388
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
8489
with:

BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ py_wheel(
2424
requires=[
2525
"stim",
2626
],
27+
abi="$(TARGET_VERSION)",
28+
python_tag="$(TARGET_VERSION)",
2729
platform= select({
2830
"@platforms//os:macos": "macosx_10_13_x86_64",
2931
"@platforms//os:windows": "win32",
3032
"@platforms//os:linux": "manylinux_2_17_x86_64.manylinux2014_x86_64",
3133
}),
34+
strip_path_prefixes = ["src"],
3235
description_file=":package_description",
3336
description_content_type="text/markdown",
3437
summary="A search-based decoder for quantum error correction (QEC).",

_update_bazel_py_version.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import sys
2+
3+
def main():
4+
version = sys.argv[1]
5+
lines = open('MODULE.bazel').read().splitlines()
6+
for i, l in enumerate(lines):
7+
if l.startswith('DEFAULT_PYTHON_VERSION = '):
8+
lines[i] = f'DEFAULT_PYTHON_VERSION = "{version}"'
9+
break
10+
with open('MODULE.bazel', 'w') as ouf:
11+
print(*lines, file=ouf, sep='\n')
12+
13+
if __name__ == '__main__':
14+
main()

0 commit comments

Comments
 (0)