|
1 | 1 | # Github Actions script to produce binary wheels. |
2 | 2 | # |
3 | | -# Note that a lot of the cibuildwheel config is in pyproject.toml. |
4 | | -# |
5 | | -# We perform one build for each wheel that we generate, i.e. one per architecture. |
6 | | -# In download_wgpu_native.py, we detect CIBW_PLATFORM and CIBW_ARCHS to determine |
7 | | -# the required binary from wgpu-native. |
8 | | -# |
9 | | -# If https://github.com/pypa/cibuildwheel/issues/944 gets implemented, we can build more wheels per build. |
10 | | -# |
11 | | -# Also includes the sdist build that does not include a binary. |
12 | | - |
| 3 | +# * One build to create all wheels (cross-platform). |
| 4 | +# * One build (with matrix) test the wheels on a selection of platforms. |
| 5 | +# * One build to publish the wheels on GitHub and Pypi. |
13 | 6 |
|
14 | 7 | name: CD |
15 | 8 |
|
|
24 | 17 |
|
25 | 18 | jobs: |
26 | 19 |
|
27 | | - release-builds: |
28 | | - name: Build wheel for ${{ matrix.platform }} ${{ matrix.arch }} |
29 | | - timeout-minutes: 10 |
| 20 | + build-wheels: |
| 21 | + name: Build all wheels |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + - name: Set up Python |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: '3.12' |
| 29 | + - name: Install dev dependencies |
| 30 | + run: | |
| 31 | + python -m pip install --upgrade pip |
| 32 | + pip install -U -e .[build] |
| 33 | + - name: Build wheels (and sdist) |
| 34 | + run: python tools/build_all_wheels.py |
| 35 | + - name: Twine check |
| 36 | + run: | |
| 37 | + twine check dist/* |
| 38 | + - name: Upload distributions |
| 39 | + uses: actions/upload-artifact@v4 |
| 40 | + with: |
| 41 | + path: dist |
| 42 | + name: all_wheels |
| 43 | + |
| 44 | + test-wheels: |
| 45 | + name: Test wheel for ${{ matrix.name }} |
| 46 | + needs: [build-wheels] |
30 | 47 | runs-on: ${{ matrix.os }} |
31 | 48 | strategy: |
32 | 49 | fail-fast: false |
33 | 50 | matrix: |
34 | 51 | include: |
35 | | - - platform: windows |
36 | | - arch: AMD64 |
37 | | - os: windows-latest |
38 | | - testable: true |
39 | | - - platform: windows |
40 | | - arch: ARM64 |
| 52 | + - name: windows amd64 |
41 | 53 | os: windows-latest |
42 | | - - platform: windows |
43 | | - arch: x86 |
44 | | - os: windows-latest |
45 | | - - platform: macos |
46 | | - arch: arm64 |
| 54 | + - name: macos arm64 |
47 | 55 | os: macos-latest |
48 | | - testable: true |
49 | | - - platform: macos |
50 | | - arch: x86_64 |
| 56 | + - name: macos x86_64 |
51 | 57 | os: macos-13 # last Intel MacOS |
52 | | - cibw_version: '==2.16' # delocation does not work for later versions |
53 | | - - platform: linux |
54 | | - arch: x86_64 |
55 | | - os: ubuntu-latest |
56 | | - testable: true |
57 | | - - platform: linux |
58 | | - arch: aarch64 |
| 58 | + - name: linux amd64 |
59 | 59 | os: ubuntu-latest |
60 | 60 | steps: |
61 | 61 | - uses: actions/checkout@v4 |
62 | | - - name: Set up QEMU |
63 | | - if: matrix.platform == 'linux' && matrix.arch == 'aarch64' |
64 | | - uses: docker/setup-qemu-action@v3 |
| 62 | + - name: Set up Python |
| 63 | + uses: actions/setup-python@v5 |
65 | 64 | with: |
66 | | - platforms: arm64 |
67 | | - - name: Install dev dependencies |
68 | | - run: | |
69 | | - python -m pip install --upgrade pip wheel setuptools twine cibuildwheel${{ matrix.cibw_version}} |
70 | | - - name: Build wheels |
71 | | - run: python -m cibuildwheel --output-dir dist |
72 | | - env: |
73 | | - CIBW_PLATFORM: ${{ matrix.platform }} |
74 | | - CIBW_ARCHS: ${{ matrix.arch }} |
75 | | - - name: Twine check |
| 65 | + python-version: '3.12' |
| 66 | + - name: Download assets |
| 67 | + uses: actions/download-artifact@v4 |
| 68 | + with: |
| 69 | + path: dist |
| 70 | + - name: Flatten dist dir |
| 71 | + shell: bash |
76 | 72 | run: | |
77 | | - twine check dist/* |
78 | | - - name: Test wheel |
79 | | - if: matrix.testable |
| 73 | + find dist -mindepth 2 -type f -exec mv -f '{}' dist/ ';' |
| 74 | + rm -rf dist/*/ |
| 75 | + - name: Install and test wheel |
80 | 76 | shell: bash |
81 | 77 | run: | |
82 | 78 | rm -rf ./wgpu |
83 | | - filename=$(ls dist/*.whl) |
84 | | - pip install $filename |
| 79 | + # Install 'normally' to install deps, then force the install from dist-folder and nothing else |
| 80 | + pip install --find-links dist wgpu |
| 81 | + pip install --force-reinstall --no-deps --no-index --find-links dist wgpu |
85 | 82 | pushd $HOME |
86 | 83 | python -c 'import wgpu.backends.wgpu_native; print(wgpu.backends.wgpu_native._ffi.lib_path)' |
87 | 84 | popd |
88 | 85 | pip uninstall -y wgpu |
89 | 86 | git reset --hard HEAD |
90 | | - - name: Upload distributions |
91 | | - uses: actions/upload-artifact@v4 |
92 | | - with: |
93 | | - path: dist |
94 | | - name: ${{ matrix.platform }}-${{ matrix.arch }}-build |
95 | | - |
96 | | - |
97 | | - sdist-build: |
98 | | - name: Build sdist |
99 | | - timeout-minutes: 5 |
100 | | - runs-on: ubuntu-latest |
101 | | - strategy: |
102 | | - fail-fast: false |
103 | | - steps: |
104 | | - - uses: actions/checkout@v4 |
105 | | - - name: Set up Python |
106 | | - uses: actions/setup-python@v5 |
107 | | - with: |
108 | | - python-version: '3.12' |
109 | | - - name: Install dev dependencies |
110 | | - run: | |
111 | | - python -m pip install --upgrade pip |
112 | | - pip install -U -r dev-requirements.txt |
113 | | - - name: Create source distribution |
114 | | - run: | |
115 | | - python setup.py sdist |
116 | | - - name: Test sdist |
| 87 | + - name: Install from sdist |
117 | 88 | shell: bash |
118 | 89 | run: | |
119 | 90 | rm -rf ./wgpu |
| 91 | + rm -rf ./dist/*.whl |
| 92 | + # Install sdist, but no test, because there is no wgpu-native lib now. |
120 | 93 | filename=$(ls dist/*.tar.gz) |
121 | 94 | pip install $filename |
122 | | - # don't run tests, we just want to know if the sdist can be installed |
123 | 95 | pip uninstall -y wgpu |
124 | 96 | git reset --hard HEAD |
125 | | - - name: Twine check |
126 | | - run: | |
127 | | - twine check dist/* |
128 | | - - name: Upload distributions |
129 | | - uses: actions/upload-artifact@v4 |
130 | | - with: |
131 | | - path: dist |
132 | | - name: sdist-build |
133 | | - |
134 | 97 |
|
135 | 98 | publish: |
136 | 99 | name: Publish to Github and Pypi |
137 | 100 | runs-on: ubuntu-latest |
138 | | - needs: [release-builds, sdist-build] |
| 101 | + needs: [build-wheels, test-wheels] |
139 | 102 | if: success() && startsWith(github.ref, 'refs/tags/v') |
140 | 103 | steps: |
141 | 104 | - uses: actions/checkout@v4 |
|
0 commit comments