summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2022-09-07 21:22:50 +0100
committerMichael Williamson <mike@zwobble.org>2022-09-07 21:53:23 +0100
commit5e0756dada43e11d83469d5123ca25cd1fbe397e (patch)
treee3f5ab51d430e3b83c78232c7eb2506321b45e32
parente56ae4ad9f23abf035a490fd924d4c75657dcdf3 (diff)
Create separate job for each binary wheel
-rw-r--r--.github/workflows/build.yml40
-rw-r--r--build-wheels-matrix.py57
2 files changed, 86 insertions, 11 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1b5854a..d49b7b0 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -51,29 +51,46 @@ jobs:
with:
path: dist/*.tar.gz
+ build_wheels_matrix:
+ name: Generate matrix for building wheels
+ runs-on: ubuntu-latest
+
+ outputs:
+ matrix: ${{ steps.set-matrix.outputs.matrix }}
+
+ steps:
+
+ - uses: actions/checkout@v2
+
+ - name: Use Python 3.10
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.10'
+
+ - name: Install cibuildwheel
+ run: python -m pip install cibuildwheel==2.9.0
+
+ - id: set-matrix
+ run: python build-wheels-matrix.py
+
build_wheels:
- name: Build wheels on ${{ matrix.os }}, linux-arch=${{ matrix.linux-arch }}
+ name: Build ${{ matrix.CIBW_BUILD }} wheel
+ needs: build_wheels_matrix
runs-on: ${{ matrix.os }}
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
strategy:
- matrix:
- os: [ubuntu-20.04, macos-10.15]
- python-version: [3.7]
- linux-arch: [auto]
- include:
- - os: ubuntu-20.04
- linux-arch: aarch64
+ matrix: ${{ fromJson(needs.build_wheels_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
- - name: Use Python ${{ matrix.python-version }}
+ - name: Use Python 3.10
uses: actions/setup-python@v2
with:
- python-version: ${{ matrix.python-version }}
+ python-version: '3.10'
- name: Set up QEMU
if: runner.os == 'Linux'
@@ -84,7 +101,8 @@ jobs:
- name: Build wheels
uses: pypa/cibuildwheel@v2.9.0
env:
- CIBW_ARCHS_LINUX: ${{ matrix.linux-arch }}
+ CIBW_ARCHS: ${{ matrix.CIBW_ARCHS }}
+ CIBW_BUILD: ${{ matrix.CIBW_BUILD }}
CIBW_BEFORE_BUILD: "pip install cython==0.29.32 && cython {project}/jq.pyx"
CIBW_TEST_REQUIRES: "-r test-requirements.txt"
CIBW_TEST_COMMAND: "py.test {project}/tests"
diff --git a/build-wheels-matrix.py b/build-wheels-matrix.py
new file mode 100644
index 0000000..2bb3df5
--- /dev/null
+++ b/build-wheels-matrix.py
@@ -0,0 +1,57 @@
+import json
+
+import cibuildwheel.linux
+import cibuildwheel.macos
+from cibuildwheel.architecture import Architecture
+from cibuildwheel.util import BuildSelector
+
+
+def _main():
+ build_selector = BuildSelector(
+ build_config="*",
+ skip_config="",
+ requires_python=None,
+ prerelease_pythons=None
+ )
+
+ linux_python_configurations = cibuildwheel.linux.get_python_configurations(
+ build_selector,
+ {Architecture.x86_64, Architecture.aarch64},
+ )
+
+ macos_python_configurations = cibuildwheel.macos.get_python_configurations(
+ build_selector,
+ {Architecture.x86_64}
+ )
+
+ matrix = {
+ "include": [
+ {
+ "os": "ubuntu-20.04",
+ "CIBW_ARCHS": _configuration_to_architecture(configuration).value,
+ "CIBW_BUILD": configuration.identifier,
+ }
+ for configuration in linux_python_configurations
+ ] + [
+ {
+ "os": "macos-10.15",
+ "CIBW_ARCHS": _configuration_to_architecture(configuration).value,
+ "CIBW_BUILD": configuration.identifier,
+ }
+ for configuration in macos_python_configurations
+ ]
+ }
+
+ print("::set-output name=matrix::" + json.dumps(matrix))
+
+
+def _configuration_to_architecture(configuration):
+ for architecture in Architecture:
+ if configuration.identifier.endswith(f"_{architecture.value}"):
+ return architecture
+
+ raise ValueError("could not find architecture for configuration")
+
+
+if __name__ == "__main__":
+ _main()