Skip to content

Commit 6b44704

Browse files
authored
Check if python starts python3 (#6239)
Problem: dev_tools/pypath does not work when python command does not exist causing a failure in check/pytest (PYTHONPATH not set). Solution: Require that python starts Python 3. Bail out from the check scripts otherwise.
1 parent 95cb43f commit 6b44704

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed

check/doctest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ thisdir="$(dirname "${BASH_SOURCE[0]}")" || exit $?
1818
topdir="$(git -C "${thisdir}" rev-parse --show-toplevel)" || exit $?
1919
cd "${topdir}" || exit $?
2020

21-
source dev_tools/pypath
21+
source dev_tools/pypath || exit $?
2222

2323
python dev_tools/docs/run_doctest.py "$@"

check/pytest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cd "${topdir}" || exit $?
2020
# (the last `-n` option wins)
2121
PYTEST_ARGS=( "-n=auto" "$@" )
2222

23-
source dev_tools/pypath
23+
source dev_tools/pypath || exit $?
2424

2525
pytest "${PYTEST_ARGS[@]}"
2626
RESULT=$?

check/pytest-and-incremental-coverage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ else
6868
rev="${base}"
6969
fi
7070

71-
source dev_tools/pypath
71+
source dev_tools/pypath || exit $?
7272

7373
# Run tests while producing coverage files.
7474
check/pytest --cov \

check/pytest-changed-files

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ if [ "${num_changed}" -eq 0 ]; then
7676
exit 0
7777
fi
7878

79-
source dev_tools/pypath
79+
source dev_tools/pypath || exit $?
8080

8181
pytest "${rest[@]}" "${changed[@]}"

check/pytest-changed-files-and-incremental-coverage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ if [ "${#changed_python_tests[@]}" -eq 0 ]; then
8787
exit 0
8888
fi
8989

90-
source dev_tools/pypath
90+
source dev_tools/pypath || exit $?
9191

9292
# Run tests while producing coverage files.
9393
check/pytest "${changed_python_tests[@]}" \

dev_tools/pypath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ else
2929
_PYPATH_BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
3030
fi
3131

32+
if ! python --version | grep -q -F "Python 3."; then
33+
echo "python command does not start Python 3" >&2
34+
echo "Please use a virtual environment created for Python 3." >&2
35+
return 2
36+
fi
37+
3238
_PYPATH_PREFIX="${_PYPATH_BASE_DIR}$(
3339
cd "${_PYPATH_BASE_DIR}" &&
3440
env PYTHONPATH=. python dev_tools/modules.py list --mode folder |

0 commit comments

Comments
 (0)