Commit 886dd34d authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #2490 from thatch/main

Fix .egg-info metadata support for zipimport
parents aef33937 b31105bd
``pkg_resources`` behavior for zipimport now matches the regular behavior, and finds
``.egg-info`` (previoulsy would only find ``.dist-info``) -- by :user:`thatch`
......@@ -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
......
......@@ -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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment