# HG changeset patch # Parent a2bfec367cefdee19ec8a47311baa3eac1b410b1 Issue #28143: Find a python2 command or use PYTHON_FOR_GEN to run scripts Configure now searches for commands called python2.7, python2, and python, and sets PYTHON_FOR_GEN to the result. PYTHON_FOR_GEN can be overridden by the user if desired. If no Python command is found, the build fails with an error message. diff -r a2bfec367cef Makefile.pre.in --- a/Makefile.pre.in Sat Sep 17 07:54:55 2016 +0000 +++ b/Makefile.pre.in Sun Sep 18 00:49:43 2016 +0000 @@ -200,6 +200,7 @@ PYTHON= python$(EXE) BUILDPYTHON= python$(BUILDEXE) +PYTHON_FOR_GEN=@PYTHON_FOR_GEN@ PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@ _PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@ HOST_GNU_TYPE= @host@ @@ -306,8 +307,9 @@ AST_ASDL= $(srcdir)/Parser/Python.asdl ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py -# XXX Note that a build now requires Python exist before the build starts -ASDLGEN= $(srcdir)/Parser/asdl_c.py +# Note that a build now requires Python to exist before the build starts. +# Use "make touch" to fix up screwed up file mtimes in a checkout. +ASDLGEN= $(PYTHON_FOR_GEN) $(srcdir)/Parser/asdl_c.py ########################################################################## # Python @@ -741,7 +743,7 @@ $(STRINGLIB_HEADERS) $(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES) - $(OPCODETARGETGEN) $(OPCODETARGETS_H) + $(PYTHON_FOR_GEN) $(OPCODETARGETGEN) $(OPCODETARGETS_H) Python/ceval.o: $(OPCODETARGETS_H) diff -r a2bfec367cef Misc/NEWS --- a/Misc/NEWS Sat Sep 17 07:54:55 2016 +0000 +++ b/Misc/NEWS Sun Sep 18 00:49:43 2016 +0000 @@ -186,6 +186,9 @@ Build ----- +- Issue #28143: Try to find a python2 command or use PYTHON_FOR_GEN to run + scripts like Parser/asdl_c.py that regenerate files to bootstrap the build. + - Issue #15819: The Include directory in the build tree is already searched; drop unused code trying to add it again. diff -r a2bfec367cef configure --- a/configure Sat Sep 17 07:54:55 2016 +0000 +++ b/configure Sun Sep 18 00:49:43 2016 +0000 @@ -743,6 +743,7 @@ VERSION GENERATED_COMMENT PYTHON_FOR_BUILD +PYTHON_FOR_GEN host_os host_vendor host_cpu @@ -2915,6 +2916,56 @@ # pybuilddir.txt will be created by --generate-posix-vars in the Makefile rm -f pybuilddir.txt +for ac_prog in python$PACKAGE_VERSION python2 python +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_PYTHON_FOR_GEN+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PYTHON_FOR_GEN"; then + ac_cv_prog_PYTHON_FOR_GEN="$PYTHON_FOR_GEN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_PYTHON_FOR_GEN="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PYTHON_FOR_GEN=$ac_cv_prog_PYTHON_FOR_GEN +if test -n "$PYTHON_FOR_GEN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_FOR_GEN" >&5 +$as_echo "$PYTHON_FOR_GEN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$PYTHON_FOR_GEN" && break +done +test -n "$PYTHON_FOR_GEN" || PYTHON_FOR_GEN="not-found" + +if test "$PYTHON_FOR_GEN" = not-found; then + PYTHON_FOR_GEN='@echo "Cannot generate $@, python not found !" && \ + echo "To skip re-generation of $@ run or ." && \ + echo "Otherwise, set python in PATH and run configure or run ." && false &&' +fi + + if test "$cross_compiling" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python interpreter for cross build" >&5 $as_echo_n "checking for python interpreter for cross build... " >&6; } diff -r a2bfec367cef configure.ac --- a/configure.ac Sat Sep 17 07:54:55 2016 +0000 +++ b/configure.ac Sun Sep 18 00:49:43 2016 +0000 @@ -19,6 +19,14 @@ # pybuilddir.txt will be created by --generate-posix-vars in the Makefile rm -f pybuilddir.txt +AC_CHECK_PROGS(PYTHON_FOR_GEN, python$PACKAGE_VERSION python2 python, not-found) +if test "$PYTHON_FOR_GEN" = not-found; then + PYTHON_FOR_GEN='@echo "Cannot generate $@, python not found !" && \ + echo "To skip re-generation of $@ run or ." && \ + echo "Otherwise, set python in PATH and run configure or run ." && false &&' +fi +AC_SUBST(PYTHON_FOR_GEN) + if test "$cross_compiling" = yes; then AC_MSG_CHECKING([for python interpreter for cross build]) if test -z "$PYTHON_FOR_BUILD"; then