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: unable to force install specific version with pdm #2587

Merged
merged 1 commit into from
Jan 25, 2024
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
1 change: 1 addition & 0 deletions news/2586.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Unable to force override a package if the package is required with extras.
4 changes: 3 additions & 1 deletion src/pdm/resolver/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ def matches_gen() -> Iterator[Candidate]:
return (c for c in candidates if c not in incompat)
elif identifier in self.overrides:
return iter(self.get_override_candidates(identifier))
elif (name := strip_extras(identifier)[0]) in self.overrides:
return iter(self.get_override_candidates(name))
reqs = sorted(requirements[identifier], key=self.requirement_preference)
if not reqs:
return iter(())
Expand Down Expand Up @@ -250,7 +252,7 @@ def _compare_file_reqs(self, req1: FileRequirement, req2: FileRequirement) -> bo
def is_satisfied_by(self, requirement: Requirement, candidate: Candidate) -> bool:
if isinstance(requirement, PythonRequirement):
return is_python_satisfied_by(requirement, candidate)
elif candidate.identify() in self.overrides:
elif (name := candidate.identify()) in self.overrides or strip_extras(name)[0] in self.overrides:
return True
if not requirement.is_named:
if candidate.req.is_named:
Expand Down
4 changes: 4 additions & 0 deletions tests/resolver/test_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,15 @@ def test_resolve_conflicting_dependencies_with_overrides(project, resolve, repos
repository.add_dependencies("foo", "0.1.0", ["hoho>=2.0"])
repository.add_candidate("bar", "0.1.0")
repository.add_dependencies("bar", "0.1.0", ["hoho~=1.1"])
repository.add_candidate("baz", "0.1.0")
repository.add_dependencies("baz", "0.1.0", ["hoho[extra]~=1.1"])
repository.add_candidate("hoho", "2.1")
repository.add_candidate("hoho", "1.5")
project.pyproject.settings["resolution"] = {"overrides": {"hoho": overrides}}
result = resolve(["foo", "bar"])
assert result["hoho"].version == "2.1"
result = resolve(["foo", "baz"])
assert result["hoho"].version == "2.1"


def test_resolve_no_available_versions(resolve, repository):
Expand Down
Loading