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 a7e00cd commit c7cf206
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pip/req/req_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,17 @@ 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,
Expand Down Expand Up @@ -525,16 +536,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 c7cf206

Please sign in to comment.