Skip to content

Commit 9fad66f

Browse files
mayeuthenryiii
andauthored
feat: add musllinux armv7l (#2017)
* feature: add musllinux armv7l * fix: local armv7l images * fix python 3.8 tests * address review comments --------- Co-authored-by: Henry Schreiner <[email protected]>
1 parent dfd01af commit 9fad66f

16 files changed

+126
-63
lines changed

README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ Python wheels are great. Building them across **Mac, Linux, Windows**, on **mult
2222
What does it do?
2323
----------------
2424

25-
| | macOS Intel | macOS Apple Silicon | Windows 64bit | Windows 32bit | Windows Arm64 | manylinux<br/>musllinux x86_64 | manylinux<br/>musllinux i686 | manylinux<br/>musllinux aarch64 | manylinux<br/>musllinux ppc64le | manylinux<br/>musllinux s390x | Pyodide |
26-
|----------------|----|-----|-----|-----|-----|----|-----|----|-----|-----|-----|
27-
| CPython 3.6 || N/A ||| N/A |||||| N/A |
28-
| CPython 3.7 || N/A ||| N/A |||||| N/A |
29-
| CPython 3.8 ||||| N/A |||||| N/A |
30-
| CPython 3.9 ||||| ✅² |||||| N/A |
31-
| CPython 3.10 ||||| ✅² |||||| N/A |
32-
| CPython 3.11 ||||| ✅² |||||| N/A |
33-
| CPython 3.12 ||||| ✅² |||||| ✅⁴ |
34-
| CPython 3.13³ ||||| ✅² |||||| N/A |
35-
| PyPy 3.7 v7.3 || N/A || N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A | N/A |
36-
| PyPy 3.8 v7.3 |||| N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A | N/A |
37-
| PyPy 3.9 v7.3 |||| N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A | N/A |
38-
| PyPy 3.10 v7.3 |||| N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A | N/A |
25+
| | macOS Intel | macOS Apple Silicon | Windows 64bit | Windows 32bit | Windows Arm64 | manylinux<br/>musllinux x86_64 | manylinux<br/>musllinux i686 | manylinux<br/>musllinux aarch64 | manylinux<br/>musllinux ppc64le | manylinux<br/>musllinux s390x | musllinux armv7l | Pyodide |
26+
|----------------|----|-----|-----|-----|-----|----|-----|----|-----|-----|---|-----|
27+
| CPython 3.6 || N/A ||| N/A |||||| | N/A |
28+
| CPython 3.7 || N/A ||| N/A |||||| | N/A |
29+
| CPython 3.8 ||||| N/A |||||| | N/A |
30+
| CPython 3.9 ||||| ✅² |||||| | N/A |
31+
| CPython 3.10 ||||| ✅² |||||| | N/A |
32+
| CPython 3.11 ||||| ✅² |||||| | N/A |
33+
| CPython 3.12 ||||| ✅² |||||| ||
34+
| CPython 3.13³ ||||| ✅² |||||| | N/A |
35+
| PyPy 3.7 v7.3 || N/A || N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A | N/A | N/A |
36+
| PyPy 3.8 v7.3 |||| N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A | N/A | N/A |
37+
| PyPy 3.9 v7.3 |||| N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A | N/A | N/A |
38+
| PyPy 3.10 v7.3 |||| N/A | N/A | ✅¹ | ✅¹ | ✅¹ | N/A | N/A | N/A | N/A |
3939

4040
<sup>¹ PyPy is only supported for manylinux wheels.</sup><br>
4141
<sup>² Windows arm64 support is experimental.</sup><br>

bin/generate_schema.py

+3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@
137137
musllinux-aarch64-image:
138138
type: string
139139
description: Specify alternative manylinux / musllinux container images
140+
musllinux-armv7l-image:
141+
type: string
142+
description: Specify alternative manylinux / musllinux container images
140143
musllinux-i686-image:
141144
type: string
142145
description: Specify alternative manylinux / musllinux container images

bin/update_docker.py

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class Image:
6565
Image("musllinux_1_2", "aarch64", "quay.io/pypa/musllinux_1_2_aarch64", None),
6666
Image("musllinux_1_2", "ppc64le", "quay.io/pypa/musllinux_1_2_ppc64le", None),
6767
Image("musllinux_1_2", "s390x", "quay.io/pypa/musllinux_1_2_s390x", None),
68+
Image("musllinux_1_2", "armv7l", "quay.io/pypa/musllinux_1_2_armv7l", None),
6869
]
6970

7071
config = configparser.ConfigParser()

cibuildwheel/architecture.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Architecture(Enum):
3737
aarch64 = "aarch64"
3838
ppc64le = "ppc64le"
3939
s390x = "s390x"
40+
armv7l = "armv7l"
4041

4142
# mac archs
4243
universal2 = "universal2"
@@ -132,6 +133,7 @@ def all_archs(platform: PlatformName) -> set[Architecture]:
132133
Architecture.aarch64,
133134
Architecture.ppc64le,
134135
Architecture.s390x,
136+
Architecture.armv7l,
135137
},
136138
"macos": {Architecture.x86_64, Architecture.arm64, Architecture.universal2},
137139
"windows": {Architecture.x86, Architecture.AMD64, Architecture.ARM64},
@@ -140,17 +142,15 @@ def all_archs(platform: PlatformName) -> set[Architecture]:
140142
return all_archs_map[platform]
141143

142144
@staticmethod
143-
# pylint: disable-next=inconsistent-return-statements
144145
def bitness_archs(platform: PlatformName, bitness: Literal["64", "32"]) -> set[Architecture]:
145-
archs_32 = {Architecture.i686, Architecture.x86}
146+
archs_32 = {Architecture.i686, Architecture.x86, Architecture.armv7l}
146147
auto_archs = Architecture.auto_archs(platform)
147148

148149
if bitness == "64":
149150
return auto_archs - archs_32
150-
elif bitness == "32":
151+
if bitness == "32":
151152
return auto_archs & archs_32
152-
else:
153-
assert_never(bitness)
153+
assert_never(bitness)
154154

155155

156156
def allowed_architectures_check(

cibuildwheel/linux.py

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
Architecture.aarch64: OCIPlatform.ARM64,
3636
Architecture.ppc64le: OCIPlatform.PPC64LE,
3737
Architecture.s390x: OCIPlatform.S390X,
38+
Architecture.armv7l: OCIPlatform.ARMV7,
3839
}
3940

4041

cibuildwheel/logger.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"musllinux_i686": "musllinux i686",
2828
"musllinux_aarch64": "musllinux aarch64",
2929
"musllinux_ppc64le": "musllinux ppc64le",
30-
"musllinux_s390x": "manylinux s390x",
30+
"musllinux_s390x": "musllinux s390x",
31+
"musllinux_armv7l": "musllinux armv7l",
3132
"win32": "Windows 32bit",
3233
"win_amd64": "Windows 64bit",
3334
"win_arm64": "Windows on ARM 64bit",

cibuildwheel/oci_container.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
class OCIPlatform(Enum):
3939
i386 = "linux/386"
4040
AMD64 = "linux/amd64"
41+
ARMV7 = "linux/arm/v7"
4142
ARM64 = "linux/arm64"
4243
PPC64LE = "linux/ppc64le"
4344
S390X = "linux/s390x"
@@ -208,7 +209,11 @@ def _get_platform_args(self, *, oci_platform: OCIPlatform | None = None) -> tupl
208209
"inspect",
209210
self.image,
210211
"--format",
211-
"{{.Os}}/{{.Architecture}}",
212+
(
213+
"{{.Os}}/{{.Architecture}}/{{.Variant}}"
214+
if len(oci_platform.value.split("/")) == 3
215+
else "{{.Os}}/{{.Architecture}}"
216+
),
212217
capture_stdout=True,
213218
).strip()
214219
if image_platform == oci_platform.value:
@@ -235,7 +240,7 @@ def __enter__(self) -> Self:
235240
platform_args = self._get_platform_args()
236241

237242
simulate_32_bit = False
238-
if self.oci_platform == OCIPlatform.i386:
243+
if self.oci_platform in {OCIPlatform.i386, OCIPlatform.ARMV7}:
239244
# If the architecture running the image is already the right one
240245
# or the image entrypoint takes care of enforcing this, then we don't need to
241246
# simulate this
@@ -246,13 +251,14 @@ def __enter__(self) -> Self:
246251
*run_cmd, *platform_args, self.image, *ctr_cmd, capture_stdout=True
247252
).strip()
248253
except subprocess.CalledProcessError:
249-
# The image might have been built with amd64 architecture
250-
# Let's try that
251-
platform_args = self._get_platform_args(oci_platform=OCIPlatform.AMD64)
252-
container_machine = call(
253-
*run_cmd, *platform_args, self.image, *ctr_cmd, capture_stdout=True
254-
).strip()
255-
simulate_32_bit = container_machine != "i686"
254+
if self.oci_platform == OCIPlatform.i386:
255+
# The image might have been built with amd64 architecture
256+
# Let's try that
257+
platform_args = self._get_platform_args(oci_platform=OCIPlatform.AMD64)
258+
container_machine = call(
259+
*run_cmd, *platform_args, self.image, *ctr_cmd, capture_stdout=True
260+
).strip()
261+
simulate_32_bit = container_machine not in {"i686", "armv7l", "armv8l"}
256262

257263
shell_args = ["linux32", "/bin/bash"] if simulate_32_bit else ["/bin/bash"]
258264

cibuildwheel/resources/build-platforms.toml

+9
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ python_configurations = [
102102
{ identifier = "cp312-musllinux_s390x", version = "3.12", path_str = "/opt/python/cp312-cp312" },
103103
{ identifier = "cp313-musllinux_s390x", version = "3.13", path_str = "/opt/python/cp313-cp313" },
104104
{ identifier = "cp313t-musllinux_s390x", version = "3.13", path_str = "/opt/python/cp313-cp313t" },
105+
{ identifier = "cp36-musllinux_armv7l", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
106+
{ identifier = "cp37-musllinux_armv7l", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
107+
{ identifier = "cp38-musllinux_armv7l", version = "3.8", path_str = "/opt/python/cp38-cp38" },
108+
{ identifier = "cp39-musllinux_armv7l", version = "3.9", path_str = "/opt/python/cp39-cp39" },
109+
{ identifier = "cp310-musllinux_armv7l", version = "3.10", path_str = "/opt/python/cp310-cp310" },
110+
{ identifier = "cp311-musllinux_armv7l", version = "3.11", path_str = "/opt/python/cp311-cp311" },
111+
{ identifier = "cp312-musllinux_armv7l", version = "3.12", path_str = "/opt/python/cp312-cp312" },
112+
{ identifier = "cp313-musllinux_armv7l", version = "3.13", path_str = "/opt/python/cp313-cp313" },
113+
{ identifier = "cp313t-musllinux_armv7l", version = "3.13", path_str = "/opt/python/cp313-cp313t" },
105114
]
106115

107116
[macos]

cibuildwheel/resources/cibuildwheel.schema.json

+11
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@
312312
"description": "Specify alternative manylinux / musllinux container images",
313313
"title": "CIBW_MUSLLINUX_AARCH64_IMAGE"
314314
},
315+
"musllinux-armv7l-image": {
316+
"type": "string",
317+
"description": "Specify alternative manylinux / musllinux container images",
318+
"title": "CIBW_MUSLLINUX_ARMV7L_IMAGE"
319+
},
315320
"musllinux-i686-image": {
316321
"type": "string",
317322
"description": "Specify alternative manylinux / musllinux container images",
@@ -542,6 +547,9 @@
542547
"musllinux-aarch64-image": {
543548
"$ref": "#/properties/musllinux-aarch64-image"
544549
},
550+
"musllinux-armv7l-image": {
551+
"$ref": "#/properties/musllinux-armv7l-image"
552+
},
545553
"musllinux-i686-image": {
546554
"$ref": "#/properties/musllinux-i686-image"
547555
},
@@ -630,6 +638,9 @@
630638
"musllinux-aarch64-image": {
631639
"$ref": "#/properties/musllinux-aarch64-image"
632640
},
641+
"musllinux-armv7l-image": {
642+
"$ref": "#/properties/musllinux-armv7l-image"
643+
},
633644
"musllinux-i686-image": {
634645
"$ref": "#/properties/musllinux-i686-image"
635646
},

cibuildwheel/resources/defaults.toml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ musllinux-i686-image = "musllinux_1_2"
3737
musllinux-aarch64-image = "musllinux_1_2"
3838
musllinux-ppc64le-image = "musllinux_1_2"
3939
musllinux-s390x-image = "musllinux_1_2"
40+
musllinux-armv7l-image = "musllinux_1_2"
4041

4142

4243
[tool.cibuildwheel.linux]

cibuildwheel/resources/pinned_docker_images.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2024.09.28-3
5252
manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-12-26-0d38463
5353
manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2024.09.28-3
5454

55+
[armv7l]
56+
musllinux_1_2 = quay.io/pypa/musllinux_1_2_armv7l:2024.09.22-4
57+

cibuildwheel/util.py

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"aarch64",
8484
"ppc64le",
8585
"s390x",
86+
"armv7l",
8687
)
8788

8889
DEFAULT_CIBW_CACHE_PATH: Final[Path] = user_cache_path(appname="cibuildwheel", appauthor="pypa")

0 commit comments

Comments
 (0)