Closed
Description
This shows up while trying to run the numpy test suite with python 3.11 and the newest pytest etc.
==================================== ERRORS ====================================
________________________ ERROR collecting test session _________________________
[...]
=========================== short test summary info ============================
ERROR - AttributeError: 'PathDistribution' object has no attribute '_normalized_name'
ERROR - AttributeError: 'PathDistribution' object has no attribute '_normalized_name'
2 errors in 1.41s
More precisely, the error appears in the vendored import_lib module
[...]/lib/python3.11/importlib/metadata/__init__.py:472: in load
ordered = sorted(eps, key=by_group)
by_group = operator.attrgetter('group')
cls = <class 'importlib.metadata.SelectableGroups'>
eps = <itertools.chain object at 0x7f19804ea5f0>
[...]/lib/python3.11/importlib/metadata/__init__.py:1013: in <genexpr>
eps = itertools.chain.from_iterable(
.0 = <generator object unique_everseen at 0x7f19805e9d40>
[...]/lib/python3.11/importlib/metadata/_itertools.py:16: in unique_everseen
k = key(element)
E AttributeError: 'PathDistribution' object has no attribute '_normalized_name'
element = <importlib_metadata.PathDistribution object at 0x7f19802c0450>
iterable = <itertools.chain object at 0x7f19804eae00>
key = operator.attrgetter('_normalized_name')
seen = set()
seen_add = <built-in method add of set object at 0x7f198035b060>
Turns out this is python/importlib_metadata#396 (fixed in 4.13.0), where @jaraco noted:
Perhaps importlib_metadata should provide a compatibility shim to honor name normalization in distributions not supplying it (or at least not crash).
Unfortunately, the vendored version present in python 3.11 is only at 4.11.3, hence does not carry the fix.