From b1ce6db07c346058b5ee8e1b151c4e9f8132e778 Mon Sep 17 00:00:00 2001 From: f-allian Date: Wed, 30 Jul 2025 20:07:16 +0100 Subject: [PATCH] fix: precompile all wheels --- .github/workflows/publish-to-pypi.yaml | 85 ++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yaml b/.github/workflows/publish-to-pypi.yaml index c3c244e0..b30f200b 100644 --- a/.github/workflows/publish-to-pypi.yaml +++ b/.github/workflows/publish-to-pypi.yaml @@ -1,4 +1,4 @@ -name: Publish python PyPI +name: Publish to PyPI on: push: @@ -6,27 +6,88 @@ on: - v* jobs: - build-release: - name: Build and publish PyPI - runs-on: ubuntu-latest + # First job is to build the wheels on different OS + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 with: - fetch-depth: 0 + python-version: "3.12" + + - name: Upgrade pip and install cibuildwheel + run: | + python -m pip install --upgrade pip + pip install cibuildwheel + + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse + env: + CIBW_BUILD: "cp310-* cp311-* cp312-*" + CIBW_SKIP: "pp* *musllinux*" + CIBW_TEST_SKIP: "*" + CIBW_ARCHS_MACOS: "universal2" + CIBW_ARCHS_LINUX: "x86_64 aarch64" + + - name: Upload built wheels + uses: actions/upload-artifact@v3 + with: + name: wheels-${{ matrix.os }} + path: wheelhouse/*.whl + + # Then just build the source distribution as normal + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: "3.12" - - name: Install build tools + - name: Upgrade pip and install build run: | - pip install --upgrade pip setuptools wheel build setuptools_scm + python -m pip install --upgrade pip + pip install build + + - name: Build sdist + run: python -m build --sdist --outdir dist + + - name: Upload sdist + uses: actions/upload-artifact@v3 + with: + name: sdist + path: dist/*.tar.gz + + # Finally publish all files to PyPI + publish: + name: Publish to PyPI + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Download all artifacts + uses: actions/download-artifact@v3 + with: + path: dist - - name: Build Package + - name: Merge all distributions run: | - python -m build --no-isolation + mkdir -p final_dist + find dist -name '*.whl' -exec cp {} final_dist/ \; + find dist -name '*.tar.gz' -exec cp {} final_dist/ \; - - name: Publish package to PyPI + - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} + packages_dir: final_dist