pw_env_setup: Support Python 3.9
Currently there is no way to configure environment checks in
pw_env_setup, and often these checks are diagnosting downstream
adjustments rather than errors. Loosen up these checks to at least
permit Python 3.9, which is the default now in some distros.
Change-Id: Ibb99acdef7f98e7b327ac9ee49e52c0a83bdb0fc
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/40362
Reviewed-by: Rob Mohr <mohrr@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
Commit-Queue: Michael Spang <spang@google.com>
diff --git a/pw_doctor/docs.rst b/pw_doctor/docs.rst
index 51087a5..1bd6578 100644
--- a/pw_doctor/docs.rst
+++ b/pw_doctor/docs.rst
@@ -7,5 +7,10 @@
it checks that things exactly match what is expected and it checks that things
look compatible without.
+Currently pw_doctor expects the running python to be Python 3.8 or 3.9.
+
+Projects that adjust the behavior of pw_env_setup may need to customize
+these checks, but unfortunately this is not supported yet.
+
.. note::
The documentation for this module is currently incomplete.
diff --git a/pw_doctor/py/pw_doctor/doctor.py b/pw_doctor/py/pw_doctor/doctor.py
index f2af518..16fb220 100755
--- a/pw_doctor/py/pw_doctor/doctor.py
+++ b/pw_doctor/py/pw_doctor/doctor.py
@@ -200,8 +200,9 @@
"""Check the Python version is correct."""
actual = sys.version_info
expected = (3, 8)
+ latest = (3, 9)
if (actual[0:2] < expected or actual[0] != expected[0]
- or actual[0:2] > expected):
+ or actual[0:2] > latest):
# If we get the wrong version but it still came from CIPD print a
# warning but give it a pass.
if 'chromium' in sys.version:
diff --git a/pw_env_setup/py/pw_env_setup/virtualenv_setup/install.py b/pw_env_setup/py/pw_env_setup/virtualenv_setup/install.py
index 9a227c8..d7134d4 100644
--- a/pw_env_setup/py/pw_env_setup/virtualenv_setup/install.py
+++ b/pw_env_setup/py/pw_env_setup/virtualenv_setup/install.py
@@ -130,7 +130,8 @@
version = subprocess.check_output(
(python, '--version'), stderr=subprocess.STDOUT).strip().decode()
# We expect Python 3.8, but if it came from CIPD let it pass anyway.
- if '3.8' not in version and 'chromium' not in version:
+ if ('3.8' not in version and '3.9' not in version
+ and 'chromium' not in version):
print('=' * 60, file=sys.stderr)
print('Unexpected Python version:', version, file=sys.stderr)
print('=' * 60, file=sys.stderr)