Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg_resources: filter entries before parsing them #1134

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion pkg_resources/__init__.py
Expand Up @@ -2041,8 +2041,17 @@ def find_on_path(importer, path_item, only=False):
or hasattr(e, "winerror") and e.winerror == 267):
return
raise
# first filter entries that interest us before sorting
def of_interest(entry):
"""Return whetever `entry` is interesting to parse as an egg"""
return (entry.lower().endswith('.egg-info')
or entry.lower().endswith('.dist-info')
or (not only and _is_egg_path(entry))
or (not only and entry.lower().endswith('.egg-link')))

# scan for .egg and .egg-info in directory
path_item_entries = _by_version_descending(entries)
path_item_entries = _by_version_descending(
filter(of_interest, entries))
for entry in path_item_entries:
lower = entry.lower()
if lower.endswith('.egg-info') or lower.endswith('.dist-info'):
Expand Down