diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2016-10-16 12:33:09 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-16 12:33:09 -0400 |
| commit | 5273dbaeb96c17f3226f85dc9f28fcfe59f5f314 (patch) | |
| tree | 0a65ef6bb71389dac1228cfd32aa3fc40226b89b /pkg_resources | |
| parent | 48317edf59bc1e1067df6d2a22898a083d4f226a (diff) | |
| parent | e0805ec6a33ff22977723258a99f0184a508bef2 (diff) | |
| download | external_python_setuptools-5273dbaeb96c17f3226f85dc9f28fcfe59f5f314.tar.gz external_python_setuptools-5273dbaeb96c17f3226f85dc9f28fcfe59f5f314.tar.bz2 external_python_setuptools-5273dbaeb96c17f3226f85dc9f28fcfe59f5f314.zip | |
Merge pull request #629 from kata198/master
Fix issues with distribution location from eggs
Diffstat (limited to 'pkg_resources')
| -rw-r--r-- | pkg_resources/__init__.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 1b8d02f5..33b3f56c 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -1983,12 +1983,20 @@ def find_on_path(importer, path_item, only=False): ) else: # scan for .egg and .egg-info in directory - for entry in os.listdir(path_item): + + path_item_entries = os.listdir(path_item) + # Reverse so we find the newest version of a distribution, + path_item_entries.sort() + path_item_entries.reverse() + for entry in path_item_entries: lower = entry.lower() if lower.endswith('.egg-info') or lower.endswith('.dist-info'): fullpath = os.path.join(path_item, entry) if os.path.isdir(fullpath): # egg-info directory, allow getting metadata + if len(os.listdir(fullpath)) == 0: + # Empty egg directory, skip. + continue metadata = PathMetadata(path_item, fullpath) else: metadata = FileMetadata(fullpath) |
