Skip to content

numpy/testing/_private/utils.py causes ValueError: invalid literal for int() with base 10: ''  #24074

@sodul

Description

@sodul

Describe the issue:

We have some test code that ends up loading numpy/testing/_private/utils.py. Up until v1.24.4 everything works fine but with v1.25.0 we get a value error apparently when the packaging information is fetched. Oddly we could not reproduce when calling list(sys_tags()) from the REPL.

Reproduce the code example:

In `numpy/testing/_private/utils.py`


    from packaging.tags import sys_tags
    _tags = list(sys_tags())

Error message:

File "/Users/stephane/.pyenv/versions/3.11.4/lib/python3.11/site-packages/numpy/__init__.py", line 316, in __getattr__
    import numpy.testing as testing
  File "/Users/stephane/.pyenv/versions/3.11.4/lib/python3.11/site-packages/numpy/testing/__init__.py", line 11, in <module>
    from ._private.utils import *
  File "/Users/stephane/.pyenv/versions/3.11.4/lib/python3.11/site-packages/numpy/testing/_private/utils.py", line 64, in <module>
    _tags = list(sys_tags())
            ^^^^^^^^^^^^^^^^
  File "/Users/stephane/.pyenv/versions/3.11.4/lib/python3.11/site-packages/packaging/tags.py", line 536, in sys_tags
    yield from cpython_tags(warn=warn)
  File "/Users/stephane/.pyenv/versions/3.11.4/lib/python3.11/site-packages/packaging/tags.py", line 211, in cpython_tags
    platforms = list(platforms or platform_tags())
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/stephane/.pyenv/versions/3.11.4/lib/python3.11/site-packages/packaging/tags.py", line 395, in mac_platforms
    version = cast("MacVersion", tuple(map(int, version_str.split(".")[:2])))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''

Runtime information:

>>> import sys, numpy; print(numpy.__version__); print(sys.version)
1.25.0
3.11.4 (main, Jun 27 2023, 17:18:33) [Clang 14.0.3 (clang-1403.0.22.14.1)]
>>> print(numpy.show_runtime())
WARNING: `threadpoolctl` not found in system! Install it by `pip install threadpoolctl`. Once installed, try `np.show_runtime` again for more detailed build information
[{'numpy_version': '1.25.0',
  'python': '3.11.4 (main, Jun 27 2023, 17:18:33) [Clang 14.0.3 '
            '(clang-1403.0.22.14.1)]',
  'uname': uname_result(system='Darwin', node='ip-192-168-0-32.us-west-2.compute.internal', release='22.5.0', version='Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000', machine='arm64')},
 {'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
                      'found': ['ASIMDHP', 'ASIMDDP'],
                      'not_found': ['ASIMDFHM']}}]
None

Context for the issue:

No response

Edit: (mattip) formatting

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions