diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2020-08-13 20:26:12 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-13 20:26:12 -0400 |
| commit | 2df5d97f4ea78fa4fe67f49a9f0ab7e48a00dd27 (patch) | |
| tree | f141badf37b9282edd438f8ff6b7e8c7b3eea5d4 /pkg_resources | |
| parent | a7f6ad46b07d51fce91e74b3777d70cbd4168f0f (diff) | |
| parent | 9372bf7d7f63136758196dd86688f00602b7a494 (diff) | |
| download | python-setuptools-git-2df5d97f4ea78fa4fe67f49a9f0ab7e48a00dd27.tar.gz | |
Merge pull request #2153 from pypa/bugfix/2129-better-egg-detection
Stricter egg detection
Diffstat (limited to 'pkg_resources')
| -rw-r--r-- | pkg_resources/__init__.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 5927ef0d..b585e850 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -2056,7 +2056,10 @@ def find_on_path(importer, path_item, only=False): ) return - entries = safe_listdir(path_item) + entries = ( + os.path.join(path_item, child) + for child in safe_listdir(path_item) + ) # for performance, before sorting by version, # screen entries for only those that will yield @@ -2372,7 +2375,15 @@ def _is_egg_path(path): """ Determine if given path appears to be an egg. """ - return path.lower().endswith('.egg') + return _is_zip_egg(path) or _is_unpacked_egg(path) + + +def _is_zip_egg(path): + return ( + path.lower().endswith('.egg') and + os.path.isfile(path) and + zipfile.is_zipfile(path) + ) def _is_unpacked_egg(path): @@ -2380,7 +2391,7 @@ def _is_unpacked_egg(path): Determine if given path appears to be an unpacked egg. """ return ( - _is_egg_path(path) and + path.lower().endswith('.egg') and os.path.isfile(os.path.join(path, 'EGG-INFO', 'PKG-INFO')) ) |
