Add platform-specific CIBW_ARCHS options.
Remove 'auto' as a possible Architecture enum value. This is resolved at option parse time.
This commit is contained in:
@@ -71,7 +71,7 @@ def main() -> None:
|
||||
|
||||
parser.add_argument(
|
||||
'--archs',
|
||||
default=os.environ.get("CIBW_ARCHS", 'auto'),
|
||||
default=None,
|
||||
help='''
|
||||
Comma-separated list of CPU architectures to build for.
|
||||
If unspecified, builds the architectures natively supported
|
||||
@@ -182,7 +182,11 @@ 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.archs is not None:
|
||||
archs_config_str = args.archs
|
||||
else:
|
||||
archs_config_str = get_option_from_environment('CIBW_ARCHS', platform=platform, default='auto')
|
||||
archs = Architecture.parse_config(archs_config_str, platform=platform)
|
||||
|
||||
if args.print_build_identifiers:
|
||||
print_build_identifiers(platform, build_selector, archs)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import platform
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -75,14 +74,6 @@ def get_python_configurations(
|
||||
# skip builds as required
|
||||
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)
|
||||
|
||||
return [
|
||||
c for c in python_configurations
|
||||
if matches_platform(c.identifier, target_archs)
|
||||
|
||||
+23
-1
@@ -1,4 +1,6 @@
|
||||
import os
|
||||
import platform as platform_module
|
||||
import re
|
||||
import ssl
|
||||
import textwrap
|
||||
import urllib.request
|
||||
@@ -122,12 +124,32 @@ 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'
|
||||
ppc64le = 'ppc64le'
|
||||
s390x = 's390x'
|
||||
win32 = 'win32'
|
||||
win_amd64 = 'win_amd64'
|
||||
|
||||
@staticmethod
|
||||
def parse_config(config: str, platform: str) -> 'List[Architecture]':
|
||||
result = []
|
||||
for arch_str in re.split(r'[\s,]+', config):
|
||||
if arch_str == 'auto':
|
||||
result += Architecture.auto_archs(platform=platform)
|
||||
else:
|
||||
result.append(Architecture(arch_str))
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def auto_archs(platform: str) -> 'List[Architecture]':
|
||||
native_architecture = Architecture(platform_module.machine())
|
||||
result = [native_architecture]
|
||||
# x86_64 machines can run i686 docker containers
|
||||
if platform == 'linux' and native_architecture == Architecture.x86_64:
|
||||
result.append(Architecture.i686)
|
||||
return result
|
||||
|
||||
|
||||
class BuildOptions(NamedTuple):
|
||||
|
||||
Reference in New Issue
Block a user