diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab4d6fa88..3c7fdb4b5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-18.04, windows-latest, macos-latest] + os: [ubuntu-18.04] + # os: [ubuntu-18.04, windows-latest, macos-latest] python_version: ['3.7'] timeout-minutes: 180 steps: @@ -52,7 +53,7 @@ jobs: uses: docker/setup-qemu-action@v1 with: platforms: all - if: runner.os == "Linux" + if: runner.os == 'Linux' - name: Sample build if: contains(steps.pr-labels.outputs.labels, ' ci-sample-build ') diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index d0f36a9d2..aebe60b3f 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -1,4 +1,5 @@ -import platform +import json +import re import subprocess import sys import textwrap @@ -12,27 +13,15 @@ get_build_verbosity_extra_flags, prepare_command) -def matches_platform(identifier: str) -> bool: - output = subprocess.check_output(['docker', '--version']) - print("We found support for these platforms:", output) - pm = platform.machine() - if pm == "x86_64": - # x86_64 machines can run i686 docker containers - if identifier.endswith('x86_64') or identifier.endswith('i686'): - return True - elif pm == "i686": - if identifier.endswith('i686'): - return True - elif pm == "aarch64": - if identifier.endswith('aarch64'): - return True - elif pm == "ppc64le": - if identifier.endswith('ppc64le'): - return True - elif pm == "s390x": - if identifier.endswith('s390x'): - return True - return False +re_pattern = re.compile(r'[cp]p\d{2}-manylinux_(\w*)') + + +def matches_platform(identifier: str, supported_platforms: List[str]) -> bool: + matched_architecture = re_pattern.search(identifier) + id_architecture = matched_architecture.group(1) if matched_architecture else '' + # x86_64 machines can run i686 docker containers + id_architecture = id_architecture if id_architecture == 'i686' else 'x86_64' + return id_architecture in supported_platforms class PythonConfiguration(NamedTuple): @@ -80,8 +69,17 @@ def get_python_configurations(build_selector: BuildSelector) -> List[PythonConfi PythonConfiguration(version='3.8', identifier='cp38-manylinux_s390x', path_str='/opt/python/cp38-cp38'), PythonConfiguration(version='3.9', identifier='cp39-manylinux_s390x', path_str='/opt/python/cp39-cp39'), ] + # skip builds as required - return [c for c in python_configurations if matches_platform(c.identifier) and build_selector(c.identifier)] + output = subprocess.check_output(['docker', 'run', '--rm', '--privileged', 'tonistiigi/binfmt:latest']) + platforms_output = json.loads(output) + # ['linux/amd64', 'linux/arm64', 'linux/riscv64', 'linux/ppc64le', 'linux/s390x', 'linux/386', 'linux/arm/v7', 'linux/arm/v6'] + platforms = [ + platform.replace('linux/', '').replace('amd64', 'x86_64').replace('/', '_') + for platform in platforms_output['supported'] + ] + log.step(f"Support found for: {platforms}") + return [c for c in python_configurations if matches_platform(c.identifier, platforms) and build_selector(c.identifier)] def build(options: BuildOptions) -> None: