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 24, 2015
1 parent 81e091e commit 6a07eb4
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 when
# to_install is calculated, which reverses the order,
# req_to_install is installed after its dependencies.
Expand All @@ -532,16 +544,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 6a07eb4

Please sign in to comment.