From 44d45ae20a663f1cb75812657cee1244e3dddb58 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Mon, 14 Dec 2020 09:37:47 -0800 Subject: [PATCH 1/3] Failing test for #2489 --- .../data/my-test-package-zip/my-test-package.zip | Bin 0 -> 1809 bytes pkg_resources/tests/test_find_distributions.py | 9 +++++++++ 2 files changed, 9 insertions(+) create mode 100644 pkg_resources/tests/data/my-test-package-zip/my-test-package.zip 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 0000000000000000000000000000000000000000..81f9a0170f7aca13a0d1d8e5201c2c186554ce7e GIT binary patch literal 1809 zcmWIWW@h1H0D)azeSu&Gl#pbQVaTnFFG(#fi7!Y@&Q45E)k{rJ*UijJ%hwML;bdUe zpMO0bgi9;985mh!GBYrMi2%5fTY*MSX1i|02s9Fe)$kcvl3x&?lUkOVqgPT<0ybX_ zXf_C=na_pW0$qF-q@)(4=B1?OC0EAhWaecTQ(%uGK6|P%3v`PU(^3igK?E2i91Ng9 z>Qt-#nFi!t0AdwCnp#)4OE7jTz7~^SAlTG(bAA8AyDPR;f4!dkX8HNea$EmA zwK}WtMDnKS#3`EQP;!goS%>XQ>Q?o zm|3%DM}%Z96?pah?Q{8e$DdA|KbtFL*1Rr(A|2h6C-j}3zh3rCE$x|tORdr5;LlwX zx9nUZrY@c;Hl^Wh6DQjfm1#?!ia%9yVL&9U4{oU0ffE=l#i=Ew1$xP8>0qa`%*2{J z5upMy;`CJ|oe*G%WB@S-+=zloxC!NRF%tOcGrA}AwE{K#bTxG~PM$xn`OL}S>j58L zJywMipb!W>g&G2(ml#h^T`DG;{_OcpEy-7s4y~(|Jj5D;Ma>j94s5Nm*O1WXqEz}f>TdjX9DWiPC$3=%$=nG4y~L2% Date: Mon, 14 Dec 2020 09:14:45 -0800 Subject: [PATCH 2/3] Find .egg-info in zipimport too Fixes #2489 --- changelog.d/2489.change.rst | 2 ++ pkg_resources/__init__.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelog.d/2489.change.rst diff --git a/changelog.d/2489.change.rst b/changelog.d/2489.change.rst new file mode 100644 index 0000000000..40eddbe734 --- /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 737f4d5fad..ba90c8c4ab 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -1978,12 +1978,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 any(map(lower.endswith, ('.dist-info', '.egg-info'))): subpath = os.path.join(path_item, subitem) submeta = EggMetadata(zipimport.zipimporter(subpath)) submeta.egg_info = subpath From b31105bdc855d75fc4f9fc7cfe005a81e7cc2f38 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2021 18:47:18 -0500 Subject: [PATCH 3/3] Rely on tuple argument to endswith Co-authored-by: Sviatoslav Sydorenko --- pkg_resources/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index ba90c8c4ab..a304647fd0 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -1984,7 +1984,7 @@ def find_eggs_in_zip(importer, path_item, only=False): dists = find_eggs_in_zip(zipimport.zipimporter(subpath), subpath) for dist in dists: yield dist - elif any(map(lower.endswith, ('.dist-info', '.egg-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