Skip to content

Fix recognition of PowerPC in cpuinfo.pyΒ #217

@barracuda156

Description

@barracuda156

In your bug report please include:

  • CPU architecture: PowerPC
  • Operating System: macOS
  • Python version: 3.11.10
  • Version of py-cpuinfo: 9.0.0

cpuinfo omits PPC/PPC_32 in the list which breaks dependents:

--->  Building py311-tables
Executing:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_python_py-tables/py311-tables/work/tables-3.9.2" && /opt/local/Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11 -m build --no-isolation --wheel --outdir /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_python_py-tables/py311-tables/work 
* Getting build dependencies for wheel...
cpuinfo failed, assuming no CPU features: py-cpuinfo currently only works on X86 and some ARM/PPC/S390X/MIPS/RISCV CPUs.
* Using Python 3.11.10 (main, Sep  7 2024, 10:26:54) [GCC 14.2.0]
* Found cython 3.0.11
* USE_PKGCONFIG: True
* Found HDF5 headers at ``/opt/local/include``, library at ``/opt/local/lib``.
.. WARNING:: Could not find the HDF5 runtime.
   The HDF5 shared library was *not* found in the default library
   paths. In case of runtime problems, please remember to install it.
* Found LZO 2 headers at ``/opt/local/include``, library at ``/opt/local/lib``.
.. WARNING:: Could not find the LZO 2 runtime.
   The LZO 2 shared library was *not* found in the default library
   paths. In case of runtime problems, please remember to install it.
* Skipping detection of LZO 1 since LZO 2 has already been found.
* Found bzip2 headers at ``/opt/local/include``, library at ``/opt/local/lib``.
* pkg-config library dirs for blosc: /opt/local/lib
* Found blosc headers at ``/opt/local/include``, library at ``/opt/local/lib``.
.. WARNING:: Could not find the blosc runtime.
   The blosc shared library was *not* found in the default library
   paths. In case of runtime problems, please remember to install it.
* pkg-config library dirs for blosc2: /opt/local/lib
* Run 'blosc2_find_directories_hook'
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
    main()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in main
    json_out["return_val"] = hook(**hook_input["kwargs"])
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
    return hook(config_settings)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=[])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/setuptools/build_meta.py", line 303, in _get_build_requires
    self.run_setup()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/setuptools/build_meta.py", line 319, in run_setup
    exec(code, locals())
  File "<string>", line 817, in <module>
  File "<string>", line 455, in find_directories
  File "<string>", line 146, in blosc2_find_directories_hook
  File "<string>", line 101, in get_blosc2_directories
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/blosc2/__init__.py", line 15, in <module>
    import cpuinfo
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/cpuinfo/__init__.py", line 3, in <module>
    from cpuinfo.cpuinfo import *
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/cpuinfo/cpuinfo.py", line 2827, in <module>
    _check_arch()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/cpuinfo/cpuinfo.py", line 366, in _check_arch
    raise Exception("py-cpuinfo currently only works on X86 "
Exception: py-cpuinfo currently only works on X86 and some ARM/PPC/S390X/MIPS/RISCV CPUs.

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_wheel
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_python_py-tables/py311-tables/work/tables-3.9.2" && /opt/local/Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11 -m build --no-isolation --wheel --outdir /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_python_py-tables/py311-tables/work 
Exit code: 1

In fact the arch is present just below in cpuinfo.py:

	# PPC
	elif re.match(r'^ppc32$|^prep$|^pmac$|^powermac$', arch_string_raw):
		arch = 'PPC_32'
		bits = 32

But it is broken by an earlier chunk:

# Make sure we are running on a supported system
def _check_arch():
	arch, bits = _parse_arch(DataSource.arch_string_raw)
	if not arch in ['X86_32', 'X86_64', 'ARM_7', 'ARM_8',
	               'PPC_64', 'S390X', 'MIPS_32', 'MIPS_64',
				   "RISCV_32", "RISCV_64"]:
		raise Exception("py-cpuinfo currently only works on X86 "
		                "and some ARM/PPC/S390X/MIPS/RISCV CPUs.")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions