From 6e215293c350377b21722176929827dd66bd89e2 Mon Sep 17 00:00:00 2001 From: Malcolm Greaves Date: Fri, 20 Feb 2026 13:37:02 -0800 Subject: [PATCH] Build liboxen once in test PyPI workflow Refactors the Test PyPI publish workflow so that `liboxen` is only built once per-platform (OS + architecture). The crate is reused for each individual pyO3 + Python version build. --- .../workflows/build_and_publish_test_pypi.yml | 2 +- .github/workflows/build_wheels_linux.yml | 28 ++++++++++++++----- .github/workflows/build_wheels_macos.yml | 16 ++++++----- .github/workflows/build_wheels_windows.yml | 18 ++++++------ 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build_and_publish_test_pypi.yml b/.github/workflows/build_and_publish_test_pypi.yml index 1fde52c77..0a0df2282 100644 --- a/.github/workflows/build_and_publish_test_pypi.yml +++ b/.github/workflows/build_and_publish_test_pypi.yml @@ -19,7 +19,7 @@ permissions: env: AWS_ROLE: arn:aws:iam::213020545630:role/github-runner-role AWS_REGION: us-west-1 - PYTHON_VERSIONS: "3.13 3.12 3.11 3.10" + PYTHON_VERSIONS: '["3.13", "3.12", "3.11", "3.10"]' jobs: set_env: diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml index 0b35f6a46..b216d1003 100644 --- a/.github/workflows/build_wheels_linux.yml +++ b/.github/workflows/build_wheels_linux.yml @@ -84,9 +84,14 @@ jobs: ] build_wheels: - name: Build Python wheels + name: Python ${{ matrix.python_version }} needs: start-self-hosted-runner runs-on: ${{ needs.start-self-hosted-runner.outputs.label }} + strategy: + fail-fast: false + max-parallel: 1 + matrix: + python_version: ${{ fromJSON(inputs.PYTHON_VERSIONS) }} steps: - name: Checkout @@ -122,20 +127,29 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v6 - - name: Build Python wheels + - name: Build Python wheel run: | - uv python install ${{ inputs.PYTHON_VERSIONS }} + uv python install ${{ matrix.python_version }} cd ${{ github.workspace }}/oxen-python - for version in ${{ inputs.PYTHON_VERSIONS }}; do - uvx --from 'maturin[patchelf]' maturin build --release --interpreter /root/.local/bin/python${version} - done + uvx --from 'maturin[patchelf]' maturin build --release -v \ + --interpreter /root/.local/bin/python${{ matrix.python_version }} \ + 2>&1 | tee /tmp/build.log + + - name: Verify liboxen cache reuse + if: strategy.job-index != 0 + run: | + if grep -q "Compiling liboxen" /tmp/build.log; then + echo "::error::liboxen was recompiled! Rust cache reuse failed." + exit 1 + fi + echo "liboxen correctly reused from cache." - name: Upload wheel artifact uses: actions/upload-artifact@v4 with: - name: wheels-linux-${{ inputs.ARCHITECTURE }} + name: wheels-linux-${{ inputs.ARCHITECTURE }}-py${{ matrix.python_version }} path: ${{ github.workspace }}/oxen-python/target/wheels/*.whl retention-days: 1 diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml index b2d14de81..3edb48f47 100644 --- a/.github/workflows/build_wheels_macos.yml +++ b/.github/workflows/build_wheels_macos.yml @@ -21,8 +21,12 @@ env: jobs: build_wheels: - name: Build Python wheels + name: Python ${{ matrix.python_version }} runs-on: macos-15-xlarge + strategy: + fail-fast: false + matrix: + python_version: ${{ fromJSON(inputs.PYTHON_VERSIONS) }} steps: - name: Checkout uses: actions/checkout@v4 @@ -48,21 +52,19 @@ jobs: - name: Build Python wheels run: | - uv python install ${{ inputs.PYTHON_VERSIONS }} + uv python install ${{ matrix.python_version }} cd ${{ github.workspace }}/oxen-python rustup target add aarch64-apple-darwin rustup target add x86_64-apple-darwin - for version in ${{ inputs.PYTHON_VERSIONS }}; do - uvx maturin build --release --interpreter /Users/runner/.local/bin/python${version} --target aarch64-apple-darwin - uvx maturin build --release --interpreter /Users/runner/.local/bin/python${version} --target x86_64-apple-darwin - done + uvx maturin build --release --interpreter /Users/runner/.local/bin/python${{ matrix.python_version }} --target aarch64-apple-darwin + uvx maturin build --release --interpreter /Users/runner/.local/bin/python${{ matrix.python_version }} --target x86_64-apple-darwin - name: Upload wheel artifact uses: actions/upload-artifact@v4 with: - name: wheels-macos + name: wheels-macos-py${{ matrix.python_version }} path: ${{ github.workspace }}/oxen-python/target/wheels/*.whl retention-days: 1 diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml index e9cb24922..bb59f73c8 100644 --- a/.github/workflows/build_wheels_windows.yml +++ b/.github/workflows/build_wheels_windows.yml @@ -70,9 +70,14 @@ jobs: ] build_wheels: - name: Build Python wheels + name: Python ${{ matrix.python_version }} needs: start-self-hosted-runner runs-on: ${{ needs.start-self-hosted-runner.outputs.label }} + strategy: + fail-fast: false + max-parallel: 1 + matrix: + python_version: ${{ fromJSON(inputs.PYTHON_VERSIONS) }} defaults: run: shell: powershell @@ -122,22 +127,19 @@ jobs: shared-key: "release-python" workspaces: "oxen-python -> target" - - name: Build Python wheels + - name: Build Python wheel run: | refreshenv - uv python install ${{ inputs.PYTHON_VERSIONS }} + uv python install ${{ matrix.python_version }} cd ${{ github.workspace }}\oxen-python - $versions = "${{ inputs.PYTHON_VERSIONS }}" -split ' ' - foreach ($version in $versions) { - uvx maturin build --release --interpreter "C:\Users\Administrator\AppData\Roaming\uv\python\cpython-$version.*\python.exe" - } + uvx maturin build --release --interpreter "C:\Users\Administrator\AppData\Roaming\uv\python\cpython-${{ matrix.python_version }}.*\python.exe" - name: Upload wheel artifact uses: actions/upload-artifact@v4 with: - name: wheels-windows-${{ inputs.ARCHITECTURE }} + name: wheels-windows-${{ inputs.ARCHITECTURE }}-py${{ matrix.python_version }} path: ${{ github.workspace }}\oxen-python\target\wheels\*.whl retention-days: 1