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

Fix dependency overrides for packages with multiple duplicate dependencies #2622

Merged
merged 1 commit into from
Jul 3, 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
2 changes: 1 addition & 1 deletion poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def complete_package(
overrides = []
for _dep in _deps:
current_overrides = self._overrides.copy()
package_overrides = current_overrides.get(package, {})
package_overrides = current_overrides.get(package, {}).copy()
package_overrides.update({_dep.name: _dep})
current_overrides.update({package: package_overrides})
overrides.append(current_overrides)
Expand Down
40 changes: 40 additions & 0 deletions tests/puzzle/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2003,3 +2003,43 @@ def test_solver_should_not_update_same_version_packages_if_installed_has_no_sour
check_solver_result(
ops, [{"job": "install", "package": foo, "skipped": True}],
)


def test_solver_should_resolve_all_versions_for_multiple_duplicate_dependencies(
solver, repo, package
):
package.python_versions = "~2.7 || ^3.5"
package.add_dependency(
"A", {"version": "^1.0", "markers": "python_version < '3.5'"}
)
package.add_dependency(
"A", {"version": "^2.0", "markers": "python_version >= '3.5'"}
)
package.add_dependency(
"B", {"version": "^3.0", "markers": "python_version < '3.5'"}
)
package.add_dependency(
"B", {"version": "^4.0", "markers": "python_version >= '3.5'"}
)

package_a10 = get_package("A", "1.0.0")
package_a20 = get_package("A", "2.0.0")
package_b30 = get_package("B", "3.0.0")
package_b40 = get_package("B", "4.0.0")

repo.add_package(package_a10)
repo.add_package(package_a20)
repo.add_package(package_b30)
repo.add_package(package_b40)

ops = solver.solve()

check_solver_result(
ops,
[
{"job": "install", "package": package_a10},
{"job": "install", "package": package_a20},
{"job": "install", "package": package_b30},
{"job": "install", "package": package_b40},
],
)