aboutsummaryrefslogtreecommitdiffstats
path: root/pkg_resources/__init__.py
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2020-04-24 22:34:10 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2020-04-24 22:39:54 +0700
commitd11428b1cc059ff6aa0ddec0bd8354a1df68d752 (patch)
treee5d7a2d4b3c09934f749f6cea8336513a177507b /pkg_resources/__init__.py
parent92ca9eab30e1aececf4243d9a928cfe63f7dcfc9 (diff)
downloadexternal_python_setuptools-d11428b1cc059ff6aa0ddec0bd8354a1df68d752.tar.gz
external_python_setuptools-d11428b1cc059ff6aa0ddec0bd8354a1df68d752.tar.bz2
external_python_setuptools-d11428b1cc059ff6aa0ddec0bd8354a1df68d752.zip
Stop recognizing files ending with .dist-info as dist
As proposed in PEP 376, dist-info distributions must be directories.
Diffstat (limited to 'pkg_resources/__init__.py')
-rw-r--r--pkg_resources/__init__.py30
1 files changed, 14 insertions, 16 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index 15a4401a..4d15086f 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -2056,33 +2056,31 @@ def find_on_path(importer, path_item, only=False):
filtered = (
entry
for entry in entries
- if dist_factory(path_item, entry, only)
+ if dist_factory(entry, only)
)
# scan for .egg and .egg-info in directory
path_item_entries = _by_version_descending(filtered)
for entry in path_item_entries:
fullpath = os.path.join(path_item, entry)
- factory = dist_factory(path_item, entry, only)
+ factory = dist_factory(entry, only)
for dist in factory(fullpath):
yield dist
-def dist_factory(path_item, entry, only):
- """
- Return a dist_factory for a path_item and entry
- """
+def dist_factory(entry, only):
+ """Return a dist_factory for the given entry."""
lower = entry.lower()
- is_meta = any(map(lower.endswith, ('.egg-info', '.dist-info')))
- return (
- distributions_from_metadata
- if is_meta else
- find_distributions
- if not only and _is_egg_path(entry) else
- resolve_egg_link
- if not only and lower.endswith('.egg-link') else
- NoDists()
- )
+ if lower.endswith('.egg-info'):
+ return distributions_from_metadata
+ elif lower.endswith('.dist-info') and os.path.isdir(entry):
+ return distributions_from_metadata
+ elif not only and _is_egg_path(entry):
+ return find_distributions
+ elif not only and lower.endswith('.egg-link'):
+ return resolve_egg_link
+ else:
+ return NoDists()
class NoDists: