Skip to content

Commit fcbaef8

Browse files
committed
Add cross compilation support for linux AArch64
1 parent d8ef6e8 commit fcbaef8

File tree

9 files changed

+551
-6
lines changed

9 files changed

+551
-6
lines changed

bin/update_docker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class Image(NamedTuple):
3535
Image("manylinux2014", "pypy_x86_64", "quay.io/pypa/manylinux2014_x86_64", None),
3636
Image("manylinux2014", "pypy_i686", "quay.io/pypa/manylinux2014_i686", None),
3737
Image("manylinux2014", "pypy_aarch64", "quay.io/pypa/manylinux2014_aarch64", None),
38+
Image("manylinux2014", "xc_aarch64", "dockcross/manylinux2014_aarch64", None),
3839
# 2_24 images
3940
Image("manylinux_2_24", "x86_64", "quay.io/pypa/manylinux_2_24_x86_64", None),
4041
Image("manylinux_2_24", "i686", "quay.io/pypa/manylinux_2_24_i686", None),

cibuildwheel/__main__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import cibuildwheel
1313
import cibuildwheel.linux
14+
import cibuildwheel.crosslinux
1415
import cibuildwheel.macos
1516
import cibuildwheel.util
1617
import cibuildwheel.windows
@@ -35,6 +36,7 @@
3536
"i686",
3637
"pypy_x86_64",
3738
"aarch64",
39+
"xc_aarch64",
3840
"ppc64le",
3941
"s390x",
4042
"pypy_aarch64",
@@ -56,7 +58,7 @@ def main() -> None:
5658

5759
parser.add_argument(
5860
"--platform",
59-
choices=["auto", "linux", "macos", "windows"],
61+
choices=["auto", "linux", "crosslinux", "macos", "windows"],
6062
default=os.environ.get("CIBW_PLATFORM", "auto"),
6163
help="""
6264
Platform to build for. For "linux" you need docker running, on Mac
@@ -278,7 +280,7 @@ def main() -> None:
278280
sys.exit(0)
279281

280282
manylinux_images: Dict[str, str] = {}
281-
if platform == "linux":
283+
if platform == "linux" or platform == "crosslinux":
282284
pinned_docker_images_file = resources_dir / "pinned_docker_images.cfg"
283285
all_pinned_docker_images = ConfigParser()
284286
all_pinned_docker_images.read(pinned_docker_images_file)
@@ -347,6 +349,8 @@ def main() -> None:
347349
):
348350
if platform == "linux":
349351
cibuildwheel.linux.build(build_options)
352+
elif platform == "crosslinux":
353+
cibuildwheel.crosslinux.build(build_options)
350354
elif platform == "windows":
351355
cibuildwheel.windows.build(build_options)
352356
elif platform == "macos":
@@ -400,7 +404,7 @@ def get_build_identifiers(
400404
List[cibuildwheel.macos.PythonConfiguration],
401405
]
402406

403-
if platform == "linux":
407+
if platform == "linux" or platform == "crosslinux":
404408
python_configurations = cibuildwheel.linux.get_python_configurations(
405409
build_selector, architectures
406410
)

cibuildwheel/architecture.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from .typing import Literal, PlatformName, assert_never
88

9-
PRETTY_NAMES = {"linux": "Linux", "macos": "macOS", "windows": "Windows"}
9+
PRETTY_NAMES = {"linux": "Linux", "crosslinux": "CrossLinux", "macos": "macOS", "windows": "Windows"}
1010

1111

1212
@functools.total_ordering
@@ -57,6 +57,10 @@ def auto_archs(platform: PlatformName) -> "Set[Architecture]":
5757
native_architecture = Architecture(platform_module.machine())
5858
result = {native_architecture}
5959

60+
if platform == "crosslinux":
61+
result.add(Architecture.aarch64)
62+
result.remove(native_architecture)
63+
6064
if platform == "linux" and native_architecture == Architecture.x86_64:
6165
# x86_64 machines can run i686 docker containers
6266
result.add(Architecture.i686)
@@ -80,6 +84,10 @@ def all_archs(platform: PlatformName) -> "Set[Architecture]":
8084
Architecture.ppc64le,
8185
Architecture.s390x,
8286
}
87+
elif platform == "crosslinux":
88+
return {
89+
Architecture.aarch64,
90+
}
8391
elif platform == "macos":
8492
return {Architecture.x86_64, Architecture.arm64, Architecture.universal2}
8593
elif platform == "windows":

0 commit comments

Comments
 (0)