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

Python version confusion #457

Merged
merged 3 commits into from
Sep 3, 2022

Conversation

dimbleby
Copy link
Contributor

Undoing #407 and taking a different approach. (Can confirm that this still fixes python-poetry/poetry#5591).

When setting python versions we also construct a marker to carry the same information. Prior to #407, the python constraint and python marker were not consistent, which that MR fixed by re-parsing the constructed marker into a fresh constraint.

This was nonsense: the constraint was right all along, it was the constructed marker that was wrong.

The result is that as of today a python requirement like <=3.10 is interpreted as <3.11 - whereas it should be equivalent to <=3.10.0

NB there is no problem with the normalization of python markers: a marker like python_version <= "3.10" is equivalent to python_version < "3.11". But that was never the correct marker for the python requirement.

So in this MR I revert #407, and make the construction of a python_version marker from a constraint be more careful of this edge condition, we now explicitly zero-pad and use python_full_version when we hit it.

(IMO this is not important enough to delay the upcoming 1.2.0 release).

@dimbleby dimbleby force-pushed the python-version-confusion branch 2 times, most recently from 6d6d2bd to 936dae2 Compare August 29, 2022 17:39
@dimbleby dimbleby force-pushed the python-version-confusion branch 2 times, most recently from 6c07428 to 71bbb18 Compare August 29, 2022 17:47
@radoering
Copy link
Member

The result is that as of today a python requirement like <=3.10 is interpreted as <3.11 - whereas it should be equivalent to <=3.10.0

Is there some reference that confirms this? (For markers PEP 508 says that <=3.10 is equal to <3.11.)

@dimbleby
Copy link
Contributor Author

discussion in pypa/pip#11420 - where I tried to tell the pip folk that they were doing it wrong but they persuaded me of the opposite - points at PEP 440

@dimbleby
Copy link
Contributor Author

This also implies that poetry is doing it wrong when the the python requirement is eg ==3.6, this too should be treated as ==3.6.0. However that would break the case where the python requirement was 3.6 - and it is hard for poetry to tell these apart, anyway it would have to be done before parsing the text into a constraint.

So I've erred on the side of caution and left that alone.

@sonarcloud
Copy link

sonarcloud bot commented Sep 3, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@radoering radoering merged commit 8ff1a72 into python-poetry:main Sep 3, 2022
@dimbleby dimbleby deleted the python-version-confusion branch September 3, 2022 20:01
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.

Python requirement of package completely ignored by poetry
2 participants