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:
parent
4ef534b19b
commit
3648adc2a7
1 changed files with 3 additions and 1 deletions
|
@ -271,8 +271,10 @@ def determine_version(cls, exe):
|
||||||
# Python 2 sends to STDERR, while Python 3 sends to STDOUT
|
# Python 2 sends to STDERR, while Python 3 sends to STDOUT
|
||||||
# Output looks like:
|
# Output looks like:
|
||||||
# Python 3.7.7
|
# Python 3.7.7
|
||||||
|
# On pre-production Ubuntu, this is also possible:
|
||||||
|
# Python 3.10.2+
|
||||||
output = Executable(exe)('-V', output=str, error=str)
|
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
|
return match.group(1) if match else None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in a new issue