Skip to content

Commit 4c0f884

Browse files
authored
PYTHON-4409 Streamline Wheel Building (#1624)
1 parent 6584dd2 commit 4c0f884

File tree

2 files changed

+31
-86
lines changed

2 files changed

+31
-86
lines changed

.github/workflows/release-python.yml

+30-86
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ defaults:
2020

2121
jobs:
2222
build_wheels:
23-
name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }}
23+
name: Build wheels for ${{ matrix.buildplat[1] }}
2424
runs-on: ${{ matrix.buildplat[0] }}
2525
strategy:
2626
# Ensure that a wheel builder finishes even if another fails
@@ -29,43 +29,25 @@ jobs:
2929
# Github Actions doesn't support pairing matrix values together, let's improvise
3030
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
3131
buildplat:
32-
- [ubuntu-20.04, manylinux_x86_64]
33-
- [ubuntu-20.04, manylinux_aarch64]
34-
- [ubuntu-20.04, manylinux_ppc64le]
35-
- [ubuntu-20.04, manylinux_s390x]
36-
- [ubuntu-20.04, manylinux_i686]
37-
- [windows-2019, win_amd64]
38-
- [windows-2019, win32]
39-
python: ["cp37", "cp38", "cp39", "cp310", "cp311", "cp312"]
40-
include:
41-
- buildplat: [macos-11, macosx_*]
42-
python: "cp37"
43-
- buildplat: [macos-11, macosx_*]
44-
python: "cp38"
45-
- buildplat: [macos-11, macosx_*]
46-
python: "cp39"
47-
- buildplat: [macos-14, macosx_*]
48-
python: "cp310"
49-
- buildplat: [macos-14, macosx_*]
50-
python: "cp311"
51-
- buildplat: [macos-14, macosx_*]
52-
python: "cp312"
32+
- [ubuntu-20.04, "manylinux_x86_64", "cp3*-manylinux_x86_64"]
33+
- [ubuntu-20.04, "manylinux_aarch64", "cp3*-manylinux_aarch64"]
34+
- [ubuntu-20.04, "manylinux_ppc64le", "cp3*-manylinux_ppc64le"]
35+
- [ubuntu-20.04, "manylinux_s390x", "cp3*-manylinux_s390x"]
36+
- [ubuntu-20.04, "manylinux_i686", "cp3*-manylinux_i686"]
37+
- [windows-2019, "win_amd6", "cp3*-win_amd64"]
38+
- [windows-2019, "win32", "cp3*-win32"]
39+
- [macos-14, "macos", "cp*-macosx_*"]
5340

5441
steps:
5542
- name: Checkout pymongo
5643
uses: actions/checkout@v4
5744
with:
5845
fetch-depth: 0
5946

60-
- name: Set up python version
61-
run: |
62-
export PYTHON_VERSION=$(sed 's/^cp3/3./' <<< ${{ matrix.python }} )
63-
echo "PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
64-
6547
- uses: actions/setup-python@v5
6648
with:
67-
python-version: ${{env.PYTHON_VERSION}}
6849
cache: 'pip'
50+
python-version: 3.8
6951
cache-dependency-path: 'pyproject.toml'
7052
allow-prereleases: true
7153

@@ -79,75 +61,37 @@ jobs:
7961
# Note: the default manylinux is manylinux2014
8062
run: |
8163
python -m pip install -U pip
82-
python -m pip install "cibuildwheel>=2.4,<3"
64+
python -m pip install "cibuildwheel>=2.17,<3"
8365
84-
- name: Build wheel
85-
if: ${{ matrix.buildplat[0] != 'macos-14' }}
66+
- name: Build wheels
8667
env:
87-
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
88-
MACOS_TEST_SKIP: "*arm64"
68+
CIBW_BUILD: ${{ matrix.buildplat[2] }}
8969
run: python -m cibuildwheel --output-dir wheelhouse
9070

91-
- name: Build wheel on M1
92-
if: ${{ matrix.buildplat[0] == 'macos-14' }}
71+
- name: Build manylinux1 wheels
72+
if: ${{ matrix.buildplat[1] == 'manylinux_x86_64' || matrix.buildplat[1] == 'manylinux_i686' }}
9373
env:
94-
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
74+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux1
75+
CIBW_MANYLINUX_I686_IMAGE: manylinux1
76+
CIBW_BUILD: "cp37-${{ matrix.buildplat[1] }} cp38-${{ matrix.buildplat[1] }} cp39-${{ matrix.buildplat[1] }}"
9577
run: python -m cibuildwheel --output-dir wheelhouse
9678

79+
- name: Assert all versions in wheelhouse
80+
if: ${{ ! startsWith(matrix.buildplat[1], 'macos') }}
81+
run: |
82+
ls wheelhouse/*cp37*.whl
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+
9789
- uses: actions/upload-artifact@v4
9890
with:
99-
name: wheel-${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }}
91+
name: wheel-${{ matrix.buildplat[1] }}
10092
path: ./wheelhouse/*.whl
10193
if-no-files-found: error
10294

103-
build_manylinux1_wheels:
104-
runs-on: ubuntu-latest
105-
strategy:
106-
# Ensure that a wheel builder finishes even if another fails
107-
fail-fast: false
108-
matrix:
109-
python: ["cp37", "cp38", "cp39"]
110-
steps:
111-
- name: Checkout pymongo
112-
uses: actions/checkout@v4
113-
with:
114-
fetch-depth: 0
115-
116-
- name: Set up python version
117-
run: |
118-
export PYTHON_VERSION=$(sed 's/^cp3/3./' <<< ${{ matrix.python }} )
119-
echo "PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
120-
121-
- uses: actions/setup-python@v5
122-
with:
123-
python-version: ${{env.PYTHON_VERSION}}
124-
cache: 'pip'
125-
cache-dependency-path: 'pyproject.toml'
126-
allow-prereleases: true
127-
128-
- name: Install cibuildwheel
129-
run: |
130-
python -m pip install -U pip
131-
python -m pip install "cibuildwheel>=2.4,<3"
132-
133-
- name: Build manylinux_x86_64
134-
env:
135-
CIBW_BUILD: ${{ matrix.python }}-manylinux_x86_64
136-
CIBW_MANYLINUX_X86_64_IMAGE: manylinux1
137-
run: python -m cibuildwheel --output-dir wheelhouse
138-
139-
- name: Build manylinux_i686
140-
env:
141-
CIBW_BUILD: ${{ matrix.python }}-manylinux_i686
142-
CIBW_MANYLINUX_I686_IMAGE: manylinux1
143-
run: python -m cibuildwheel --output-dir wheelhouse
144-
145-
- uses: actions/upload-artifact@v4
146-
with:
147-
name: wheel-${{ matrix.python }}-manylinux1
148-
path: ./wheelhouse/*.whl
149-
if-no-files-found: error
150-
15195
make_sdist:
15296
name: Make SDist
15397
runs-on: macos-13
@@ -180,7 +124,7 @@ jobs:
180124

181125
collect_dist:
182126
runs-on: ubuntu-latest
183-
needs: [build_wheels, build_manylinux1_wheels, make_sdist]
127+
needs: [build_wheels, make_sdist]
184128
name: Download Wheels
185129
steps:
186130
- name: Download all workflow run artifacts

.github/workflows/test-python.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Python Tests
22

33
on:
44
push:
5+
branches: ["master", "v**"]
56
pull_request:
67
workflow_dispatch:
78

0 commit comments

Comments
 (0)