python: allow versions with garbage suffix (#29543)

* python: allow versions with garbage suffix

Ubuntu 22.04 preview python prints version as 3.10.2+, the + causes
version parsing to fail and breaks detection.

* Add version comment

* match VALID_VERSION regex
This commit is contained in:
Tom Scogland 2022-03-17 02:54:29 -07:00 committed by GitHub
parent 4ef534b19b
commit 3648adc2a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -271,8 +271,10 @@ def determine_version(cls, exe):
# Python 2 sends to STDERR, while Python 3 sends to STDOUT
# Output looks like:
# Python 3.7.7
# On pre-production Ubuntu, this is also possible:
# Python 3.10.2+
output = Executable(exe)('-V', output=str, error=str)
match = re.search(r'Python\s+(\S+)', output)
match = re.search(r'Python\s+([A-Za-z0-9_.-]+)', output)
return match.group(1) if match else None
@classmethod