|
| 1 | +name: Python Dist |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "[0-9]+.[0-9]+.[0-9]+" |
| 7 | + - "[0-9]+.[0-9]+.[0-9]+.post[0-9]+" |
| 8 | + - "[0-9]+.[0-9]+.[0-9]+[a-b][0-9]+" |
| 9 | + - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+" |
| 10 | + workflow_dispatch: |
| 11 | + pull_request: |
| 12 | + workflow_call: |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: dist-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +defaults: |
| 19 | + run: |
| 20 | + shell: bash -eux {0} |
| 21 | + |
| 22 | +jobs: |
| 23 | + build_wheels: |
| 24 | + name: Build wheels for ${{ matrix.buildplat[1] }} |
| 25 | + runs-on: ${{ matrix.buildplat[0] }} |
| 26 | + strategy: |
| 27 | + # Ensure that a wheel builder finishes even if another fails |
| 28 | + fail-fast: false |
| 29 | + matrix: |
| 30 | + # Github Actions doesn't support pairing matrix values together, let's improvise |
| 31 | + # https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 |
| 32 | + buildplat: |
| 33 | + - [ubuntu-20.04, "manylinux_x86_64", "cp3*-manylinux_x86_64"] |
| 34 | + - [ubuntu-20.04, "manylinux_aarch64", "cp3*-manylinux_aarch64"] |
| 35 | + - [ubuntu-20.04, "manylinux_ppc64le", "cp3*-manylinux_ppc64le"] |
| 36 | + - [ubuntu-20.04, "manylinux_s390x", "cp3*-manylinux_s390x"] |
| 37 | + - [ubuntu-20.04, "manylinux_i686", "cp3*-manylinux_i686"] |
| 38 | + - [windows-2019, "win_amd6", "cp3*-win_amd64"] |
| 39 | + - [windows-2019, "win32", "cp3*-win32"] |
| 40 | + - [macos-14, "macos", "cp*-macosx_*"] |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Checkout pymongo |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + fetch-depth: 0 |
| 47 | + |
| 48 | + - uses: actions/setup-python@v5 |
| 49 | + with: |
| 50 | + cache: 'pip' |
| 51 | + python-version: 3.8 |
| 52 | + cache-dependency-path: 'pyproject.toml' |
| 53 | + allow-prereleases: true |
| 54 | + |
| 55 | + - name: Set up QEMU |
| 56 | + if: runner.os == 'Linux' |
| 57 | + uses: docker/setup-qemu-action@v3 |
| 58 | + with: |
| 59 | + platforms: all |
| 60 | + |
| 61 | + - name: Install cibuildwheel |
| 62 | + # Note: the default manylinux is manylinux2014 |
| 63 | + run: | |
| 64 | + python -m pip install -U pip |
| 65 | + python -m pip install "cibuildwheel>=2.17,<3" |
| 66 | +
|
| 67 | + - name: Build wheels |
| 68 | + env: |
| 69 | + CIBW_BUILD: ${{ matrix.buildplat[2] }} |
| 70 | + run: python -m cibuildwheel --output-dir wheelhouse |
| 71 | + |
| 72 | + - name: Build manylinux1 wheels |
| 73 | + if: ${{ matrix.buildplat[1] == 'manylinux_x86_64' || matrix.buildplat[1] == 'manylinux_i686' }} |
| 74 | + env: |
| 75 | + CIBW_MANYLINUX_X86_64_IMAGE: manylinux1 |
| 76 | + CIBW_MANYLINUX_I686_IMAGE: manylinux1 |
| 77 | + CIBW_BUILD: "cp38-${{ matrix.buildplat[1] }} cp39-${{ matrix.buildplat[1] }}" |
| 78 | + run: python -m cibuildwheel --output-dir wheelhouse |
| 79 | + |
| 80 | + - name: Assert all versions in wheelhouse |
| 81 | + if: ${{ ! startsWith(matrix.buildplat[1], 'macos') }} |
| 82 | + run: | |
| 83 | + ls wheelhouse/*cp38*.whl |
| 84 | + ls wheelhouse/*cp39*.whl |
| 85 | + ls wheelhouse/*cp310*.whl |
| 86 | + ls wheelhouse/*cp311*.whl |
| 87 | + ls wheelhouse/*cp312*.whl |
| 88 | +
|
| 89 | + - uses: actions/upload-artifact@v4 |
| 90 | + with: |
| 91 | + name: wheel-${{ matrix.buildplat[1] }} |
| 92 | + path: ./wheelhouse/*.whl |
| 93 | + if-no-files-found: error |
| 94 | + |
| 95 | + make_sdist: |
| 96 | + name: Make SDist |
| 97 | + runs-on: macos-13 |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v4 |
| 100 | + with: |
| 101 | + fetch-depth: 0 |
| 102 | + |
| 103 | + - uses: actions/setup-python@v5 |
| 104 | + with: |
| 105 | + # Build sdist on lowest supported Python |
| 106 | + python-version: '3.8' |
| 107 | + |
| 108 | + - name: Build SDist |
| 109 | + run: | |
| 110 | + set -ex |
| 111 | + python -m pip install -U pip build |
| 112 | + python -m build --sdist . |
| 113 | +
|
| 114 | + - name: Test SDist |
| 115 | + run: | |
| 116 | + python -m pip install dist/*.gz |
| 117 | + cd .. |
| 118 | + python -c "from pymongo import has_c; assert has_c()" |
| 119 | +
|
| 120 | + - uses: actions/upload-artifact@v4 |
| 121 | + with: |
| 122 | + name: "sdist" |
| 123 | + path: ./dist/*.tar.gz |
| 124 | + |
| 125 | + collect_dist: |
| 126 | + runs-on: ubuntu-latest |
| 127 | + needs: [build_wheels, make_sdist] |
| 128 | + name: Download Wheels |
| 129 | + steps: |
| 130 | + - name: Download all workflow run artifacts |
| 131 | + uses: actions/download-artifact@v4 |
| 132 | + - name: Flatten directory |
| 133 | + working-directory: . |
| 134 | + run: | |
| 135 | + find . -mindepth 2 -type f -exec mv {} . \; |
| 136 | + find . -type d -empty -delete |
| 137 | + - uses: actions/upload-artifact@v4 |
| 138 | + with: |
| 139 | + name: all-dist-${{ github.run_id }} |
| 140 | + path: "./*" |
0 commit comments