From 35f0bb95a7632430bac87dc97bad6b32481933a5 Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Fri, 11 Aug 2023 13:57:56 -0700 Subject: [PATCH 1/2] dev_tools/pypath - verify `python` runs Python 3 --- dev_tools/pypath | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dev_tools/pypath b/dev_tools/pypath index 807b1d32aab..37461620b4c 100755 --- a/dev_tools/pypath +++ b/dev_tools/pypath @@ -29,6 +29,12 @@ else _PYPATH_BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" fi +if ! python --version | grep -q -F "Python 3."; then + echo "python command does not start Python 3" >&2 + echo "Please use a virtual environment created for Python 3." >&2 + return 2 +fi + _PYPATH_PREFIX="${_PYPATH_BASE_DIR}$( cd "${_PYPATH_BASE_DIR}" && env PYTHONPATH=. python dev_tools/modules.py list --mode folder | From 1c1de77d4fe3726098a3abb8ac3f8bb264ce7cfc Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Fri, 11 Aug 2023 14:04:18 -0700 Subject: [PATCH 2/2] Exit check-scripts on error in dev_tools/pypath This bails out when `python` command does not exist or does not start Python 3. --- check/doctest | 2 +- check/pytest | 2 +- check/pytest-and-incremental-coverage | 2 +- check/pytest-changed-files | 2 +- check/pytest-changed-files-and-incremental-coverage | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/check/doctest b/check/doctest index a26b6cff433..5f3497b9d9a 100755 --- a/check/doctest +++ b/check/doctest @@ -18,6 +18,6 @@ thisdir="$(dirname "${BASH_SOURCE[0]}")" || exit $? topdir="$(git -C "${thisdir}" rev-parse --show-toplevel)" || exit $? cd "${topdir}" || exit $? -source dev_tools/pypath +source dev_tools/pypath || exit $? python dev_tools/docs/run_doctest.py "$@" diff --git a/check/pytest b/check/pytest index 72c439b4ec3..fd8ddf739a2 100755 --- a/check/pytest +++ b/check/pytest @@ -20,7 +20,7 @@ cd "${topdir}" || exit $? # (the last `-n` option wins) PYTEST_ARGS=( "-n=auto" "$@" ) -source dev_tools/pypath +source dev_tools/pypath || exit $? pytest "${PYTEST_ARGS[@]}" RESULT=$? diff --git a/check/pytest-and-incremental-coverage b/check/pytest-and-incremental-coverage index 9fa1c2b8eb7..a81cefdab31 100755 --- a/check/pytest-and-incremental-coverage +++ b/check/pytest-and-incremental-coverage @@ -68,7 +68,7 @@ else rev="${base}" fi -source dev_tools/pypath +source dev_tools/pypath || exit $? # Run tests while producing coverage files. check/pytest --cov \ diff --git a/check/pytest-changed-files b/check/pytest-changed-files index df89599ebba..7dc9dd4acf3 100755 --- a/check/pytest-changed-files +++ b/check/pytest-changed-files @@ -76,6 +76,6 @@ if [ "${num_changed}" -eq 0 ]; then exit 0 fi -source dev_tools/pypath +source dev_tools/pypath || exit $? pytest "${rest[@]}" "${changed[@]}" diff --git a/check/pytest-changed-files-and-incremental-coverage b/check/pytest-changed-files-and-incremental-coverage index 56fa26a6cc4..6b72ab2934a 100755 --- a/check/pytest-changed-files-and-incremental-coverage +++ b/check/pytest-changed-files-and-incremental-coverage @@ -87,7 +87,7 @@ if [ "${#changed_python_tests[@]}" -eq 0 ]; then exit 0 fi -source dev_tools/pypath +source dev_tools/pypath || exit $? # Run tests while producing coverage files. check/pytest "${changed_python_tests[@]}" \