README: document Python version policy Bug: None Test: None Change-Id: I68d12dcb73d3aa8f3c0c6f77cfe2b19970912d65 Reviewed-on: https://android-review.googlesource.com/c/platform/tools/repohooks/+/3491631 Presubmit-Verified: Treehugger Robot <android-test-infra-workplan-finisher@system.gserviceaccount.com> Reviewed-by: Leandro Lovisolo <lovisolo@google.com> Autosubmit: Mike Frysinger <vapier@google.com> Performance: CrystalBall Performance Presubmit <android-crystalball-presubmit-eng@google.com> Open-Source-Licensing: Lint 🤖 <ayeaye-gerrit@google.com> Lint: Lint 🤖 <ayeaye-gerrit@google.com>
diff --git a/README.md b/README.md index 9747c5d..ec3c22e 100644 --- a/README.md +++ b/README.md
@@ -1,6 +1,6 @@ # AOSP Preupload Hooks -This repo holds hooks that get run by repo during the upload phase. They +This repo holds hooks that get run by [repo] during the upload phase. They perform various checks automatically such as running linters on your code. Note: Currently all hooks are disabled by default. Each repo must explicitly @@ -311,6 +311,14 @@ and exec-ed in its own context. The only entry-point that matters is `main`. * New hooks can be added in `rh/hooks.py`. Be sure to keep the list up-to-date with the documentation in this file. +* Python versions + * Code loaded & run by end users (i.e. during `repo upload`) should stick to + older versions of Python. We expect users to run on a variety of platforms + where Python is not the latest (e.g. Ubuntu LTS that is years behind). We + currently require **Python 3.6**. This aligns with [repo's supported Python + versions](https://gerrit.googlesource.com/git-repo/+/HEAD/docs/python-support.md). + * Code only run by repohooks developers may use much newer versions of Python + to keep things simple, especially as we don't readily test older versions. ## Warnings @@ -337,3 +345,5 @@ * Commit message checks (correct format/BUG/TEST/SOB tags/etc...). * Markdown (gitiles) validator. * Spell checker. + +[repo]: https://gerrit.googlesource.com/git-repo/
diff --git a/pre-upload.py b/pre-upload.py index 892389d..c852c29 100755 --- a/pre-upload.py +++ b/pre-upload.py
@@ -29,6 +29,7 @@ # Assert some minimum Python versions as we don't test or support any others. +# See README.md for what version we may require. if sys.version_info < (3, 6): print('repohooks: error: Python-3.6+ is required', file=sys.stderr) sys.exit(1)
diff --git a/tools/cpplint.py-update b/tools/cpplint.py-update index eadc2cb..8732a62 100755 --- a/tools/cpplint.py-update +++ b/tools/cpplint.py-update
@@ -22,6 +22,8 @@ import urllib.request +# Since this is manually run by repohooks developers, we can safely require more +# recent versions of Python. assert (sys.version_info.major, sys.version_info.minor) >= (3, 9), ( f"Python 3.9 or newer is required; found {sys.version}")
diff --git a/tools/pylint.py b/tools/pylint.py index dff0007..5462407 100755 --- a/tools/pylint.py +++ b/tools/pylint.py
@@ -24,6 +24,8 @@ from typing import Dict, List, Optional, Set +# This script is run by repohooks users. +# See README.md for what version we may require. assert (sys.version_info.major, sys.version_info.minor) >= (3, 6), ( f'Python 3.6 or newer is required; found {sys.version}')