Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolver.constraints: Keep our_constraints before their_constraints #879

Merged
merged 1 commit into from
Aug 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions piptools/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def combine_install_requirements(ireqs):
source_ireqs = []
for ireq in ireqs:
source_ireqs.extend(getattr(ireq, "_source_ireqs", [ireq]))
source_ireqs.sort(key=str)

# deepcopy the accumulator so as to not modify the inputs
combined_ireq = copy.deepcopy(source_ireqs[0])
Expand Down Expand Up @@ -120,7 +119,12 @@ def __init__(
@property
def constraints(self):
return set(
self._group_constraints(chain(self.our_constraints, self.their_constraints))
self._group_constraints(
chain(
sorted(self.our_constraints, key=str),
sorted(self.their_constraints, key=str),
)
)
)

def resolve_hashes(self, ireqs):
Expand Down Expand Up @@ -258,7 +262,7 @@ def _resolve_one_round(self):
for best_match in best_matches:
their_constraints.extend(self._iter_dependencies(best_match))
# Grouping constraints to make clean diff between rounds
theirs = set(self._group_constraints(their_constraints))
theirs = set(self._group_constraints(sorted(their_constraints, key=str)))

# NOTE: We need to compare RequirementSummary objects, since
# InstallRequirement does not define equality
Expand Down
9 changes: 7 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
from piptools.repositories import PyPIRepository
from piptools.repositories.base import BaseRepository
from piptools.resolver import Resolver
from piptools.utils import as_tuple, key_from_req, make_install_requirement
from piptools.utils import (
as_tuple,
is_url_requirement,
key_from_req,
make_install_requirement,
)


class FakeRepository(BaseRepository):
Expand Down Expand Up @@ -59,7 +64,7 @@ def find_best_match(self, ireq, prereleases=False):
)

def get_dependencies(self, ireq):
if ireq.editable:
if ireq.editable or is_url_requirement(ireq):
return self.editables[str(ireq.link)]

name, version, extras = as_tuple(ireq)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_data/fake-editables.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"git+git://example.org/django.git#egg=django": []
"git+git://example.org/django.git#egg=django": [],
"git+https://github.com/celery/billiard#egg=billiard==3.5.9999": []
}
21 changes: 19 additions & 2 deletions tests/test_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,23 @@
),
},
),
# Git URL requirement
# See: GH-851
(
[
"git+https://github.com/celery/billiard#egg=billiard==3.5.9999",
"celery==4.0.2",
],
[
"amqp==2.1.4 (from kombu==4.0.2->celery==4.0.2)",
"kombu==4.0.2 (from celery==4.0.2)",
"billiard<3.6.0,==3.5.9999,>=3.5.0.2 from "
"git+https://github.com/celery/billiard#egg=billiard==3.5.9999",
"vine==1.1.3 (from amqp==2.1.4->kombu==4.0.2->celery==4.0.2)",
"celery==4.0.2",
"pytz==2016.4 (from celery==4.0.2)",
],
),
]
),
)
Expand Down Expand Up @@ -264,8 +281,8 @@ def test_compile_failure_shows_provenance(resolver, from_line):
with pytest.raises(NoCandidateFound) as err:
resolver(requirements).resolve()
lines = str(err.value).splitlines()
assert lines[-2].strip() == "celery>3.2"
assert (
lines[-2].strip()
lines[-1].strip()
== "celery==3.1.18 (from fake-piptools-test-with-pinned-deps==0.1)"
)
assert lines[-1].strip() == "celery>3.2"