#1129502 python-cpuinfo: add code to detect Alpha CPUs; needed for other packages

Package:
python-cpuinfo
Source:
python-cpuinfo
Submitter:
Michael Cree
Date:
2026-09-20 07:29:02 UTC
Severity:
normal
Tags:
#1129502#5
Date:
2026-03-02 07:18:43 UTC
From:
To:
python-cpuinfo is missing code to detect Alpha CPUs.  The attached
patch adds such code.

Could you apply the patch soon as dependent packages fail to build
from source without it, for example, pytables, see:
https://buildd.debian.org/status/fetch.php?pkg=pytables&arch=alpha&ver=3.11.0-2&stamp=1772245356&raw=0

Example failure:

ERROR: test00_description (tables.tests.test_tables.CompressBlosc2TablesTestCase.test00_description)
Checking table description and descriptive fields.
[snip irrelevant part of python backtrace]
  File "/build/reproducible-path/pytables-3.11.0/.pybuild/cpython3_3.14/build/tables/leaf.py", line 446, in _calc_chunkshape
    cpu_info = get_cpu_info()
  File "/build/reproducible-path/pytables-3.11.0/.pybuild/cpython3_3.14/build/tables/leaf.py", line 64, in get_cpu_info
    import cpuinfo
  File "/usr/lib/python3/dist-packages/cpuinfo/__init__.py", line 2, in <module>
    from cpuinfo.cpuinfo import *
  File "/usr/lib/python3/dist-packages/cpuinfo/cpuinfo.py", line 2848, in <module>
    _check_arch()
    ~~~~~~~~~~~^^
  File "/usr/lib/python3/dist-packages/cpuinfo/cpuinfo.py", line 371, in _check_arch
    raise Exception("py-cpuinfo currently only works on X86 "
    		"and some ARM/HPPA/LoongArch/MIPS/PPC/RISCV/SPARC/S390X CPUs." )
Exception: py-cpuinfo currently only works on X86 and some ARM/HPPA/LoongArch/MIPS/PPC/RISCV/SPARC/S390X CPUs.

Regards
Michael.

#1129502#10
Date:
2026-09-19 09:54:38 UTC
From:
To:
Hi Michael,

Sorry this sat for six months. I've picked it up and prepared the patch for
upload; a merge request against the team repository is here:

https://salsa.debian.org/python-team/packages/python-cpuinfo/-/merge_requests/2

One thing worth recording for whoever looks at this next: the patch as
attached does not apply to the packaging tree as-is. It was generated against
a tree that already had 0001-python-cpuinfo-hppa-v2.patch applied, so the two
hunks touching the arch list in _check_arch() and the exception message
conflict with the hppa patch. Ordering it after that patch in
debian/patches/series is enough - no changes to the diff itself were needed.

I made three cosmetic changes while rebasing, nothing functional: aligned the
new 'ALPHA' list entry with the surrounding tab indentation, dropped a stray
blank line before "# Various fields", and removed two trailing semicolons on
the hz_actual lines.

With the full stack applied the upstream test suite still passes here: 166
passed, 1 skipped - though that only shows the change doesn't regress other
architectures, since none of those tests exercise the new code.

To check the Alpha paths themselves I mocked DataSource against a
reconstructed Alpha /proc/cpuinfo (built from show_cpuinfo() in
arch/alpha/kernel/setup.c - I have no Alpha hardware here). Before and after,
same input:

                      unpatched                  patched
  _parse_arch()       (None, None)               ('ALPHA', 64)
  _check_arch()       raises                     no exception
  brand_raw           'Alpha'                    'EV6'
  hz_actual           None                       (466337464, 0) = 466.3375 MHz
  hardware_raw        None                       'AlphaServer ES40 6/667'

So the mechanism does what it says, and the " est." suffix on the cycle
frequency line parses fine. The 'cpu model' and 'platform string' overrides
both trigger. What I can't confirm is that my reconstructed fixture matches
what a real machine prints, which brings me to the first ask below.

Two things I could use your help with.

First, a test fixture. Upstream keeps one test file per architecture
(tests/test_linux_aarch64_64.py, tests/test_linux_fedora_5_s390x.py and so
on), and there's no Alpha equivalent yet. Could you send the output of

  cat /proc/cpuinfo

from the machine you tested on, plus

  python3 -c "import cpuinfo, json; print(json.dumps(cpuinfo.get_cpu_info(), indent=2))"

with the patch applied? That would let me write tests/test_linux_alpha.py in
the same shape as the others. The Hz handling in particular deserves a test,
since Alpha is the only architecture reporting "cycle frequency [Hz]" in Hz
rather than MHz and the scale factor change touches every other arch's code
path.

Second, has this been sent upstream? The patch is currently marked
Forwarded: no. Upstream is https://github.com/workhorsy/py-cpuinfo and a
pull request there would spare Debian carrying this indefinitely. Happy to
open it myself with you as the author if you'd rather not.

Note that I can't upload this myself - I'm neither DD nor DM - so it still
needs a sponsor. Emmanuel Arias has the ITA (#1093668); I've pinged him on
the merge request.

Regards,
Malik

#1129502#15
Date:
2026-09-20 01:52:05 UTC
From:
To:
Hi Malik,

Thanks for taking a look at this!

Attached proc-cpuinfo.txt for an Alpha ES45 with 2 cpus.

Attached python-cpuinfo-output.txt with the requested output

No, I hadn't pushed it upstream, partly upstream seemed to be somewhat
dead, but even more so because I don't have a github account.

I'm happy for you to push it upstream if you are happy to do so.

Regards,
Michael.

#1129502#20
Date:
2026-09-20 07:22:23 UTC
From:
To:
Hi Michael,

Thanks. I fed your /proc/cpuinfo to the patched code and every field matches
what your machine reported, so that settles it.

Upstream PR, with you as author on the code commit:

https://github.com/workhorsy/py-cpuinfo/pull/226

You're right that it looks dead, last commit is November 2022, so I wouldn't
expect much. Both patches point Forwarded: at it now either way.

Malik