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: pdm translator fails to resolve dependency if pre-release version is required #59

Merged
merged 2 commits into from
Dec 8, 2023

Conversation

betaboon
Copy link
Collaborator

@betaboon betaboon commented Dec 7, 2023

fixes
__main__.MismatchedVersionException: Found no packages to satisfy dependency (name=sphinx-basic-ng, spec=)

which occurs if a package does not specify any constraints for a dependency.

Copy link
Owner

@jvolkman jvolkman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a minimal reproducer for this that you can think of? I assume it worked before the rewrite?

Comment on lines 85 to 86
if not req.specifier:
return True
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you verify that this actually resolves the issue? req.specifier is already supposed to behave this way when no specifier is present, so I think something else might be going on.

E.g.

>>> from packaging.requirements import Requirement
>>> from packaging.version import Version
>>> req = Requirement("foo")
>>> ver = Version("1.0")
>>> print(f"spec={req.specifier}")
spec=
>>> print(req.specifier.contains(ver))
True

Copy link
Collaborator Author

@betaboon betaboon Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to provide a repro tomorrow

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm. you're right. i cant seem to easily reproduce this.
need some time to investigate.
will post back

Copy link
Collaborator Author

@betaboon betaboon Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min-repro is pdm add furo.
which pulls in sphinx-basic-ng without a contraint, which resolves to 1.0.0b1..

and then basically this happens:

>>> from packaging.requirements import Requirement
>>> from packaging.version import Version
>>> 
>>> req = Requirement("sphinx-basic-ng")
>>> ver = Version("1.0.0b1")
>>> print(f"spec={req.specifier}")
spec=
>>> print(req.specifier.contains(ver))
False

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it's basically about using prereleases=True for Specifier.contains

@betaboon betaboon force-pushed the fix-pdm-resolve-without-spec branch from 33441f8 to 1ac2897 Compare December 8, 2023 12:15
@betaboon betaboon force-pushed the fix-pdm-resolve-without-spec branch from 1ac2897 to ac1a627 Compare December 8, 2023 12:17
@betaboon betaboon changed the title fix: pdm translator fails to resolve dependency if no spec given fix: pdm translator fails to resolve dependency if pre-release version is required Dec 8, 2023
Copy link
Owner

@jvolkman jvolkman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@jvolkman jvolkman merged commit b51fde1 into jvolkman:main Dec 8, 2023
14 checks passed
@betaboon betaboon deleted the fix-pdm-resolve-without-spec branch December 8, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants