Skip to content
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

build: relax upper limit on python version check #48136

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,29 @@ exec python "$0" "$@"
]
del _

from sys import stderr
import sys
try:
from shutil import which
except ImportError:
from distutils.spawn import find_executable as which

print('Node.js configure: Found Python {}.{}.{}...'.format(*sys.version_info))
acceptable_pythons = ((3, 11), (3, 10), (3, 9), (3, 8), (3, 7), (3, 6))
if sys.version_info[:2] in acceptable_pythons:
major, minor, patch = sys.version_info[:3]
print('Node.js configure: Found Python {}.{}.{}...'.format(major, minor, patch))
if major > 3 or major == 3 and minor >= 6:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if major > 3 or major == 3 and minor >= 6:
if sys.version_info >= (3, 8):

https://devguide.python.org/versions/#versions

import configure
else:
python_cmds = ['python{}.{}'.format(*vers) for vers in acceptable_pythons]
sys.stderr.write('Please use {}.\n'.format(' or '.join(python_cmds)))
for python_cmd in python_cmds:
python_cmd_path = which(python_cmd)
found = []
# TODO(bnoordhuis) update when python 4 is released (ETA: never)
for minor in range(6, 42):
python_cmd_path = which('python3.{}'.format(minor))
if python_cmd_path and 'pyenv/shims' not in python_cmd_path:
sys.stderr.write('\t{} {}\n'.format(python_cmd_path, ' '.join(sys.argv[:1])))
found.append(python_cmd_path)
if found:
args = ' '.join(sys.argv[:1])
stderr.write('No suitable python install found, use one of:\n')
for python_cmd_path in found:
stderr.write('\t{} {}\n'.format(python_cmd_path, args))
else:
stderr.write('No suitable python install found, need python >= 3.6\n')
sys.exit(1)