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

Requires version constraints #517

Merged
merged 11 commits into from
Nov 22, 2024
Merged

Requires version constraints #517

merged 11 commits into from
Nov 22, 2024

Conversation

1maple1
Copy link
Contributor

@1maple1 1maple1 commented Nov 14, 2024

No description provided.

@1maple1 1maple1 requested a review from TheBurchLog November 14, 2024 14:38
@TheBurchLog
Copy link
Contributor

Give this a try instead so we don't have to handle the regex logic:

from packaging.requirements import Requirement
from packaging.version import Version

req = Requirement("name>1")

if Version(system.version) in req.specifier:
    #Valid Version

)
)
if valid_versions:
system_candidates = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Mapping back and forth from str(Version) to system.version doesn't always match because Version parsing will sometimes fix formatting issues so it is no longer a one to one Mapping. Check out how System Client handles it in _determine_latest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this situation is slightly different. I think changing an invalid requires version to a valid package version is ok. If a version can't be parsed at all it should fail. Anyway, I updated tests to show what happens in the various cases. We can debate more.


if valid_versions:
system_candidates = [
system for system in systems if system.version in valid_versions
Copy link
Contributor

Choose a reason for hiding this comment

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

We should compare parsed versions to parsed versions:
system for system in systems if str(Version(system.version)) in valid_versions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

complete

@1maple1 1maple1 merged commit d46d180 into develop Nov 22, 2024
6 checks passed
@1maple1 1maple1 deleted the requires-version branch November 22, 2024 15:08
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