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
7d34b2d7
Commit
7d34b2d7
authored
Feb 10, 2018
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract method for filtering extras
parent
1bbafd87
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
pkg_resources/__init__.py
pkg_resources/__init__.py
+24
-10
No files found.
pkg_resources/__init__.py
View file @
7d34b2d7
...
@@ -2683,22 +2683,36 @@ class Distribution(object):
...
@@ -2683,22 +2683,36 @@ class Distribution(object):
try:
try:
return self.__dep_map
return self.__dep_map
except AttributeError:
except AttributeError:
self.__dep_map = self._
build_dep_map(
)
self.__dep_map = self._
filter_extras(self._build_dep_map()
)
return self.__dep_map
return self.__dep_map
def _build_dep_map(self):
@staticmethod
dm = {}
def _filter_extras(dm):
for name in 'requires.txt', 'depends.txt':
"""
for extra, reqs in split_sections(self._get_metadata(name)):
Given
a
mapping
of
extras
to
dependencies
,
strip
off
environment
markers
and
filter
out
any
dependencies
not
matching
the
markers
.
"""
for extra in list(dm):
if extra:
if extra:
new_extra = extra
reqs = dm.pop(extra)
if ':' in extra:
if ':' in extra:
extra, marker = extra.split(':', 1)
new_
extra, marker = extra.split(':', 1)
if invalid_marker(marker):
if invalid_marker(marker):
# XXX warn
# XXX warn
reqs = []
reqs = []
elif not evaluate_marker(marker):
elif not evaluate_marker(marker):
reqs = []
reqs = []
extra = safe_extra(extra) or None
new_extra = safe_extra(new_extra) or None
dm.setdefault(new_extra, []).extend(reqs)
return dm
def _build_dep_map(self):
dm = {}
for name in 'requires.txt', 'depends.txt':
for extra, reqs in split_sections(self._get_metadata(name)):
dm.setdefault(extra, []).extend(parse_requirements(reqs))
dm.setdefault(extra, []).extend(parse_requirements(reqs))
return dm
return dm
...
...
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