Skip to content

Commit 17e2780

Browse files
authored
ci: build aarch64 wheel on GHA aarch64 runner (#2503)
Signed-off-by: mayeut <[email protected]>
1 parent 1ba8667 commit 17e2780

14 files changed

+28
-60
lines changed

.github/workflows/build.yml

+2-9
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
include:
2828
- {os: ubuntu-latest, arch: x86_64}
2929
- {os: ubuntu-latest, arch: i686}
30-
- {os: ubuntu-latest, arch: aarch64}
30+
- {os: ubuntu-24.04-arm, arch: aarch64}
3131
- {os: macos-13, arch: x86_64}
3232
- {os: macos-14, arch: arm64}
3333
- {os: windows-2019, arch: AMD64}
@@ -48,18 +48,11 @@ jobs:
4848
with:
4949
python-version: 3.11
5050

51-
- name: Set up QEMU
52-
uses: docker/setup-qemu-action@v3
53-
if: matrix.arch == 'aarch64'
54-
5551
- name: Create wheels + run tests
5652
uses: pypa/[email protected]
5753
env:
5854
CIBW_ARCHS: "${{ matrix.arch }}"
59-
CIBW_ENABLE: "cpython-prerelease"
60-
CIBW_TEST_EXTRAS: test
61-
CIBW_TEST_COMMAND:
62-
make -C {project} PYTHON="env python" PSUTIL_SCRIPTS_DIR="{project}/scripts" install-sysdeps install-pydeps-test install print-sysinfo test test-memleaks
55+
CIBW_ENABLE: "${{ startsWith(github.ref, 'refs/tags/') && '' || 'cpython-prerelease' }}"
6356

6457
- name: Upload wheels
6558
uses: actions/upload-artifact@v4

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ syntax: glob
1818
build/
1919
dist/
2020
wheelhouse/
21+
.tests/

Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ test-coverage: ## Run test coverage.
162162
$(PYTHON) -m coverage html
163163
$(PYTHON) -m webbrowser -t htmlcov/index.html
164164

165+
test-ci:
166+
${MAKE} install-sysdeps
167+
mkdir -p .tests
168+
cd .tests/ && $(PYTHON) -c "from psutil.tests import print_sysinfo; print_sysinfo()"
169+
cd .tests/ && $(PYTHON_ENV_VARS) PYTEST_ADDOPTS="-k 'not test_memleaks.py'" $(PYTHON) -m pytest $(PYTEST_ARGS) --pyargs psutil.tests
170+
cd .tests/ && $(PYTHON_ENV_VARS) PYTEST_ADDOPTS="-k 'test_memleaks.py'" $(PYTHON) -m pytest $(PYTEST_ARGS) --pyargs psutil.tests
171+
165172
# ===================================================================
166173
# Linters
167174
# ===================================================================

psutil/tests/__init__.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"HAS_IONICE", "HAS_MEMORY_MAPS", "HAS_PROC_CPU_NUM", "HAS_RLIMIT",
7474
"HAS_SENSORS_BATTERY", "HAS_BATTERY", "HAS_SENSORS_FANS",
7575
"HAS_SENSORS_TEMPERATURES", "HAS_NET_CONNECTIONS_UNIX", "MACOS_11PLUS",
76-
"MACOS_12PLUS", "COVERAGE", 'AARCH64', "QEMU_USER", "PYTEST_PARALLEL",
76+
"MACOS_12PLUS", "COVERAGE", 'AARCH64', "PYTEST_PARALLEL",
7777
# subprocesses
7878
'pyrun', 'terminate', 'reap_children', 'spawn_testproc', 'spawn_zombie',
7979
'spawn_children_pair',
@@ -114,11 +114,6 @@
114114
CI_TESTING = GITHUB_ACTIONS
115115
COVERAGE = 'COVERAGE_RUN' in os.environ
116116
PYTEST_PARALLEL = "PYTEST_XDIST_WORKER" in os.environ # `make test-parallel`
117-
if LINUX and GITHUB_ACTIONS:
118-
with open('/proc/1/cmdline') as f:
119-
QEMU_USER = "/bin/qemu-" in f.read()
120-
else:
121-
QEMU_USER = False
122117
# are we a 64 bit process?
123118
IS_64BIT = sys.maxsize > 2**32
124119
AARCH64 = platform.machine() == "aarch64"

psutil/tests/test_contracts.py

-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from psutil.tests import HAS_NET_IO_COUNTERS
2828
from psutil.tests import HAS_SENSORS_FANS
2929
from psutil.tests import HAS_SENSORS_TEMPERATURES
30-
from psutil.tests import QEMU_USER
3130
from psutil.tests import SKIP_SYSCONS
3231
from psutil.tests import PsutilTestCase
3332
from psutil.tests import create_sockets
@@ -268,7 +267,6 @@ def test_net_if_addrs(self):
268267
assert isinstance(addr.netmask, (str, type(None)))
269268
assert isinstance(addr.broadcast, (str, type(None)))
270269

271-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
272270
def test_net_if_stats(self):
273271
# Duplicate of test_system.py. Keep it anyway.
274272
for ifname, info in psutil.net_if_stats().items():

psutil/tests/test_linux.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import errno
1313
import io
1414
import os
15+
import platform
1516
import re
1617
import shutil
1718
import socket
@@ -32,7 +33,6 @@
3233
from psutil.tests import HAS_RLIMIT
3334
from psutil.tests import PYPY
3435
from psutil.tests import PYTEST_PARALLEL
35-
from psutil.tests import QEMU_USER
3636
from psutil.tests import TOLERANCE_DISK_USAGE
3737
from psutil.tests import TOLERANCE_SYS_MEM
3838
from psutil.tests import PsutilTestCase
@@ -735,6 +735,9 @@ def test_against_lscpu(self):
735735
core_ids.add(fields[1])
736736
assert psutil.cpu_count(logical=False) == len(core_ids)
737737

738+
@pytest.mark.skipif(
739+
platform.machine() not in {"x86_64", "i686"}, reason="x86_64/i686 only"
740+
)
738741
def test_method_2(self):
739742
meth_1 = psutil._pslinux.cpu_count_cores()
740743
with mock.patch('glob.glob', return_value=[]) as m:
@@ -754,6 +757,9 @@ def test_emulate_none(self):
754757
@pytest.mark.skipif(not LINUX, reason="LINUX only")
755758
class TestSystemCPUFrequency(PsutilTestCase):
756759
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
760+
@pytest.mark.skipif(
761+
AARCH64, reason="aarch64 does not always expose frequency"
762+
)
757763
def test_emulate_use_second_file(self):
758764
# https://github.com/giampaolo/psutil/issues/981
759765
def path_exists_mock(path):
@@ -977,7 +983,6 @@ def test_ips(self):
977983

978984

979985
@pytest.mark.skipif(not LINUX, reason="LINUX only")
980-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
981986
class TestSystemNetIfStats(PsutilTestCase):
982987
@pytest.mark.skipif(
983988
not shutil.which("ifconfig"), reason="ifconfig utility not available"
@@ -1546,7 +1551,7 @@ def test_issue_687(self):
15461551
with ThreadTask():
15471552
p = psutil.Process()
15481553
threads = p.threads()
1549-
assert len(threads) == (3 if QEMU_USER else 2)
1554+
assert len(threads) == 2
15501555
tid = sorted(threads, key=lambda x: x.id)[1].id
15511556
assert p.pid != tid
15521557
pt = psutil.Process(tid)
@@ -2227,7 +2232,6 @@ def test_name(self):
22272232
value = self.read_status_file("Name:")
22282233
assert self.proc.name() == value
22292234

2230-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
22312235
def test_status(self):
22322236
value = self.read_status_file("State:")
22332237
value = value[value.find('(') + 1 : value.rfind(')')]

psutil/tests/test_memleaks.py

-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
from psutil.tests import HAS_SENSORS_BATTERY
4040
from psutil.tests import HAS_SENSORS_FANS
4141
from psutil.tests import HAS_SENSORS_TEMPERATURES
42-
from psutil.tests import QEMU_USER
4342
from psutil.tests import TestMemoryLeak
4443
from psutil.tests import create_sockets
4544
from psutil.tests import get_testfn
@@ -396,7 +395,6 @@ def test_disk_usage(self):
396395
times = FEW_TIMES if POSIX else self.times
397396
self.execute(lambda: psutil.disk_usage('.'), times=times)
398397

399-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
400398
def test_disk_partitions(self):
401399
self.execute(psutil.disk_partitions)
402400

@@ -434,7 +432,6 @@ def test_net_if_addrs(self):
434432
tolerance = 80 * 1024 if WINDOWS else self.tolerance
435433
self.execute(psutil.net_if_addrs, tolerance=tolerance)
436434

437-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
438435
def test_net_if_stats(self):
439436
self.execute(psutil.net_if_stats)
440437

psutil/tests/test_misc.py

-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from psutil._common import supports_ipv6
3030
from psutil._common import wrap_numbers
3131
from psutil.tests import HAS_NET_IO_COUNTERS
32-
from psutil.tests import QEMU_USER
3332
from psutil.tests import PsutilTestCase
3433
from psutil.tests import process_namespace
3534
from psutil.tests import pytest
@@ -269,9 +268,6 @@ def check(ret):
269268
for fun, name in ns.iter(ns.getters):
270269
if name in {"win_service_iter", "win_service_get"}:
271270
continue
272-
if QEMU_USER and name == "net_if_stats":
273-
# OSError: [Errno 38] ioctl(SIOCETHTOOL) not implemented
274-
continue
275271
with self.subTest(name=name):
276272
try:
277273
ret = fun()

psutil/tests/test_posix.py

-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from psutil.tests import AARCH64
2727
from psutil.tests import HAS_NET_IO_COUNTERS
2828
from psutil.tests import PYTHON_EXE
29-
from psutil.tests import QEMU_USER
3029
from psutil.tests import PsutilTestCase
3130
from psutil.tests import pytest
3231
from psutil.tests import retry_on_failure
@@ -103,9 +102,6 @@ def ps_name(pid):
103102
if SUNOS:
104103
field = "comm"
105104
command = ps(field, pid).split()
106-
if QEMU_USER:
107-
assert "/bin/qemu-" in command[0]
108-
return command[1]
109105
return command[0]
110106

111107

psutil/tests/test_process.py

+1-16
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
from psutil.tests import PYPY
5050
from psutil.tests import PYTHON_EXE
5151
from psutil.tests import PYTHON_EXE_ENV
52-
from psutil.tests import QEMU_USER
5352
from psutil.tests import PsutilTestCase
5453
from psutil.tests import ThreadTask
5554
from psutil.tests import call_until
@@ -257,7 +256,6 @@ def test_cpu_percent_numcpus_none(self):
257256
psutil.Process().cpu_percent()
258257
assert m.called
259258

260-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
261259
def test_cpu_times(self):
262260
times = psutil.Process().cpu_times()
263261
assert times.user >= 0.0, times
@@ -270,7 +268,6 @@ def test_cpu_times(self):
270268
for name in times._fields:
271269
time.strftime("%H:%M:%S", time.localtime(getattr(times, name)))
272270

273-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
274271
def test_cpu_times_2(self):
275272
user_time, kernel_time = psutil.Process().cpu_times()[:2]
276273
utime, ktime = os.times()[:2]
@@ -642,8 +639,6 @@ def test_memory_maps(self):
642639
continue
643640
if BSD and nt.path == "pvclock":
644641
continue
645-
if QEMU_USER and "/bin/qemu-" in nt.path:
646-
continue
647642
assert os.path.isabs(nt.path), nt.path
648643

649644
if POSIX:
@@ -710,7 +705,6 @@ def test_is_running(self):
710705
assert not p.is_running()
711706
assert not p.is_running()
712707

713-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
714708
def test_exe(self):
715709
p = self.spawn_psproc()
716710
exe = p.exe()
@@ -763,9 +757,6 @@ def test_cmdline(self):
763757
if pyexe != PYTHON_EXE:
764758
assert ' '.join(p.cmdline()[1:]) == ' '.join(cmdline[1:])
765759
return
766-
if QEMU_USER:
767-
assert ' '.join(p.cmdline()[2:]) == ' '.join(cmdline)
768-
return
769760
assert ' '.join(p.cmdline()) == ' '.join(cmdline)
770761

771762
@pytest.mark.skipif(PYPY, reason="broken on PYPY")
@@ -783,8 +774,6 @@ def test_long_cmdline(self):
783774
assert p.cmdline() == cmdline
784775
except psutil.ZombieProcess:
785776
raise pytest.skip("OPENBSD: process turned into zombie")
786-
elif QEMU_USER:
787-
assert p.cmdline()[2:] == cmdline
788777
else:
789778
ret = p.cmdline()
790779
if NETBSD and ret == []:
@@ -798,8 +787,7 @@ def test_name(self):
798787
pyexe = os.path.basename(os.path.realpath(sys.executable)).lower()
799788
assert pyexe.startswith(name), (pyexe, name)
800789

801-
@pytest.mark.skipif(PYPY or QEMU_USER, reason="unreliable on PYPY")
802-
@pytest.mark.skipif(QEMU_USER, reason="unreliable on QEMU user")
790+
@pytest.mark.skipif(PYPY, reason="unreliable on PYPY")
803791
def test_long_name(self):
804792
pyexe = create_py_exe(self.get_testfn(suffix=string.digits * 2))
805793
cmdline = [
@@ -830,7 +818,6 @@ def test_long_name(self):
830818
# @pytest.mark.skipif(SUNOS, reason="broken on SUNOS")
831819
# @pytest.mark.skipif(AIX, reason="broken on AIX")
832820
# @pytest.mark.skipif(PYPY, reason="broken on PYPY")
833-
# @pytest.mark.skipif(QEMU_USER, reason="broken on QEMU user")
834821
# def test_prog_w_funky_name(self):
835822
# # Test that name(), exe() and cmdline() correctly handle programs
836823
# # with funky chars such as spaces and ")", see:
@@ -938,7 +925,6 @@ def cleanup(init):
938925
except psutil.AccessDenied:
939926
pass
940927

941-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
942928
def test_status(self):
943929
p = psutil.Process()
944930
assert p.status() == psutil.STATUS_RUNNING
@@ -1166,7 +1152,6 @@ def test_parent_multi(self):
11661152
assert grandchild.parent() == child
11671153
assert child.parent() == parent
11681154

1169-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
11701155
@retry_on_failure()
11711156
def test_parents(self):
11721157
parent = psutil.Process()

psutil/tests/test_process_all.py

-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from psutil import WINDOWS
3030
from psutil.tests import CI_TESTING
3131
from psutil.tests import PYTEST_PARALLEL
32-
from psutil.tests import QEMU_USER
3332
from psutil.tests import VALID_PROC_STATUSES
3433
from psutil.tests import PsutilTestCase
3534
from psutil.tests import check_connection_ntuple
@@ -232,9 +231,6 @@ def username(self, ret, info):
232231
def status(self, ret, info):
233232
assert isinstance(ret, str)
234233
assert ret, ret
235-
if QEMU_USER:
236-
# status does not work under qemu user
237-
return
238234
assert ret != '?' # XXX
239235
assert ret in VALID_PROC_STATUSES
240236

psutil/tests/test_scripts.py

-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from psutil.tests import HAS_SENSORS_TEMPERATURES
2525
from psutil.tests import PYTHON_EXE
2626
from psutil.tests import PYTHON_EXE_ENV
27-
from psutil.tests import QEMU_USER
2827
from psutil.tests import ROOT_DIR
2928
from psutil.tests import SCRIPTS_DIR
3029
from psutil.tests import PsutilTestCase
@@ -117,7 +116,6 @@ def test_pstree(self):
117116
def test_netstat(self):
118117
self.assert_stdout('netstat.py')
119118

120-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
121119
def test_ifconfig(self):
122120
self.assert_stdout('ifconfig.py')
123121

psutil/tests/test_system.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from psutil import SUNOS
3232
from psutil import WINDOWS
3333
from psutil._common import broadcast_addr
34+
from psutil.tests import AARCH64
3435
from psutil.tests import ASCII_FS
3536
from psutil.tests import CI_TESTING
3637
from psutil.tests import GITHUB_ACTIONS
@@ -45,7 +46,6 @@
4546
from psutil.tests import IS_64BIT
4647
from psutil.tests import MACOS_12PLUS
4748
from psutil.tests import PYPY
48-
from psutil.tests import QEMU_USER
4949
from psutil.tests import UNICODE_SUFFIX
5050
from psutil.tests import PsutilTestCase
5151
from psutil.tests import check_net_address
@@ -598,8 +598,10 @@ def check_ls(ls):
598598
assert value >= 0
599599

600600
ls = psutil.cpu_freq(percpu=True)
601-
if FREEBSD and not ls:
602-
raise pytest.skip("returns empty list on FreeBSD")
601+
if (FREEBSD or AARCH64) and not ls:
602+
raise pytest.skip(
603+
"returns empty list on FreeBSD and Linux aarch64"
604+
)
603605

604606
assert ls, ls
605607
check_ls([psutil.cpu_freq(percpu=False)])
@@ -800,7 +802,6 @@ def test_net_io_counters_no_nics(self):
800802
assert psutil.net_io_counters(pernic=True) == {}
801803
assert m.called
802804

803-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
804805
def test_net_if_addrs(self):
805806
nics = psutil.net_if_addrs()
806807
assert nics, nics
@@ -893,7 +894,6 @@ def test_net_if_addrs_mac_null_bytes(self):
893894
else:
894895
assert addr.address == '06-3d-29-00-00-00'
895896

896-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
897897
def test_net_if_stats(self):
898898
nics = psutil.net_if_stats()
899899
assert nics, nics

pyproject.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,11 @@ trailing_comma_inline_array = true
221221
skip = [
222222
"*-musllinux*",
223223
"cp313-win*", # pywin32 is not available on cp313 yet
224-
"cp3{7,8,9,10,11,12}-*linux_{aarch64,ppc64le,s390x}", # Only test cp36/cp313 on qemu tested architectures
224+
"cp3{7,8,9,10,11,12}-*linux_{ppc64le,s390x}", # Only test cp36/cp313 on qemu tested architectures
225225
"pp*",
226226
]
227+
test-extras = ["test"]
228+
test-command = "make -C {project} PYTHON=python PSUTIL_SCRIPTS_DIR=\"{project}/scripts\" test-ci"
227229

228230
[tool.cibuildwheel.macos]
229231
archs = ["arm64", "x86_64"]

0 commit comments

Comments
 (0)