-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix python version parsing for deadsnakes python versions #7462
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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