Skip to content

Commit

Permalink
feat: add linux aarch64 wheel
Browse files Browse the repository at this point in the history
Signed-off-by: mayeut <[email protected]>
  • Loading branch information
mayeut committed Jun 25, 2022
1 parent 437f9fa commit 997ab3c
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 14 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# * Linux
# * macOS
# * Windows (disabled)
# * Windows
# * FreeBSD
#
# To skip certain builds see:
Expand All @@ -20,15 +20,19 @@
on: [push, pull_request]
name: build
jobs:
# Linux + macOS + Windows Python 3.6+
py3:
name: ${{ matrix.os }}-py36-plus
# Linux + macOS + Windows CPython 3.6+
cp36:
name: cp36+, ${{ matrix.os }}, ${{ matrix.archs }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11, windows-2019]
include:
- {os: macos-11, archs: "x86_64 universal2"}
- {os: ubuntu-20.04, archs: "x86_64 i686"}
- {os: ubuntu-20.04, archs: "aarch64"}
- {os: windows-2019, archs: "AMD64 x86"}

steps:
- name: Cancel previous runs
Expand All @@ -43,10 +47,16 @@ jobs:
cache: pip
cache-dependency-path: .github/workflows/build.yml

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
if: matrix.archs == 'aarch64'

- name: Run tests
uses: pypa/[email protected]
with:
config-file: "./cibuildwheel.toml"
env:
CIBW_ARCHS: ${{ matrix.archs }}

- name: Create wheels
uses: actions/upload-artifact@v3
Expand All @@ -65,9 +75,9 @@ jobs:
# Windows cp37+ tests
# psutil tests do not like running from a virtualenv with python>=3.7 so
# not using cibuildwheel for those. run them "manually" with this job.
windows-py3-test:
name: windows-py3-test-${{ matrix.python }}-${{ matrix.architecture }}
needs: py3
windows-cp3-test:
name: windows tests ${{ matrix.python }} ${{ matrix.architecture }}
needs: cp36
runs-on: windows-2019
timeout-minutes: 20
strategy:
Expand Down Expand Up @@ -105,9 +115,9 @@ jobs:
python ../psutil/tests/test_memleaks.py
shell: bash

# Linux + macOS + Python 2.7 & 3.5
linux-macos-py2:
name: ${{ matrix.os }}-py27-py35
# Linux + macOS + CPython 2.7 & 3.5
linux-macos-cp27-cp35:
name: cp27/cp35, ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
Expand Down
2 changes: 2 additions & 0 deletions psutil/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"HAS_IONICE", "HAS_MEMORY_MAPS", "HAS_PROC_CPU_NUM", "HAS_RLIMIT",
"HAS_SENSORS_BATTERY", "HAS_BATTERY", "HAS_SENSORS_FANS",
"HAS_SENSORS_TEMPERATURES", "HAS_MEMORY_FULL_INFO", "MACOS_11PLUS",
"QEMU_USER",
# subprocesses
'pyrun', 'terminate', 'reap_children', 'spawn_testproc', 'spawn_zombie',
'spawn_children_pair',
Expand Down Expand Up @@ -125,6 +126,7 @@
APPVEYOR = 'APPVEYOR' in os.environ
GITHUB_ACTIONS = 'GITHUB_ACTIONS' in os.environ or 'CIBUILDWHEEL' in os.environ
CI_TESTING = APPVEYOR or GITHUB_ACTIONS
QEMU_USER = LINUX and GITHUB_ACTIONS and platform.machine() == 'aarch64'
# are we a 64 bit process?
IS_64BIT = sys.maxsize > 2 ** 32
if MACOS:
Expand Down
5 changes: 5 additions & 0 deletions psutil/tests/test_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from psutil.tests import HAS_SENSORS_FANS
from psutil.tests import HAS_SENSORS_TEMPERATURES
from psutil.tests import PYPY
from psutil.tests import QEMU_USER
from psutil.tests import SKIP_SYSCONS
from psutil.tests import VALID_PROC_STATUSES
from psutil.tests import PsutilTestCase
Expand Down Expand Up @@ -277,6 +278,7 @@ def test_net_if_addrs(self):
self.assertIsInstance(addr.netmask, (str, type(None)))
self.assertIsInstance(addr.broadcast, (str, type(None)))

@unittest.skipIf(QEMU_USER, 'QEMU user not supported')
def test_net_if_stats(self):
# Duplicate of test_system.py. Keep it anyway.
for ifname, info in psutil.net_if_stats().items():
Expand Down Expand Up @@ -424,6 +426,9 @@ def test_all(self):
failures = []
for info in self.iter_proc_info():
for name, value in info.items():
if QEMU_USER and name == 'status':
# @unittest.skipIf(QEMU_USER, "QEMU user not supported")
continue
meth = getattr(self, name)
try:
meth(value, info)
Expand Down
5 changes: 4 additions & 1 deletion psutil/tests/test_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from psutil.tests import HAS_GETLOADAVG
from psutil.tests import HAS_RLIMIT
from psutil.tests import PYPY
from psutil.tests import QEMU_USER
from psutil.tests import TOLERANCE_DISK_USAGE
from psutil.tests import TOLERANCE_SYS_MEM
from psutil.tests import PsutilTestCase
Expand Down Expand Up @@ -974,6 +975,7 @@ def test_ips(self):


@unittest.skipIf(not LINUX, "LINUX only")
@unittest.skipIf(QEMU_USER, "QEMU user not supported")
class TestSystemNetIfStats(PsutilTestCase):

def test_against_ifconfig(self):
Expand Down Expand Up @@ -1505,7 +1507,7 @@ def test_issue_687(self):
with ThreadTask():
p = psutil.Process()
threads = p.threads()
self.assertEqual(len(threads), 2)
self.assertEqual(len(threads), 3 if QEMU_USER else 2)
tid = sorted(threads, key=lambda x: x.id)[1].id
self.assertNotEqual(p.pid, tid)
pt = psutil.Process(tid)
Expand Down Expand Up @@ -2187,6 +2189,7 @@ def test_name(self):
value = self.read_status_file("Name:")
self.assertEqual(self.proc.name(), value)

@unittest.skipIf(QEMU_USER, "QEMU user not supported")
def test_status(self):
value = self.read_status_file("State:")
value = value[value.find('(') + 1:value.rfind(')')]
Expand Down
3 changes: 3 additions & 0 deletions psutil/tests/test_memleaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from psutil.tests import HAS_SENSORS_BATTERY
from psutil.tests import HAS_SENSORS_FANS
from psutil.tests import HAS_SENSORS_TEMPERATURES
from psutil.tests import QEMU_USER
from psutil.tests import TestMemoryLeak
from psutil.tests import create_sockets
from psutil.tests import get_testfn
Expand Down Expand Up @@ -393,6 +394,7 @@ def test_disk_usage(self):
times = FEW_TIMES if POSIX else self.times
self.execute(lambda: psutil.disk_usage('.'), times=times)

@unittest.skipIf(QEMU_USER, "QEMU user not supported")
def test_disk_partitions(self):
self.execute(psutil.disk_partitions)

Expand Down Expand Up @@ -428,6 +430,7 @@ def test_net_if_addrs(self):
tolerance = 80 * 1024 if WINDOWS else self.tolerance
self.execute(psutil.net_if_addrs, tolerance=tolerance)

@unittest.skipIf(QEMU_USER, "QEMU user not supported")
def test_net_if_stats(self):
self.execute(psutil.net_if_stats)

Expand Down
7 changes: 6 additions & 1 deletion psutil/tests/test_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from psutil.tests import CI_TESTING
from psutil.tests import HAS_NET_IO_COUNTERS
from psutil.tests import PYTHON_EXE
from psutil.tests import QEMU_USER
from psutil.tests import PsutilTestCase
from psutil.tests import mock
from psutil.tests import retry_on_failure
Expand Down Expand Up @@ -107,7 +108,11 @@ def ps_name(pid):
field = "command"
if SUNOS:
field = "comm"
return ps(field, pid).split()[0]
command = ps(field, pid).split()
if QEMU_USER:
assert "/bin/qemu-" in command[0]
return command[1]
return command[0]


def ps_args(pid):
Expand Down
18 changes: 17 additions & 1 deletion psutil/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
from psutil.tests import MACOS_11PLUS
from psutil.tests import PYPY
from psutil.tests import PYTHON_EXE
from psutil.tests import QEMU_USER
from psutil.tests import PsutilTestCase
from psutil.tests import ThreadTask
from psutil.tests import call_until
Expand Down Expand Up @@ -243,6 +244,7 @@ def test_cpu_percent_numcpus_none(self):
psutil.Process().cpu_percent()
assert m.called

@unittest.skipIf(QEMU_USER, "QEMU user not supported")
def test_cpu_times(self):
times = psutil.Process().cpu_times()
assert (times.user > 0.0) or (times.system > 0.0), times
Expand All @@ -254,6 +256,7 @@ def test_cpu_times(self):
for name in times._fields:
time.strftime("%H:%M:%S", time.localtime(getattr(times, name)))

@unittest.skipIf(QEMU_USER, "QEMU user not supported")
def test_cpu_times_2(self):
user_time, kernel_time = psutil.Process().cpu_times()[:2]
utime, ktime = os.times()[:2]
Expand Down Expand Up @@ -616,6 +619,8 @@ def test_memory_maps(self):

for nt in maps:
if not nt.path.startswith('['):
if QEMU_USER and "/bin/qemu-" in nt.path:
continue
assert os.path.isabs(nt.path), nt.path
if POSIX:
try:
Expand Down Expand Up @@ -679,6 +684,7 @@ def test_is_running(self):
assert not p.is_running()
assert not p.is_running()

@unittest.skipIf(QEMU_USER, "QEMU user not supported")
def test_exe(self):
p = self.spawn_psproc()
exe = p.exe()
Expand Down Expand Up @@ -724,6 +730,9 @@ def test_cmdline(self):
self.assertEqual(' '.join(p.cmdline()[1:]),
' '.join(cmdline[1:]))
return
if QEMU_USER:
self.assertEqual(' '.join(p.cmdline()[2:]), ' '.join(cmdline))
return
self.assertEqual(' '.join(p.cmdline()), ' '.join(cmdline))

@unittest.skipIf(PYPY, "broken on PYPY")
Expand All @@ -732,6 +741,9 @@ def test_long_cmdline(self):
create_exe(testfn)
cmdline = [testfn] + (["0123456789"] * 20)
p = self.spawn_psproc(cmdline)
if QEMU_USER:
self.assertEqual(p.cmdline()[2:], cmdline)
return
self.assertEqual(p.cmdline(), cmdline)

def test_name(self):
Expand All @@ -740,7 +752,8 @@ def test_name(self):
pyexe = os.path.basename(os.path.realpath(sys.executable)).lower()
assert pyexe.startswith(name), (pyexe, name)

@unittest.skipIf(PYPY, "unreliable on PYPY")
@unittest.skipIf(PYPY or QEMU_USER, "unreliable on PYPY")
@unittest.skipIf(QEMU_USER, "unreliable on QEMU user")
def test_long_name(self):
testfn = self.get_testfn(suffix="0123456789" * 2)
create_exe(testfn)
Expand All @@ -751,6 +764,7 @@ def test_long_name(self):
@unittest.skipIf(SUNOS, "broken on SUNOS")
@unittest.skipIf(AIX, "broken on AIX")
@unittest.skipIf(PYPY, "broken on PYPY")
@unittest.skipIf(QEMU_USER, "broken on QEMU user")
def test_prog_w_funky_name(self):
# Test that name(), exe() and cmdline() correctly handle programs
# with funky chars such as spaces and ")", see:
Expand Down Expand Up @@ -848,6 +862,7 @@ def test_nice(self):
except psutil.AccessDenied:
pass

@unittest.skipIf(QEMU_USER, "QEMU user not supported")
def test_status(self):
p = psutil.Process()
self.assertEqual(p.status(), psutil.STATUS_RUNNING)
Expand Down Expand Up @@ -1073,6 +1088,7 @@ def test_parent_disappeared(self):
side_effect=psutil.NoSuchProcess(0, 'foo')):
self.assertIsNone(p.parent())

@unittest.skipIf(QEMU_USER, "QEMU user not supported")
@retry_on_failure()
def test_parents(self):
parent = psutil.Process()
Expand Down
3 changes: 3 additions & 0 deletions psutil/tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from psutil.tests import HAS_SENSORS_TEMPERATURES
from psutil.tests import IS_64BIT
from psutil.tests import PYPY
from psutil.tests import QEMU_USER
from psutil.tests import UNICODE_SUFFIX
from psutil.tests import PsutilTestCase
from psutil.tests import check_net_address
Expand Down Expand Up @@ -723,6 +724,7 @@ def test_net_io_counters_no_nics(self):
self.assertEqual(psutil.net_io_counters(pernic=True), {})
assert m.called

@unittest.skipIf(QEMU_USER, 'QEMU user not supported')
def test_net_if_addrs(self):
nics = psutil.net_if_addrs()
assert nics, nics
Expand Down Expand Up @@ -800,6 +802,7 @@ def test_net_if_addrs_mac_null_bytes(self):
else:
self.assertEqual(addr.address, '06-3d-29-00-00-00')

@unittest.skipIf(QEMU_USER, 'QEMU user not supported')
def test_net_if_stats(self):
nics = psutil.net_if_stats()
assert nics, nics
Expand Down

0 comments on commit 997ab3c

Please sign in to comment.