Skip to content

Commit c93d51e

Browse files
authored
feat: add armv7l in auto_archs when running on aarch64 (#2259)
* feat: add armv7l in auto_archs when running on aarch64 This depends on aarch32 EL0 support and thus is done conditionally. * ci(travis): move to Ubuntu 22.04 / cp312
1 parent c738289 commit c93d51e

14 files changed

+96
-50
lines changed

.travis.yml

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
os: linux
2-
dist: focal
2+
dist: jammy
33
language: python
44

55
branches:
@@ -8,29 +8,19 @@ branches:
88

99
jobs:
1010
include:
11-
- name: Linux | x86_64 + i686 | Python 3.11
12-
python: 3.11
11+
- name: Linux | x86_64 + i686 | Python 3.12
12+
python: 3.12
1313
services: docker
1414
env: PYTHON=python
1515

16-
- name: Linux | arm64 | Python 3.11
17-
python: 3.11
16+
- name: Linux | arm64 | Python 3.12
17+
python: 3.12
1818
services: docker
19-
arch: arm64-graviton2
20-
group: edge
21-
virt: vm
19+
arch: arm64
2220
env: PYTHON=python
23-
# docker is outdated in the arm64-graviton2 vm focal image (19.x)
24-
# we need to upgrade to get >= 24.0
25-
addons:
26-
apt:
27-
sources:
28-
- sourceline: 'deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable'
29-
packages:
30-
- docker-ce docker-ce-cli containerd.io
3121

32-
- name: Linux | ppc64le | Python 3.11
33-
python: 3.11
22+
- name: Linux | ppc64le | Python 3.12
23+
python: 3.12
3424
services: docker
3525
arch: ppc64le
3626
allow_failure: True
@@ -40,16 +30,16 @@ jobs:
4030
# c.f. https://travis-ci.community/t/running-out-of-disk-space-quota-when-using-docker-on-ppc64le/11634
4131
- PYTEST_ADDOPTS='-k "not test_manylinuxXXXX_only"'
4232

43-
- name: Windows | x86_64 | Python 3.11
33+
- name: Windows | x86_64 | Python 3.12
4434
os: windows
4535
language: shell
4636
before_install:
47-
- choco upgrade python3 -y --version 3.11.9 --limit-output --params "/InstallDir:C:\\Python311"
37+
- choco upgrade python3 -y --version 3.12.8 --limit-output --params "/InstallDir:C:\\Python312"
4838
env:
49-
- PYTHON=C:\\Python311\\python
39+
- PYTHON=C:\\Python312\\python
5040

51-
- name: Linux | s390x | Python 3.11
52-
python: 3.11
41+
- name: Linux | s390x | Python 3.12
42+
python: 3.12
5343
services: docker
5444
arch: s390x
5545
allow_failure: True

CI.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
This is a summary of the host Python versions and platforms covered by the different CI platforms:
22

3-
| | 3.11 | 3.12 | 3.13 |
4-
|---------|----------------------------------------------|---------------------------------------------|----------------|
5-
| Linux | Azure Pipelines / GitHub Actions / Travis CI | AppVeyor¹ / CircleCI¹ / Cirrus CI / GitLab¹ | GitHub Actions |
6-
| macOS | Azure Pipelines / GitLab¹ | AppVeyor¹ / CircleCI¹ / Cirrus CI / GitLab¹ | GitHub Actions |
7-
| Windows | Azure Pipelines / Travis CI | AppVeyor¹ / Cirrus CI / GitLab¹ | GitHub Actions |
3+
| | 3.11 | 3.12 | 3.13 |
4+
|---------|----------------------------------|---------------------------------------------------------|----------------|
5+
| Linux | Azure Pipelines / GitHub Actions | AppVeyor¹ / CircleCI¹ / Cirrus CI / GitLab¹ / Travis CI | GitHub Actions |
6+
| macOS | Azure Pipelines | AppVeyor¹ / CircleCI¹ / Cirrus CI / GitLab¹ | GitHub Actions |
7+
| Windows | Azure Pipelines | AppVeyor¹ / Cirrus CI / GitLab¹ / Travis CI | GitHub Actions |
88

99
> ¹ Runs a reduced set of tests to reduce CI load
1010
11-
Non-x86 architectures are covered on Travis CI using Python 3.11.
11+
Non-x86 architectures are covered on Travis CI using Python 3.12.

cibuildwheel/architecture.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import functools
44
import platform as platform_module
55
import re
6+
import shutil
7+
import subprocess
68
import sys
79
from collections.abc import Set
810
from enum import Enum
@@ -24,6 +26,19 @@
2426
]
2527

2628

29+
def _check_aarch32_el0() -> bool:
30+
"""Check if running armv7l natively on aarch64 is supported"""
31+
if not sys.platform.startswith("linux"):
32+
return False
33+
if platform_module.machine() != "aarch64":
34+
return False
35+
executable = shutil.which("linux32")
36+
if executable is None:
37+
return False
38+
check = subprocess.run([executable, "uname", "-m"], check=False, capture_output=True, text=True)
39+
return check.returncode == 0 and check.stdout.startswith("armv")
40+
41+
2742
@functools.total_ordering
2843
class Architecture(Enum):
2944
value: str
@@ -114,9 +129,12 @@ def auto_archs(platform: PlatformName) -> set[Architecture]:
114129
return set() # can't build anything on this platform
115130
result = {native_arch}
116131

117-
if platform == "linux" and Architecture.x86_64 in result:
118-
# x86_64 machines can run i686 containers
119-
result.add(Architecture.i686)
132+
if platform == "linux":
133+
if Architecture.x86_64 in result:
134+
# x86_64 machines can run i686 containers
135+
result.add(Architecture.i686)
136+
elif Architecture.aarch64 in result and _check_aarch32_el0():
137+
result.add(Architecture.armv7l)
120138

121139
if platform == "windows" and Architecture.AMD64 in result:
122140
result.add(Architecture.x86)

examples/github-with-qemu.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ jobs:
2626
# configure cibuildwheel on Linux to build native archs ('auto'),
2727
# and to split the remaining architectures between the x86_64 and
2828
# ARM runners
29-
# armv7l can be built without QEMU on GitHub Actions ARM runners but that's
30-
# not the case on all ARM64 hardware hence 'auto armv7l' for native archs
31-
# on the GHA ARM64 runner
32-
CIBW_ARCHS_LINUX: ${{ runner.arch == 'X64' && 'auto ppc64le s390x' || 'auto armv7l' }}
29+
CIBW_ARCHS_LINUX: ${{ runner.arch == 'X64' && 'auto ppc64le s390x' || 'auto' }}
3330

3431
- uses: actions/upload-artifact@v4
3532
with:

examples/travis-ci-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# commit, but will only push to PyPI on tagged commits.
33

44
os: linux
5-
dist: focal
5+
dist: jammy
66
language: python
77
python: "3.12"
88

examples/travis-ci-minimal.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
os: linux
2-
dist: focal
2+
dist: jammy
33
language: python
44
python: "3.12"
55

examples/travis-ci-test-and-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# distribution is also created.
77

88
os: linux
9-
dist: focal
9+
dist: jammy
1010
language: python
1111
python: "3.12"
1212

test/test_manylinuxXXXX_only.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def test(manylinux_image, tmp_path):
108108
if manylinux_image in {"manylinux_2_28", "manylinux_2_34"} and platform.machine() == "x86_64":
109109
# We don't have a manylinux_2_28+ image for i686
110110
add_env["CIBW_ARCHS"] = "x86_64"
111+
if platform.machine() == "aarch64":
112+
# We just have a manylinux_2_31 image for armv7l
113+
add_env["CIBW_ARCHS"] = "aarch64"
111114

112115
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
113116

@@ -150,4 +153,8 @@ def test(manylinux_image, tmp_path):
150153
# We don't have a manylinux_2_28+ image for i686
151154
expected_wheels = [w for w in expected_wheels if "i686" not in w]
152155

156+
if platform.machine() == "aarch64":
157+
# We just have a manylinux_2_31 image for armv7l
158+
expected_wheels = [w for w in expected_wheels if "armv7l" not in w]
159+
153160
assert set(actual_wheels) == set(expected_wheels)

test/test_musllinux_X_Y_only.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test(musllinux_image, tmp_path):
3838

3939
# build the wheels
4040
add_env = {
41-
"CIBW_SKIP": "*-manylinux*",
41+
"CIBW_SKIP": "*-manylinux* *_armv7l",
4242
"CIBW_MUSLLINUX_X86_64_IMAGE": musllinux_image,
4343
"CIBW_MUSLLINUX_I686_IMAGE": musllinux_image,
4444
"CIBW_MUSLLINUX_AARCH64_IMAGE": musllinux_image,
@@ -54,4 +54,5 @@ def test(musllinux_image, tmp_path):
5454
musllinux_versions=[musllinux_image],
5555
single_python=True,
5656
)
57+
expected_wheels = [w for w in expected_wheels if "armv7l" not in w]
5758
assert set(actual_wheels) == set(expected_wheels)

test/test_testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_uname(self):
6868
# See #336 for more info.
6969
bits = struct.calcsize("P") * 8
7070
if bits == 32:
71-
self.assertIn(platform.machine(), ["i686", "wasm32"])
71+
self.assertIn(platform.machine(), ["i686", "armv7l","armv8l", "wasm32"])
7272
'''
7373

7474

0 commit comments

Comments
 (0)