diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 7b9eecc..7165063 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -30,20 +30,18 @@ jobs: runs-on: ${{ matrix.os }} needs: [create_version] strategy: - fail-fast: false + fail-fast: true matrix: - include: - - os: ubuntu-24.04 - arch: x86_64 - - os: macos-13 - arch: auto + os: [ubuntu-24.04, macos-13] + python-version: ['3.10', '3.11', '3.12'] + steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - name: Set up Python uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 with: - python-version: '3.10' + python-version: ${{ matrix.python-version }} - uses: actions/download-artifact@master with: @@ -57,13 +55,22 @@ jobs: disk-cache: ${{ github.workflow }} repository-cache: true + - name: Set Python Version + env: + TARGET_PYTHON: ${{ matrix.python-version }} + run: | + echo "set version to ${TARGET_PYTHON}" + python _update_bazel_py_version.py $TARGET_PYTHON + - name: Build package + env: + TARGET_PYTHON: ${{ matrix.python-version }} run: | - bazel build --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel + bazel build --define TARGET_VERSION="$(python -c "print(\"py${TARGET_PYTHON}\".replace(\".\", \"\"))")" --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4 with: - name: python-wheels-${{ matrix.os }} + name: python-wheels-${{ matrix.os }}-${{ matrix.python-version }} path: ./bazel-bin/*.whl release-wheels: @@ -88,6 +95,7 @@ jobs: packages_dir: wheelhouse/ verbose: true + - name: Publish package to pypi uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 with: diff --git a/.github/workflows/stable-release-workflow.yml b/.github/workflows/stable-release-workflow.yml index de7c291..e9bb6fa 100644 --- a/.github/workflows/stable-release-workflow.yml +++ b/.github/workflows/stable-release-workflow.yml @@ -29,20 +29,17 @@ jobs: runs-on: ${{ matrix.os }} needs: [create_version] strategy: - fail-fast: false + fail-fast: true matrix: - include: - - os: ubuntu-24.04 - arch: x86_64 - - os: macos-13 - arch: auto + os: [ubuntu-24.04, macos-13] + python-version: ['3.10', '3.11', '3.12'] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - name: Set up Python uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 with: - python-version: '3.10' + python-version: ${{ matrix.python-version }} - uses: actions/download-artifact@master with: @@ -56,13 +53,22 @@ jobs: disk-cache: ${{ github.workflow }} repository-cache: true + - name: Set Python Version + env: + TARGET_PYTHON: ${{ matrix.python-version }} + run: | + echo "set version to ${TARGET_PYTHON}" + python _update_bazel_py_version.py $TARGET_PYTHON + - name: Build package + env: + TARGET_PYTHON: ${{ matrix.python-version }} run: | - bazel build --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel + bazel build --define TARGET_VERSION="$(python -c "print(\"py${TARGET_PYTHON}\".replace(\".\", \"\"))")" --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4 with: - name: python-wheels-${{ matrix.os }} + name: python-wheels-${{ matrix.os }}-${{ matrix.python-version }} path: ./bazel-bin/*.whl release-wheels: @@ -78,7 +84,6 @@ jobs: merge-multiple: true path: wheelhouse/ - - name: Publish package to testpypi uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 with: diff --git a/BUILD b/BUILD index 1225b3a..b33be34 100644 --- a/BUILD +++ b/BUILD @@ -24,11 +24,14 @@ py_wheel( requires=[ "stim", ], + abi="$(TARGET_VERSION)", + python_tag="$(TARGET_VERSION)", platform= select({ "@platforms//os:macos": "macosx_10_13_x86_64", "@platforms//os:windows": "win32", "@platforms//os:linux": "manylinux_2_17_x86_64.manylinux2014_x86_64", }), + strip_path_prefixes = ["src"], description_file=":package_description", description_content_type="text/markdown", summary="A search-based decoder for quantum error correction (QEC).", diff --git a/_update_bazel_py_version.py b/_update_bazel_py_version.py new file mode 100644 index 0000000..c0220fc --- /dev/null +++ b/_update_bazel_py_version.py @@ -0,0 +1,14 @@ +import sys + +def main(): + version = sys.argv[1] + lines = open('MODULE.bazel').read().splitlines() + for i, l in enumerate(lines): + if l.startswith('DEFAULT_PYTHON_VERSION = '): + lines[i] = f'DEFAULT_PYTHON_VERSION = "{version}"' + break + with open('MODULE.bazel', 'w') as ouf: + print(*lines, file=ouf, sep='\n') + +if __name__ == '__main__': + main()