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

Re resolve combined ireq #1512

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions piptools/resolver.py
Expand Up @@ -72,6 +72,9 @@ def combine_install_requirements(

# deepcopy the accumulator so as to not modify the inputs
combined_ireq = copy.deepcopy(source_ireqs[0])
# combined install_requirement needs to be prepared again, i.e. to have its
# dependencies be resolved again.
combined_ireq.prepared = False

for ireq in source_ireqs[1:]:
# NOTE we may be losing some info on dropped reqs here
Expand Down
64 changes: 64 additions & 0 deletions tests/test_cli_compile.py
Expand Up @@ -1759,6 +1759,70 @@ def test_combine_extras(pip_conf, runner, make_package):
assert "small-fake-b==" in out.stderr


def test_combine_different_extras_of_the_same_package(
pip_conf, runner, tmpdir, make_package, make_wheel
):
"""
Loosely based on the example from https://github.com/jazzband/pip-tools/issues/1511.
"""
pkgs = [
make_package(
"fake-colorful",
version="0.3",
),
make_package(
"fake-tensorboardX",
version="0.5",
),
make_package(
"fake-ray",
version="0.1",
extras_require={
"default": ["fake-colorful==0.3"],
"tune": ["fake-tensorboardX==0.5"],
},
),
make_package(
"fake-tune-sklearn",
version="0.7",
install_requires=[
"fake-ray[tune]==0.1",
],
),
]

dists_dir = tmpdir / "dists"
for pkg in pkgs:
make_wheel(pkg, dists_dir)

with open("requirements.in", "w") as req_in:
req_in.writelines(
[
"fake-ray[default]==0.1\n",
"fake-tune-sklearn==0.7\n",
]
)

out = runner.invoke(cli, ["--find-links", str(dists_dir)])

assert out.exit_code == 0
assert (
"""\
fake-colorful==0.3
# via fake-ray
fake-ray[default,tune]==0.1
# via
# -r requirements.in
# fake-tune-sklearn
fake-tensorboardx==0.5
# via fake-ray
fake-tune-sklearn==0.7
# via -r requirements.in
"""
in out.stderr
)


@pytest.mark.parametrize(
("pkg2_install_requires", "req_in_content", "out_expected_content"),
(
Expand Down
13 changes: 13 additions & 0 deletions tests/test_resolver.py
Expand Up @@ -341,6 +341,19 @@ def test_combine_install_requirements_extras_no_req(
)


def test_combine_install_requirements_for_one_package_with_multiple_extras_reset_prepared(
repository, from_line
):
"""Regression test for https://github.com/jazzband/pip-tools/pull/1512/files."""
pkg1 = from_line("ray[default]==1.1.1")
pkg1.prepared = True
pkg2 = from_line("ray[tune]==1.1.1")
combined = combine_install_requirements(repository, [pkg1, pkg2])

assert str(combined) == "ray[default,tune]==1.1.1"
assert combined.prepared is False


def test_compile_failure_shows_provenance(resolver, from_line):
"""
Provenance of conflicting dependencies should be printed on failure.
Expand Down