Skip to content

Commit

Permalink
support pinned vcs dependencies [jazzband#355]
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-weber committed Jul 7, 2016
1 parent 111d510 commit ca509d3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion piptools/repositories/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def find_best_match(self, ireq, prereleases=None):
Returns a Version object that indicates the best match for the given
InstallRequirement according to the external repository.
"""
if ireq.editable:
if ireq.editable or (ireq.link and not ireq.link.is_artifact):
return ireq # return itself as the best match

all_candidates = self.find_all_candidates(ireq.name)
Expand Down
14 changes: 7 additions & 7 deletions piptools/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ def resolve(self, max_rounds=10):

def _check_constraints(self):
for constraint in chain(self.our_constraints, self.their_constraints):
if constraint.link is not None and not constraint.editable:
msg = ('pip-compile does not support URLs as packages, unless they are editable. '
'Perhaps add -e option?')
if ((constraint.link and not constraint.editable
and not constraint.link.is_artifact and not is_pinned_requirement(constraint))):
msg = 'pip-compile does not support non-editable vcs URLs that are not pinned to one version.'
raise UnsupportedConstraint(msg, constraint)

def _group_constraints(self, constraints):
Expand All @@ -142,9 +142,9 @@ def _group_constraints(self, constraints):
"""
for _, ireqs in full_groupby(constraints, key=_dep_key):
ireqs = list(ireqs)
editable_ireq = first(ireqs, key=lambda ireq: ireq.editable)
if editable_ireq:
yield editable_ireq # ignore all the other specs: the editable one is the one that counts
exception_ireq = first(ireqs, key=lambda ireq: ireq.editable or (ireq.link and not ireq.link.is_artifact))
if exception_ireq:
yield exception_ireq # ignore all the other specs: the editable/vcs one is the one that counts
continue

ireqs = iter(ireqs)
Expand Down Expand Up @@ -214,7 +214,7 @@ def get_best_match(self, ireq):
Flask==0.10.1 => Flask==0.10.1
"""
if ireq.editable:
if ireq.editable or (ireq.link and not ireq.link.is_artifact):
# NOTE: it's much quicker to immediately return instead of
# hitting the index server
best_match = ireq
Expand Down
10 changes: 5 additions & 5 deletions piptools/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from . import click
from .exceptions import IncompatibleRequirements, UnsupportedConstraint
from .utils import flat_map, key_from_req
from .utils import flat_map, key_from_req, is_pinned_requirement

PACKAGES_TO_IGNORE = [
'pip',
Expand Down Expand Up @@ -68,9 +68,9 @@ def merge(requirements, ignore_conflicts):
by_key = {}

for ireq in requirements:
if ireq.link is not None and not ireq.editable:
msg = ('pip-compile does not support URLs as packages, unless they are editable. '
'Perhaps add -e option?')
if ((ireq.link and not ireq.editable
and not ireq.link.is_artifact and not is_pinned_requirement(ireq))):
msg = 'pip-compile does not support non-editable vcs URLs that are not pinned to one version.'
raise UnsupportedConstraint(msg, ireq)

key = ireq.link or key_from_req(ireq.req)
Expand All @@ -94,7 +94,7 @@ def diff(compiled_requirements, installed_dists):
Calculate which packages should be installed or uninstalled, given a set
of compiled requirements and a list of currently installed modules.
"""
requirements_lut = {r.link or key_from_req(r.req): r for r in compiled_requirements}
requirements_lut = {r.link if r.editable else key_from_req(r.req): r for r in compiled_requirements}

satisfied = set() # holds keys
to_install = set() # holds keys-and-versions
Expand Down
4 changes: 2 additions & 2 deletions piptools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def format_requirement(ireq, include_specifier=True):
Generic formatter for pretty printing InstallRequirements to the terminal
in a less verbose way than using its `__str__` method.
"""
if ireq.editable:
line = '-e {}'.format(ireq.link)
if ireq.editable or (ireq.link and not ireq.link.is_artifact):
line = '{}{}'.format('-e ' if ireq.editable else '', ireq.link)
elif include_specifier:
line = str(ireq.req)
else:
Expand Down

0 comments on commit ca509d3

Please sign in to comment.