Skip to content

Commit

Permalink
Make a helper function for adding requirements
Browse files Browse the repository at this point in the history
This is for reuse in the declarative requires patch.
  • Loading branch information
rbtcollins committed Mar 31, 2015
1 parent 611f040 commit c9f451a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions pip/req/req_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,18 @@ def _prepare_file(self, finder, req_to_install):
dist = abstract_dist.dist(finder)
more_reqs = []

def add_req(subreq):
if self.has_requirement(subreq.project_name):
# FIXME: check for conflict
return
subreq = InstallRequirement(
str(subreq),
req_to_install,
isolated=self.isolated,
)
more_reqs.append(subreq)
self.add_requirement(subreq)

# We add req_to_install before its dependencies, so that we
# can refer to it when adding dependencies.
if not self.has_requirement(req_to_install.name):
Expand All @@ -531,16 +543,7 @@ def _prepare_file(self, finder, req_to_install):
set(dist.extras) & set(req_to_install.extras)
)
for subreq in dist.requires(available_requested):
if self.has_requirement(subreq.project_name):
# FIXME: check for conflict
continue
subreq = InstallRequirement(
str(subreq),
req_to_install,
isolated=self.isolated,
)
more_reqs.append(subreq)
self.add_requirement(subreq)
add_req(subreq)

# cleanup tmp src
self.reqs_to_cleanup.append(req_to_install)
Expand Down

0 comments on commit c9f451a

Please sign in to comment.