From 965ec0df1ffa98ba5d8913a2770daaf5b92b0a0d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 28 May 2020 07:03:19 -0400 Subject: In pkg_resources, no longer detect any pathname ending in .egg as a Python egg. Now the path must be an unpacked egg or a zip file. Fixes #2129. --- pkg_resources/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'pkg_resources') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 2e7d5059..3c826eb0 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -2373,7 +2373,15 @@ def _is_egg_path(path): """ Determine if given path appears to be an egg. """ - return path.lower().endswith('.egg') + return _is_zip_egg(path) or _is_unpacked_egg(path) + + +def _is_zip_egg(path): + return ( + path.lower().endswith('.egg') and + os.path.isfile(path) and + zipfile.is_zipfile(path) + ) def _is_unpacked_egg(path): @@ -2381,7 +2389,7 @@ def _is_unpacked_egg(path): Determine if given path appears to be an unpacked egg. """ return ( - _is_egg_path(path) and + path.lower().endswith('.egg') and os.path.isfile(os.path.join(path, 'EGG-INFO', 'PKG-INFO')) ) -- cgit v1.2.1 From 9372bf7d7f63136758196dd86688f00602b7a494 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 3 Jul 2020 12:55:46 -0400 Subject: Keep the full path for each entry when enumerating entries for a candidate path. --- pkg_resources/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg_resources') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 3c826eb0..5df23e5b 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -2057,7 +2057,10 @@ def find_on_path(importer, path_item, only=False): ) return - entries = safe_listdir(path_item) + entries = ( + os.path.join(path_item, child) + for child in safe_listdir(path_item) + ) # for performance, before sorting by version, # screen entries for only those that will yield -- cgit v1.2.1