diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2021-01-16 18:47:33 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-16 18:47:33 -0500 |
| commit | 886dd34d565f3911819d4c16c6f16fe3cd65a39d (patch) | |
| tree | 07e9068e1fe8d00f6988a6395ec419b9efb08ebc | |
| parent | aef3393748c7804937fab87d5754ca434fa37f9b (diff) | |
| parent | b31105bdc855d75fc4f9fc7cfe005a81e7cc2f38 (diff) | |
| download | python-setuptools-git-886dd34d565f3911819d4c16c6f16fe3cd65a39d.tar.gz | |
Merge pull request #2490 from thatch/main
Fix .egg-info metadata support for zipimport
| -rw-r--r-- | changelog.d/2489.change.rst | 2 | ||||
| -rw-r--r-- | pkg_resources/__init__.py | 3 | ||||
| -rw-r--r-- | pkg_resources/tests/data/my-test-package-zip/my-test-package.zip | bin | 0 -> 1809 bytes | |||
| -rw-r--r-- | pkg_resources/tests/test_find_distributions.py | 9 |
4 files changed, 13 insertions, 1 deletions
diff --git a/changelog.d/2489.change.rst b/changelog.d/2489.change.rst new file mode 100644 index 00000000..40eddbe7 --- /dev/null +++ b/changelog.d/2489.change.rst @@ -0,0 +1,2 @@ +``pkg_resources`` behavior for zipimport now matches the regular behavior, and finds +``.egg-info`` (previoulsy would only find ``.dist-info``) -- by :user:`thatch` 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 Binary files differnew file mode 100644 index 00000000..81f9a017 --- /dev/null +++ b/pkg_resources/tests/data/my-test-package-zip/my-test-package.zip 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) |
