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

Ignore dependencies not matching the project's python constraint... #4958

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/poetry/mixology/version_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def solve(self) -> SolverResult:
"""
start = time.time()
root_dependency = Dependency(self._root.name, self._root.version)
root_dependency.python_versions = self._root.python_versions
root_dependency.is_root = True

self._add_incompatibility(
Expand Down
24 changes: 24 additions & 0 deletions tests/puzzle/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,30 @@ def test_solver_fails_if_mismatch_root_python_versions(
solver.solve()


def test_solver_ignores_python_restricted_if_mismatch_root_package_python_versions(
solver: Solver, repo: Repository, package: ProjectPackage
):
solver.provider.set_package_python_versions("~3.8")
package.add_dependency(
Factory.create_dependency("A", {"version": "1.0", "python": "<3.8"})
)
package.add_dependency(
Factory.create_dependency(
"B", {"version": "1.0", "markers": "python_version < '3.8'"}
)
)

package_a = get_package("A", "1.0")
package_b = get_package("B", "1.0")

repo.add_package(package_a)
repo.add_package(package_b)

transaction = solver.solve()

check_solver_result(transaction, [])


def test_solver_solves_optional_and_compatible_packages(
solver: Solver, repo: Repository, package: ProjectPackage
):
Expand Down