python-utils-r1.eclass: Make python_optimize fail if -x $PYTHON

Make python_optimize() fail if the expected Python interpreter is not
executable.  Since some errors are expected during Python
byte-compilation (e.g. CPython includes test .py modules with syntax
errors), we can't rely on compileall result.  However, this will catch
at least the very bad mistake of wrong ${PYTHON} that affects e.g.
dev-python/pypy*.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny
2020-09-17 15:57:52 +02:00
parent b0c1e014da
commit f58ec7afec

View File

@@ -608,6 +608,7 @@ python_optimize() {
local PYTHON=${PYTHON}
[[ ${PYTHON} ]] || _python_export PYTHON
[[ -x ${PYTHON} ]] || die "PYTHON (${PYTHON}) is not executable"
# default to sys.path
if [[ ${#} -eq 0 ]]; then