From 90a14b9dd29ac948f2023801bddb19d87533ef23 Mon Sep 17 00:00:00 2001 From: Pavel Savchenko Date: Sat, 12 Dec 2020 21:23:27 +0000 Subject: [PATCH] fixup! Support docker qemu emulation in any linux env --- .github/workflows/test.yml | 5 +++-- cibuildwheel/linux.py | 39 +++++++++++++++++--------------------- 2 files changed, 20 insertions(+), 24 deletions(-) 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..57e83803f 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -1,4 +1,5 @@ import platform +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,14 @@ 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)] + target_archs = [platform.machine()] + return [ + c for c in python_configurations + if matches_platform(c.identifier, target_archs) + and build_selector(c.identifier) + ] def build(options: BuildOptions) -> None: