-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Needs TriageIssues that need to be evaluated for severity and status.Issues that need to be evaluated for severity and status.bug
Description
setuptools version
60.9.3
Python version
python 3.9
OS
macOS
Additional environment information
❯ pip list
Package Version
---------- -------
pip 22.0.4
setuptools 60.9.3
wheel 0.37.1
Description
this seems similar to #3102, but issue was closed by #3108, without activity since then, and I still seeing this issue in the latest release.
importing setuptools overrides/removes the behavior and return type of of the standard library importlib.metadata.distribution() function:
Expected behavior
importing setuptools doesn't supersede/remove the distribution finder from standard library importlib
How to Reproduce
- import
setuptools - call
importlib.metadata.distribution()
Output
>>> from importlib import metadata
>>> metadata.distribution('pip') # returns the expected type
<importlib.metadata.PathDistribution object at 0x101665910>
>>> import sys
>>> [getattr(finder, 'find_distributions', None) for finder in sys.meta_path]
[None, None, None, <bound method PathFinder.find_distributions of <class '_frozen_importlib_external.PathFinder'>>]
# importing setuptools changes the type of object returned by metadata.distribution
# and removes the _frozen_importlib_external.PathFinder from
# the list of finders used by `metadata.Distribution.discover`
>>> import setuptools
>>> metadata.distribution('pip')
<setuptools._vendor.importlib_metadata.PathDistribution object at 0x102253070>
>>> [getattr(finder, 'find_distributions', None) for finder in sys.meta_path]
[None, None, None, None, None, None, <bound method MetadataPathFinder.find_distributions of <setuptools._vendor.importlib_metadata.MetadataPathFinder object at 0x101fdad00>>]
# note:
>>> import importlib_metadata
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'importlib_metadata'Metadata
Metadata
Assignees
Labels
Needs TriageIssues that need to be evaluated for severity and status.Issues that need to be evaluated for severity and status.bug