Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
f24868e7
Commit
f24868e7
authored
Sep 09, 2017
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract functions for resolving egg_link and reading non-empty lines from a file.
parent
0a614125
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
12 deletions
+26
-12
pkg_resources/__init__.py
pkg_resources/__init__.py
+26
-12
No files found.
pkg_resources/__init__.py
View file @
f24868e7
...
...
@@ -2048,8 +2048,8 @@ def find_on_path(importer, path_item, only=False):
path_item_entries = _by_version_descending(entries)
for entry in path_item_entries:
lower = entry.lower()
fullpath = os.path.join(path_item, entry)
if lower.endswith('.egg-info') or lower.endswith('.dist-info'):
fullpath = os.path.join(path_item, entry)
if os.path.isdir(fullpath):
# egg-info directory, allow getting metadata
if len(os.listdir(fullpath)) == 0:
...
...
@@ -2062,20 +2062,34 @@ def find_on_path(importer, path_item, only=False):
path_item, entry, metadata, precedence=DEVELOP_DIST
)
elif not only and _is_egg_path(entry):
dists = find_distributions(
os.path.join(path_item, entry)
)
dists = find_distributions(
fullpath
)
for dist in dists:
yield dist
elif not only and lower.endswith('.egg-link'):
with open(os.path.join(path_item, entry)) as entry_file:
entry_lines = entry_file.readlines()
for line in entry_lines:
if not line.strip():
continue
path = os.path.join(path_item, line.rstrip())
dists = find_distributions(path)
for item in dists:
yield item
break
dists = resolve_egg_link(fullpath)
for dist in dists:
yield dist
def non_empty_lines(path):
"""
Yield
non
-
empty
lines
from
file
at
path
"""
return (line.rstrip() for line in open(path) if line.strip())
def resolve_egg_link(path):
"""
Given
a
path
to
an
.
egg
-
link
,
resolve
distributions
present
in
the
referenced
path
.
"""
referenced_paths = non_empty_lines(path)
resolved_paths = (
os.path.join(os.path.dirname(path), ref)
for ref in referenced_paths
)
dist_groups = map(find_distributions, resolved_paths)
return next(dist_groups, ())
register_finder(pkgutil.ImpImporter, find_on_path)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment