-
Notifications
You must be signed in to change notification settings - Fork 251
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
platform release is not a version-like marker #552
base: main
Are you sure you want to change the base?
Conversation
01537ec
to
64f0f05
Compare
tests/version/test_markers.py
Outdated
@@ -913,6 +913,14 @@ def test_parse_version_like_markers(marker: str, env: dict[str, str]) -> None: | |||
assert m.validate(env) | |||
|
|||
|
|||
def test_environment_markers() -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test fails before the change in markers.py
Version like markers are validated against PEP-440. This allows things like '1.0.0' and disallows things like '1.8.0_u60'. However, this is very valid in platform_release, as described in [PEP-508](https://peps.python.org/pep-0508/#environment-markers) which gives samples `3.14.1-x86_64-linode39, 14.5.0, 1.8.0_51`. platform_release should be a normal marker, which I think allows for equality checking only. This fixes #7418 where I was guided towards this solution.
…anyone git blames this
for more information, see https://pre-commit.ci
47fb3b2
to
eca89a7
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
This would be helpful to us. With it we can install certain packages/versions only for specific platforms. Could you give this a review poetry-team? |
@dimbleby I see you interacted on the original issue (python-poetry/poetry#7418) could you give this mr a quick review? |
looks fine to me but i don't have the commit bit so that doesn't help you |
I'm a bit on the fence here. If we change |
https://packaging.python.org/en/latest/specifications/dependency-specifiers/#environment-markers
ie it seems as though the intended behaviour is a kind of duck-typing: if everything looks like a version then treat everything as a version, and if not then don't. In particular: if so yeah, poetry is currently doing it wrong with or without this MR |
this is probably unsolvable in the context of a tool that is trying to build a cross-platform lockfile - because it can't possibly know whether |
current behaviour is, that it is assumed that some markers are version like and some are not: if name in self._VERSION_LIKE_MARKER_NAME:
parser = parse_version_constraint From my understanding the standard wants to determine this on the fly and then treat the markers either as version (if both sides are version like) or as generic otherwise.
Is this possible from the way poetry is designed? I could imagine that at install time we just check what type the constraints are, but I'm unclear what happens at lock time. If this is not possible I would argue that we should treat platform_relaese as generic marker (as proposed in this mr), because the assumption that it is a version is not true in general. |
the assumption that it is not a version is also not true in general, so unfortunately this reasoning is equally convincing as an argument for doing the exact opposite. |
that's true. But from my understanding it is true that it will always work on all platforms, whereas the approach that assumes a version-like marker breaks on a lot of platforms. Meaning the generic marker is less powerful but always works with explicit comparisons, whereas the version-like marker is sometimes more powerful but breaks on a lot of platforms. I would argue that we should go for the approach that is less powerful but always works in this case. What about the other option, doing both, do you know if that is realistic? |
this is not true. If this were true then everything might as well be a non-version marker. version-comparisons are not the same as string-comparisons. |
sorry I think my comment was not precise, I meant that using generic markers with string comparisons for the |
using string comparisons does not "work" on every platform, it gives wrong answers where version comparisons are required. Thats not just "less powerful": it is broken. |
I have not thought it through to the end yet, but a possible solution might be:
That's some work because all the methods like Another alternative would be to introduce a new version class (e.g. |
Version like markers are validated against PEP-440. This allows things like '1.0.0' and disallows things like '1.8.0_60-redhat'. However, this is very valid in platform_release, as described in
PEP-508 which gives samples
3.14.1-x86_64-linode39, 14.5.0, 1.8.0_51
.platform_release should be a generic marker, which I think allows for equality checking only.
Resolves: python-poetry#7418