summaryrefslogtreecommitdiff
path: root/pkg_resources
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-01-16 18:47:33 -0500
committerGitHub <noreply@github.com>2021-01-16 18:47:33 -0500
commit886dd34d565f3911819d4c16c6f16fe3cd65a39d (patch)
tree07e9068e1fe8d00f6988a6395ec419b9efb08ebc /pkg_resources
parentaef3393748c7804937fab87d5754ca434fa37f9b (diff)
parentb31105bdc855d75fc4f9fc7cfe005a81e7cc2f38 (diff)
downloadpython-setuptools-git-886dd34d565f3911819d4c16c6f16fe3cd65a39d.tar.gz
Merge pull request #2490 from thatch/main
Fix .egg-info metadata support for zipimport
Diffstat (limited to 'pkg_resources')
-rw-r--r--pkg_resources/__init__.py3
-rw-r--r--pkg_resources/tests/data/my-test-package-zip/my-test-package.zipbin0 -> 1809 bytes
-rw-r--r--pkg_resources/tests/test_find_distributions.py9
3 files changed, 11 insertions, 1 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index b58f2937..73f85459 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -1981,12 +1981,13 @@ def find_eggs_in_zip(importer, path_item, only=False):
# don't yield nested distros
return
for subitem in metadata.resource_listdir(''):
+ lower = subitem.lower()
if _is_egg_path(subitem):
subpath = os.path.join(path_item, subitem)
dists = find_eggs_in_zip(zipimport.zipimporter(subpath), subpath)
for dist in dists:
yield dist
- elif subitem.lower().endswith('.dist-info'):
+ elif subitem.lower().endswith(('.dist-info', '.egg-info')):
subpath = os.path.join(path_item, subitem)
submeta = EggMetadata(zipimport.zipimporter(subpath))
submeta.egg_info = subpath
diff --git a/pkg_resources/tests/data/my-test-package-zip/my-test-package.zip b/pkg_resources/tests/data/my-test-package-zip/my-test-package.zip
new file mode 100644
index 00000000..81f9a017
--- /dev/null
+++ b/pkg_resources/tests/data/my-test-package-zip/my-test-package.zip
Binary files differ
diff --git a/pkg_resources/tests/test_find_distributions.py b/pkg_resources/tests/test_find_distributions.py
index f9594422..b01b4827 100644
--- a/pkg_resources/tests/test_find_distributions.py
+++ b/pkg_resources/tests/test_find_distributions.py
@@ -32,3 +32,12 @@ class TestFindDistributions:
assert [dist.project_name for dist in dists] == ['my-test-package']
dists = pkg_resources.find_distributions(str(target_dir), only=True)
assert not list(dists)
+
+ def test_zipped_sdist_one_level_removed(self, target_dir):
+ (TESTS_DATA_DIR / 'my-test-package-zip').copy(target_dir)
+ dists = pkg_resources.find_distributions(
+ str(target_dir / "my-test-package.zip"))
+ assert [dist.project_name for dist in dists] == ['my-test-package']
+ dists = pkg_resources.find_distributions(
+ str(target_dir / "my-test-package.zip"), only=True)
+ assert not list(dists)