Fix python version parsing for deadsnakes python versions#7462
Fix python version parsing for deadsnakes python versions#7462GeorgeSaussy wants to merge 2 commits intopython-poetry:mainfrom
Conversation
| primary_version_regex = "\\d+\\.([a-zA-Z\\d]+(\\.[a-zA-Z\\d]+)*)" | ||
| local_segment_regex = "(\\+([a-zA-Z\\d]+(\\.[a-zA-Z\\d]+)*)?)?$" | ||
| pep_440_and_deadsnakes_regex = f"^{primary_version_regex}{local_segment_regex}$" | ||
| match = re.compile(pep_440_and_deadsnakes_regex).match( | ||
| platform.python_version() | ||
| ) | ||
| if match is None: | ||
| raise ValueError("Python version must be PEP 440 compatible.") | ||
| clean_python_version = match.group() | ||
| clean_python_version = clean_python_version.rstrip("+") | ||
|
|
There was a problem hiding this comment.
That feels a little over the top to me. I'd keep it simple and just strip the trailing plus. Afterwards, validation can be done via poetry.core.constraints.version.Version.parse() instead of the regexes.
I'm a bit torn if it's even necessary to validate the version here, since we parse it later anyway and already fail with a quite good message as can be seen in #6925 (comment). Of course, the message could be improved to say that the invalid version is the python version.
|
drive by comment: This makes it sound like it is specific to deadsnakes, but it's the normal version scheme used for Python built from git, and not deadsnakes specific. |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR will allows poetry to a single trailing "+" character at the end of a PEP 440 compatible Python version string. This will allow Poetry to handle the nightly builds from CPython.
Note: The version string must be either exactly compatible with PEP 440 or it must be compatible except for a trailing "+" character while also not having a local version segment.
Resolves: #233