Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6d02e39

Browse files
committed
ci: Merge sdist and wheel building workflows
This allows verifying that wheels can be installed after building, and that the sdist can be built into a wheel without a second workflow. Also simplify some of the checking scripts.
1 parent 78bf53c commit 6d02e39

File tree

5 files changed

+65
-118
lines changed

5 files changed

+65
-118
lines changed

.github/workflows/cibuildsdist.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.

.github/workflows/cibuildwheel.yml

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,45 @@ permissions:
2222
contents: read
2323

2424
jobs:
25+
build_sdist:
26+
if: |
27+
github.event_name == 'push' ||
28+
github.event_name == 'pull_request' && (
29+
(
30+
github.event.action == 'labeled' &&
31+
github.event.label.name == 'CI: Run cibuildwheel'
32+
) ||
33+
contains(github.event.pull_request.labels.*.name,
34+
'CI: Run cibuildwheel')
35+
)
36+
name: Build sdist and wheel on ${{ matrix.os }}
37+
runs-on: ubuntu-20.04
38+
39+
steps:
40+
- uses: actions/checkout@v3
41+
with:
42+
fetch-depth: 0
43+
44+
# Something changed somewhere that prevents the downloaded-at-build-time
45+
# licenses from being included in built wheels, so pre-download them so
46+
# that they exist before the build and are included.
47+
- name: Pre-download bundled licenses
48+
run: >
49+
curl -Lo LICENSE/LICENSE_QHULL
50+
https://github.com/qhull/qhull/raw/2020.2/COPYING.txt
51+
52+
- name: Build sdist
53+
run: pipx run build --sdist
54+
55+
- name: Check README rendering for PyPI
56+
run: pipx run twine check dist/*
57+
58+
- name: Upload sdist result
59+
uses: actions/upload-artifact@v3
60+
with:
61+
name: sdist
62+
path: dist/*.tar.gz
63+
2564
build_wheels:
2665
if: |
2766
github.event_name == 'push' ||
@@ -30,21 +69,28 @@ jobs:
3069
github.event.action == 'labeled' &&
3170
github.event.label.name == 'CI: Run cibuildwheel'
3271
) ||
33-
contains(github.event.pull_request.labels.*.name, 'CI: Run cibuildwheel')
72+
contains(github.event.pull_request.labels.*.name,
73+
'CI: Run cibuildwheel')
3474
)
75+
needs: build_sdist
3576
name: Build wheels on ${{ matrix.os }}
3677
runs-on: ${{ matrix.os }}
3778
env:
3879
CIBW_BEFORE_BUILD: >-
3980
pip install certifi oldest-supported-numpy &&
40-
git clean -fxd build
81+
rm -rf {package}build
4182
CIBW_BEFORE_BUILD_WINDOWS: >-
4283
pip install certifi delvewheel oldest-supported-numpy &&
43-
git clean -fxd build
84+
rm -rf {package}/build
4485
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >-
4586
delvewheel repair -w {dest_dir} {wheel}
87+
CIBW_AFTER_BUILD: twine check {wheel}
4688
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
4789
CIBW_SKIP: "*-musllinux*"
90+
CIBW_TEST_REQUIRES: oldest-supported-numpy
91+
CIBW_TEST_COMMAND: >-
92+
python {package}/ci/check_version_number.py &&
93+
python {package}/ci/check_wheel_licenses.py
4894
MACOSX_DEPLOYMENT_TARGET: "10.12"
4995
MPL_DISABLE_FH4: "yes"
5096
strategy:
@@ -66,47 +112,44 @@ jobs:
66112
with:
67113
platforms: arm64
68114

69-
- uses: actions/checkout@v3
115+
- name: Download sdist
116+
uses: actions/download-artifact@v3
70117
with:
71-
fetch-depth: 0
72-
73-
# Something changed somewhere that prevents the downloaded-at-build-time
74-
# licenses from being included in built wheels, so pre-download them so
75-
# that they exist before the build and are included.
76-
- name: Pre-download bundled licenses
77-
run: >
78-
curl -Lo LICENSE/LICENSE_QHULL
79-
https://github.com/qhull/qhull/raw/2020.2/COPYING.txt
118+
name: sdist
80119

81120
- name: Build wheels for CPython 3.11
82121
uses: pypa/[email protected]
122+
with:
123+
package-dir: dist/*.tar.gz
83124
env:
84125
CIBW_BUILD: "cp311-*"
85126
CIBW_ARCHS: ${{ matrix.cibw_archs }}
86127

87128
- name: Build wheels for CPython 3.10
88129
uses: pypa/[email protected]
130+
with:
131+
package-dir: dist/*.tar.gz
89132
env:
90133
CIBW_BUILD: "cp310-*"
91134
CIBW_ARCHS: ${{ matrix.cibw_archs }}
92135

93136
- name: Build wheels for CPython 3.9
94137
uses: pypa/[email protected]
138+
with:
139+
package-dir: dist/*.tar.gz
95140
env:
96141
CIBW_BUILD: "cp39-*"
97142
CIBW_ARCHS: ${{ matrix.cibw_archs }}
98143

99144
- name: Build wheels for PyPy
100145
uses: pypa/[email protected]
146+
with:
147+
package-dir: dist/*.tar.gz
101148
env:
102149
CIBW_BUILD: "pp39-*"
103150
CIBW_ARCHS: ${{ matrix.cibw_archs }}
104151
if: matrix.cibw_archs != 'aarch64'
105152

106-
- name: Validate that LICENSE files are included in wheels
107-
run: |
108-
python3 ./ci/check_wheel_licenses.py
109-
110153
- uses: actions/upload-artifact@v3
111154
with:
112155
name: wheels

ci/check_version_number.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
99
$ pip install dist/matplotlib*.whl for wheel
1010
$ ./ci/check_version_number.py
1111
"""
12-
import matplotlib
13-
1412
import sys
1513

16-
EXIT_SUCCESS = 0
17-
EXIT_FAILURE = 1
14+
import matplotlib
1815

1916

2017
print(f"Version {matplotlib.__version__} installed")
2118
if matplotlib.__version__[0] == "0":
22-
sys.exit(EXIT_FAILURE)
23-
sys.exit(EXIT_SUCCESS)
19+
sys.exit("Version incorrectly starts with 0")

ci/check_wheel_licenses.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import sys
1414
import zipfile
1515

16-
EXIT_SUCCESS = 0
17-
EXIT_FAILURE = 1
1816

1917
project_dir = Path(__file__).parent.resolve().parent
2018
dist_dir = project_dir / 'dist'
@@ -29,8 +27,6 @@
2927
if '.dist-info/LICENSE' in path}
3028
if not (len(wheel_license_file_names) and
3129
wheel_license_file_names.issuperset(license_file_names)):
32-
print(f'LICENSE file(s) missing:\n'
33-
f'{wheel_license_file_names} !=\n'
34-
f'{license_file_names}')
35-
sys.exit(EXIT_FAILURE)
36-
sys.exit(EXIT_SUCCESS)
30+
sys.exit(f'LICENSE file(s) missing:\n'
31+
f'{wheel_license_file_names} !=\n'
32+
f'{license_file_names}')

ci/silence

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)