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

Compile editables that are both primary reqs and constraints #1093

Merged
merged 1 commit into from
Apr 2, 2020
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: 2 additions & 8 deletions piptools/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def combine_install_requirements(ireqs):
combined_ireq = copy.deepcopy(source_ireqs[0])
for ireq in source_ireqs[1:]:
# NOTE we may be losing some info on dropped reqs here
combined_ireq.req.specifier &= ireq.req.specifier
if combined_ireq.req is not None and ireq.req is not None:
combined_ireq.req.specifier &= ireq.req.specifier
combined_ireq.constraint &= ireq.constraint
# Return a sorted, de-duped tuple of extras
combined_ireq.extras = tuple(
Expand Down Expand Up @@ -220,13 +221,6 @@ def _group_constraints(self, constraints):

"""
for _, ireqs in full_groupby(constraints, key=key_from_ireq):
ireqs = list(ireqs)
editable_ireq = next((ireq for ireq in ireqs if ireq.editable), None)
if editable_ireq:
# ignore all the other specs: the editable one is the one that counts
atugushev marked this conversation as resolved.
Show resolved Hide resolved
yield editable_ireq
continue

yield combine_install_requirements(ireqs)

def _resolve_one_round(self):
Expand Down
23 changes: 23 additions & 0 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,29 @@ def test_editable_package(pip_conf, runner):
assert "small-fake-a==0.1" in out.stderr


@pytest.mark.parametrize(("req_editable",), [(True,), (False,)])
def test_editable_package_in_constraints(pip_conf, runner, req_editable):
"""
piptools can compile an editable that appears in both primary requirements
and constraints
"""
fake_package_dir = os.path.join(PACKAGES_PATH, "small_fake_with_deps")
fake_package_dir = path_to_url(fake_package_dir)

with open("constraints.txt", "w") as constraints_in:
constraints_in.write("-e " + fake_package_dir)

with open("requirements.in", "w") as req_in:
prefix = "-e " if req_editable else ""
req_in.write(prefix + fake_package_dir + "\n-c constraints.txt")

out = runner.invoke(cli, ["-n"])

assert out.exit_code == 0
assert fake_package_dir in out.stderr
assert "small-fake-a==0.1" in out.stderr


@pytest.mark.network
def test_editable_package_vcs(runner):
vcs_package = (
Expand Down