-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support Python versions with trailing +
#1357
Comments
The Local Version Identifiers section of the Version Specifiers spec seems to suggest that a local label needs to be non-empty, but it doesn't seem to come out and say it explicitly. With that said, the regex for parsing version numbers does unambiguously require a non-empty local version segment if a So at least with respect to the spec, it seems like the version number here is invalid. Is there any particular reason why But if this is a widespread or common practice, then perhaps there isn't too much harm in making our version parser slightly more flexible. I think the point here though would be to decide what the semantics of |
I think the Python version isn't governed by PEP 440. 3.11.4+ is if you build off of random CPython commit. I think it comes from e.g. https://github.com/python/cpython/blob/c08c0679055d96c0397cf128bf7cc8134538b36a/Include/patchlevel.h#L26 Should be fine to treat it as 3.11.4 |
They seem semantically different; I would treat |
What's the issue with treating this as equivalent to parsing |
I second @hauntsaninja. The
|
Makes sense. I'd also be open to just stripping a trailing |
They're different versions — the |
There's an upstream cpython bug: python/cpython#99968 |
(This PR message is mostly copied from the comment in the code.) For local builds of Python, at time of writing, the version numbers end with a `+`. This makes the version non-PEP-440 compatible since a `+` indicates the start of a local segment which must be non-empty. Thus, `uv` chokes on it and [spits out an error][1] when trying to create a venv using a "local" build of Python. Arguably, the right fix for this is for [CPython to use a PEP-440 compatible version number][2]. However, as a work-around for now, [as suggested by pradyunsg][3] as one possible direction forward, we strip the `+`. This fix does unfortunately mean that one [cannot specify a Python version constraint that specifically selects a local version][4]. But at the time of writing, it seems reasonable to block such functionality on this being fixed upstream (in some way). Another alternative would be to treat such invalid versions as strings (which is what PEP-508 suggests), but this leads to undesirable behavior in this case. For example, let's say you have a Python constraint of `>=3.9.1` and a local build of Python with a version `3.11.1+`. Using string comparisons would mean the constraint wouldn't be satisfied: >>> "3.9.1" < "3.11.1+" False So in the end, we just strip the trailing `+`, as was done in the days of old for [legacy version numbers][5]. I tested this fix by manually confirming that uv venv --python local/python failed before it and succeeded after it. Fixes #1357 [1]: #1357 [2]: python/cpython#99968 [3]: pypa/packaging#678 (comment) [4]: #1357 (comment) [5]: https://github.com/pypa/packaging/blob/085ff41692b687ae5b0772a55615b69a5b677be9/packaging/version.py#L168-L193
(This PR message is mostly copied from the comment in the code.) For local builds of Python, at time of writing, the version numbers end with a `+`. This makes the version non-PEP-440 compatible since a `+` indicates the start of a local segment which must be non-empty. Thus, `uv` chokes on it and [spits out an error][1] when trying to create a venv using a "local" build of Python. Arguably, the right fix for this is for [CPython to use a PEP-440 compatible version number][2]. However, as a work-around for now, [as suggested by pradyunsg][3] as one possible direction forward, we strip the `+`. This fix does unfortunately mean that one [cannot specify a Python version constraint that specifically selects a local version][4]. But at the time of writing, it seems reasonable to block such functionality on this being fixed upstream (in some way). Another alternative would be to treat such invalid versions as strings (which is what PEP-508 suggests), but this leads to undesirable behavior in this case. For example, let's say you have a Python constraint of `>=3.9.1` and a local build of Python with a version `3.11.1+`. Using string comparisons would mean the constraint wouldn't be satisfied: >>> "3.9.1" < "3.11.1+" False So in the end, we just strip the trailing `+`, as was done in the days of old for [legacy version numbers][5]. I tested this fix by manually confirming that uv venv --python local/python failed before it and succeeded after it. Fixes #1357 [1]: #1357 [2]: python/cpython#99968 [3]: pypa/packaging#678 (comment) [4]: #1357 (comment) [5]: https://github.com/pypa/packaging/blob/085ff41692b687ae5b0772a55615b69a5b677be9/packaging/version.py#L168-L193
It was reported that a locally-built Python with
3.11.4+
errors out in our version parser:https://gist.github.com/jsbueno/be1797cfe654c69245ddbea78e0360ff
The text was updated successfully, but these errors were encountered: