Skip to content

Commit

Permalink
autogen.sh: do not call python just assuming it exists.
Browse files Browse the repository at this point in the history
On GIMP CI for instance, even though Python 3 was installed in the build
environment, apparently `python` didn't exist in path, hence failing to
create mypaint-brush-settings-gen.h:
> ./autogen.sh: line 238: python: command not found

Instead let's try out several python common binary names (giving
preference to system default `python`, then Python 3, finally Python 2).

Also bad was that the Python error was not fatal, which lead to the
build starting and ultimately failing with:

> ../mypaint-brush-settings.h:22:10: fatal error: mypaint-brush-settings-gen.h: No such file or directory

Therefore make the autogen.sh fail when we fail to run `generate.py`.

(cherry picked from commit 85c1af8)
  • Loading branch information
Jehan committed Apr 13, 2020
1 parent d17189b commit 87e22a5
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ AUTOCONF=${AUTOCONF-autoconf}
AUTOHEADER=${AUTOHEADER-autoheader}
AUTOMAKE=${AUTOMAKE-automake-1.16}
LIBTOOLIZE=${LIBTOOLIZE-libtoolize}
PYTHON=${PYTHON-python}

AUTOCONF_REQUIRED_VERSION=2.62
AUTOMAKE_REQUIRED_VERSION=1.13
Expand Down Expand Up @@ -169,6 +170,29 @@ else
DIE=1
fi

printf "checking for python ... "
if ($PYTHON --version) < /dev/null > /dev/null 2>&1; then
PYTHON=$PYTHON
elif (python3 --version) < /dev/null > /dev/null 2>&1; then
PYTHON=python3
elif (python3.8 --version) < /dev/null > /dev/null 2>&1; then
PYTHON=python3.8
elif (python3.7 --version) < /dev/null > /dev/null 2>&1; then
PYTHON=python3.7
elif (python2 --version) < /dev/null > /dev/null 2>&1; then
PYTHON=python2
elif (python2.7 --version) < /dev/null > /dev/null 2>&1; then
PYTHON=python2.7
else
echo
echo " You must have python (any version) installed to compile $PROJECT."
echo " Download the appropriate package for your distribution,"
echo " or get the source tarball at https://www.python.org/"
echo
DIE=1;
fi
echo "yes ($PYTHON)"

if test "$DIE" -eq 1; then
echo
echo "Please install/upgrade the missing tools and call me again."
Expand Down Expand Up @@ -235,7 +259,7 @@ $LIBTOOLIZE --force || exit $?
# configure script. The internal-only brushsettings-gen.h is also used
# as the source of strings for gettext.

python generate.py mypaint-brush-settings-gen.h brushsettings-gen.h
$PYTHON generate.py mypaint-brush-settings-gen.h brushsettings-gen.h || exit $?

# The MyPaint code no longer needs the .json file at runtime, and it is
# not installed as data.
Expand Down

0 comments on commit 87e22a5

Please sign in to comment.