Skip to content

Commit

Permalink
Prevent vendored importlib_metadata from loading distributions from o…
Browse files Browse the repository at this point in the history
…lder importlib_metadata. Fixes #3102.
  • Loading branch information
jaraco committed Feb 15, 2022
1 parent abbaacc commit ee416a2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions setuptools/_importlib.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
import sys


def disable_importlib_metadata_finder(metadata):
"""
Ensure importlib_metadata doesn't provide older, incompatible
Distributions.
Workaround for #3102.
"""
import importlib_metadata
if importlib_metadata is metadata:
return
to_remove = [
ob
for ob in sys.meta_path
if isinstance(ob, importlib_metadata.MetadataPathFinder)
]
for item in to_remove:
sys.meta_path.remove(item)


if sys.version_info < (3, 10):
from setuptools.extern import importlib_metadata as metadata
disable_importlib_metadata_finder(metadata)
else:
import importlib.metadata as metadata # noqa: F401

Expand Down

0 comments on commit ee416a2

Please sign in to comment.