refactor: --archs, CIBW_ARCHS, "auto"
Using `--archs` for the flag, comma separated, also accepting CIBW_ARCHS. Supports "auto" as the default that can also expand, matching CIBW_PLATFORM.
This commit is contained in:
@@ -70,19 +70,16 @@ def main() -> None:
|
|||||||
''')
|
''')
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-a',
|
'--archs',
|
||||||
'--architectures',
|
default=os.environ.get("CIBW_ARCHS", 'auto'),
|
||||||
choices=[arch.value for arch in Architecture],
|
|
||||||
default=[],
|
|
||||||
help='''
|
help='''
|
||||||
Comma-separated list of CPU architectures to build for.
|
Comma-separated list of CPU architectures to build for.
|
||||||
If unspecified, builds the architectures natively supported
|
If unspecified, builds the architectures natively supported
|
||||||
on this machine. Set this option to build an architecture
|
on this machine. Set this option to build an architecture
|
||||||
via emulation, for example, using binfmt_misc and qemu.
|
via emulation, for example, using binfmt_misc and qemu.
|
||||||
''',
|
Default: auto
|
||||||
action="extend",
|
Choices: auto, {}
|
||||||
nargs="+",
|
'''.format(", ".join(a.name for a in Architecture)),
|
||||||
type=Architecture,
|
|
||||||
)
|
)
|
||||||
parser.add_argument('--output-dir',
|
parser.add_argument('--output-dir',
|
||||||
default=os.environ.get('CIBW_OUTPUT_DIR', 'wheelhouse'),
|
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)
|
print('cibuildwheel: Could not find setup.py, setup.cfg or pyproject.toml at root of package', file=sys.stderr)
|
||||||
exit(2)
|
exit(2)
|
||||||
|
|
||||||
|
archs = [Architecture(a) for a in args.archs.split(",")]
|
||||||
|
|
||||||
if args.print_build_identifiers:
|
if args.print_build_identifiers:
|
||||||
print_build_identifiers(platform, build_selector, args.architectures)
|
print_build_identifiers(platform, build_selector, archs)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
manylinux_images: Optional[Dict[str, str]] = None
|
manylinux_images: Optional[Dict[str, str]] = None
|
||||||
@@ -219,7 +218,7 @@ def main() -> None:
|
|||||||
manylinux_images[build_platform] = image
|
manylinux_images[build_platform] = image
|
||||||
|
|
||||||
build_options = BuildOptions(
|
build_options = BuildOptions(
|
||||||
architectures=args.architectures,
|
architectures=archs,
|
||||||
package_dir=package_dir,
|
package_dir=package_dir,
|
||||||
output_dir=output_dir,
|
output_dir=output_dir,
|
||||||
test_command=test_command,
|
test_command=test_command,
|
||||||
|
|||||||
+10
-4
@@ -18,10 +18,10 @@ from .util import (
|
|||||||
re_pattern = re.compile(r'[cp]p\d{2}-manylinux_(\w*)')
|
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)
|
matched_architecture = re_pattern.search(identifier)
|
||||||
id_architecture = matched_architecture.group(1) if matched_architecture else ''
|
id_architecture = matched_architecture.group(1) if matched_architecture else ''
|
||||||
return id_architecture in supported_platforms
|
return id_architecture in architectures
|
||||||
|
|
||||||
|
|
||||||
class PythonConfiguration(NamedTuple):
|
class PythonConfiguration(NamedTuple):
|
||||||
@@ -73,10 +73,16 @@ def get_python_configurations(
|
|||||||
]
|
]
|
||||||
|
|
||||||
# skip builds as required
|
# skip builds as required
|
||||||
target_archs = architectures or [Architecture(platform.machine())]
|
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
|
# x86_64 machines can run i686 docker containers
|
||||||
if Architecture.i686 not in target_archs and Architecture.x86_64 in target_archs:
|
if native_architecture == Architecture.x86_64:
|
||||||
target_archs.append(Architecture.i686)
|
target_archs.append(Architecture.i686)
|
||||||
|
|
||||||
print("matching platforms to architectures: ", target_archs)
|
print("matching platforms to architectures: ", target_archs)
|
||||||
return [
|
return [
|
||||||
c for c in python_configurations
|
c for c in python_configurations
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ class DependencyConstraints:
|
|||||||
|
|
||||||
|
|
||||||
class Architecture(str, Enum):
|
class Architecture(str, Enum):
|
||||||
|
auto = 'auto' # gets expanded to the native arch, possibly 32+64 bit
|
||||||
x86_64 = 'x86_64'
|
x86_64 = 'x86_64'
|
||||||
i686 = 'i686'
|
i686 = 'i686'
|
||||||
aarch64 = 'aarch64'
|
aarch64 = 'aarch64'
|
||||||
|
|||||||
Reference in New Issue
Block a user