diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 4486aee8..a7f77a0b 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -70,19 +70,16 @@ def main() -> None: ''') parser.add_argument( - '-a', - '--architectures', - choices=[arch.value for arch in Architecture], - default=[], + '--archs', + default=os.environ.get("CIBW_ARCHS", 'auto'), help=''' Comma-separated list of CPU architectures to build for. If unspecified, builds the architectures natively supported on this machine. Set this option to build an architecture via emulation, for example, using binfmt_misc and qemu. - ''', - action="extend", - nargs="+", - type=Architecture, + Default: auto + Choices: auto, {} + '''.format(", ".join(a.name for a in Architecture)), ) parser.add_argument('--output-dir', default=os.environ.get('CIBW_OUTPUT_DIR', 'wheelhouse'), @@ -185,8 +182,10 @@ def main() -> None: print('cibuildwheel: Could not find setup.py, setup.cfg or pyproject.toml at root of package', file=sys.stderr) exit(2) + archs = [Architecture(a) for a in args.archs.split(",")] + if args.print_build_identifiers: - print_build_identifiers(platform, build_selector, args.architectures) + print_build_identifiers(platform, build_selector, archs) exit(0) manylinux_images: Optional[Dict[str, str]] = None @@ -219,7 +218,7 @@ def main() -> None: manylinux_images[build_platform] = image build_options = BuildOptions( - architectures=args.architectures, + architectures=archs, package_dir=package_dir, output_dir=output_dir, test_command=test_command, diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index b27b4c65..a9554396 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -18,10 +18,10 @@ from .util import ( re_pattern = re.compile(r'[cp]p\d{2}-manylinux_(\w*)') -def matches_platform(identifier: str, supported_platforms: List[Architecture]) -> bool: +def matches_platform(identifier: str, architectures: List[Architecture]) -> bool: matched_architecture = re_pattern.search(identifier) id_architecture = matched_architecture.group(1) if matched_architecture else '' - return id_architecture in supported_platforms + return id_architecture in architectures class PythonConfiguration(NamedTuple): @@ -73,10 +73,16 @@ def get_python_configurations( ] # skip builds as required - target_archs = architectures or [Architecture(platform.machine())] - # x86_64 machines can run i686 docker containers - if Architecture.i686 not in target_archs and Architecture.x86_64 in target_archs: - target_archs.append(Architecture.i686) + target_archs = architectures + + if Architecture.auto in architectures: + target_archs.remove(Architecture.auto) + native_architecture = Architecture(platform.machine()) + target_archs.append(native_architecture) + # x86_64 machines can run i686 docker containers + if native_architecture == Architecture.x86_64: + target_archs.append(Architecture.i686) + print("matching platforms to architectures: ", target_archs) return [ c for c in python_configurations diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 80ae3a36..5ea02f5b 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -122,6 +122,7 @@ class DependencyConstraints: class Architecture(str, Enum): + auto = 'auto' # gets expanded to the native arch, possibly 32+64 bit x86_64 = 'x86_64' i686 = 'i686' aarch64 = 'aarch64'