[Python-checkins] cpython (3.5): Issue #26662: Set PYTHON_FOR_GEN in configure

xavier.degaye python-checkins at python.org
Tue Jul 26 06:56:32 EDT 2016


https://hg.python.org/cpython/rev/5aff28f33b2a
changeset: 102455:5aff28f33b2a
branch: 3.5
parent: 102453:3996dd17ca21
user: Xavier de Gaye <xdegaye at users.sourceforge.net>
date: Tue Jul 26 12:48:08 2016 +0200
summary:
 Issue #26662: Set PYTHON_FOR_GEN in configure
as the Python program to be used for file generation during the build.
files:
 Makefile.pre.in | 9 +-
 Misc/NEWS | 6 +
 Objects/typeslots.py | 63 ++++++----
 configure | 169 +++++++++---------------------
 configure.ac | 25 +---
 5 files changed, 108 insertions(+), 164 deletions(-)
diff --git a/Makefile.pre.in b/Makefile.pre.in
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -222,6 +222,7 @@
 BUILDPYTHON=	python$(BUILDEXE)
 
 cross_compiling=@cross_compiling@
+PYTHON_FOR_GEN=@PYTHON_FOR_GEN@
 PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
 _PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
 BUILD_GNU_TYPE=	@build@
@@ -339,7 +340,7 @@
 OPCODE_H_DIR= 	$(srcdir)/Include
 OPCODE_H_SCRIPT= $(srcdir)/Tools/scripts/generate_opcode_h.py
 OPCODE_H=	$(OPCODE_H_DIR)/opcode.h
-OPCODE_H_GEN=	@OPCODEHGEN@ $(OPCODE_H_SCRIPT) $(srcdir)/Lib/opcode.py $(OPCODE_H)
+OPCODE_H_GEN=	$(PYTHON_FOR_GEN) $(OPCODE_H_SCRIPT) $(srcdir)/Lib/opcode.py $(OPCODE_H)
 #
 ##########################################################################
 # AST
@@ -352,7 +353,7 @@
 ASDLGEN_FILES=	$(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
 # Note that a build now requires Python to exist before the build starts.
 # Use "hg touch" to fix up screwed up file mtimes in a checkout.
-ASDLGEN=	@ASDLGEN@ $(srcdir)/Parser/asdl_c.py
+ASDLGEN=	$(PYTHON_FOR_GEN) $(srcdir)/Parser/asdl_c.py
 
 ##########################################################################
 # Python
@@ -880,7 +881,7 @@
 Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h
 
 $(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES)
-	$(OPCODETARGETGEN) $(OPCODETARGETS_H)
+	$(PYTHON_FOR_GEN) $(OPCODETARGETGEN) $(OPCODETARGETS_H)
 
 Python/ceval.o: $(OPCODETARGETS_H) $(srcdir)/Python/ceval_gil.h
 
@@ -888,7 +889,7 @@
 
 Objects/typeobject.o: Objects/typeslots.inc
 Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
-	$(PYTHON) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h > Objects/typeslots.inc
+	$(PYTHON_FOR_GEN) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h Objects/typeslots.inc
 
 ############################################################################
 # Header files
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -142,6 +142,12 @@
 
 - Issue #27309: Enabled proper Windows styles in python[w].exe manifest.
 
+Build
+-----
+
+- Issue #26662: Set PYTHON_FOR_GEN in configure as the Python program to be
+ used for file generation during the build.
+
 What's New in Python 3.5.2?
 ===========================
 
diff --git a/Objects/typeslots.py b/Objects/typeslots.py
--- a/Objects/typeslots.py
+++ b/Objects/typeslots.py
@@ -1,32 +1,43 @@
 #!/usr/bin/python
-# Usage: typeslots.py < Include/typeslots.h > typeslots.inc
+# Usage: typeslots.py < Include/typeslots.h typeslots.inc
 
 import sys, re
 
-print("/* Generated by typeslots.py */")
-res = {}
-for line in sys.stdin:
- m = re.match("#define Py_([a-z_]+) ([0-9]+)", line)
- if not m:
- continue
- member = m.group(1)
- if member.startswith("tp_"):
- member = "ht_type."+member
- elif member.startswith("am_"):
- member = "as_async."+member
- elif member.startswith("nb_"):
- member = "as_number."+member
- elif member.startswith("mp_"):
- member = "as_mapping."+member
- elif member.startswith("sq_"):
- member = "as_sequence."+member
- elif member.startswith("bf_"):
- member = "as_buffer."+member
- res[int(m.group(2))] = member
+def generate_typeslots(out=sys.stdout):
+ out.write("/* Generated by typeslots.py */\n")
+ res = {}
+ for line in sys.stdin:
+ m = re.match("#define Py_([a-z_]+) ([0-9]+)", line)
+ if not m:
+ continue
+ member = m.group(1)
+ if member.startswith("tp_"):
+ member = "ht_type."+member
+ elif member.startswith("am_"):
+ member = "as_async."+member
+ elif member.startswith("nb_"):
+ member = "as_number."+member
+ elif member.startswith("mp_"):
+ member = "as_mapping."+member
+ elif member.startswith("sq_"):
+ member = "as_sequence."+member
+ elif member.startswith("bf_"):
+ member = "as_buffer."+member
+ res[int(m.group(2))] = member
 
-M = max(res.keys())+1
-for i in range(1,M):
- if i in res:
- print("offsetof(PyHeapTypeObject, %s)," % res[i])
+ M = max(res.keys())+1
+ for i in range(1,M):
+ if i in res:
+ out.write("offsetof(PyHeapTypeObject, %s),\n" % res[i])
+ else:
+ out.write("0,\n")
+
+def main():
+ if len(sys.argv) == 2:
+ with open(sys.argv[1], "w") as f:
+ generate_typeslots(f)
 else:
- print("0,")
+ generate_typeslots()
+
+if __name__ == "__main__":
+ main()
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -680,9 +680,6 @@
 INSTALL_DATA
 INSTALL_SCRIPT
 INSTALL_PROGRAM
-OPCODEHGEN
-PYTHON
-ASDLGEN
 ac_ct_READELF
 READELF
 ARFLAGS
@@ -743,6 +740,7 @@
 SOVERSION
 VERSION
 PYTHON_FOR_BUILD
+PYTHON_FOR_GEN
 host_os
 host_vendor
 host_cpu
@@ -776,7 +774,6 @@
 docdir
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -887,7 +884,6 @@
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1140,15 +1136,6 @@
 | -silent | --silent | --silen | --sile | --sil)
 silent=yes ;;
 
- -runstatedir | --runstatedir | --runstatedi | --runstated \
- | --runstate | --runstat | --runsta | --runst | --runs \
- | --run | --ru | --r)
- ac_prev=runstatedir ;;
- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
- | --run=* | --ru=* | --r=*)
- runstatedir=$ac_optarg ;;
-
 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
 ac_prev=sbindir ;;
 -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1286,7 +1273,7 @@
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
 eval ac_val=\$$ac_var
 # Remove trailing slashes.
@@ -1439,7 +1426,6 @@
 --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
 --localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
 --libdir=DIR object code libraries [EPREFIX/lib]
 --includedir=DIR C header files [PREFIX/include]
 --oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -2995,6 +2981,56 @@
 # pybuilddir.txt will be created by --generate-posix-vars in the Makefile
 rm -f pybuilddir.txt
 
+for ac_prog in python$PACKAGE_VERSION python3 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 <make touch> or <make -t $@>." && \
+ echo "Otherwise, set python in PATH and run configure or run <make PYTHON_FOR_GEN=python>." && 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; }
@@ -6295,107 +6331,6 @@
 
 
 
-for ac_prog in python$PACKAGE_VERSION python3 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+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$PYTHON"; then
- ac_cv_prog_PYTHON="$PYTHON" # 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="$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=$ac_cv_prog_PYTHON
-if test -n "$PYTHON"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
-$as_echo "$PYTHON" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$PYTHON" && break
-done
-test -n "$PYTHON" || PYTHON="not-found"
-
-if test "$PYTHON" = not-found; then
- ASDLGEN="@echo python: $PYTHON! cannot run \$(srcdir)/Parser/asdl_c.py #"
-else
- ASDLGEN="$PYTHON"
-fi
-
-
-for ac_prog in python$PACKAGE_VERSION python3 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+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$PYTHON"; then
- ac_cv_prog_PYTHON="$PYTHON" # 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="$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=$ac_cv_prog_PYTHON
-if test -n "$PYTHON"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
-$as_echo "$PYTHON" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$PYTHON" && break
-done
-test -n "$PYTHON" || PYTHON="not-found"
-
-if test "$PYTHON" = not-found; then
- OPCODEHGEN="@echo python: $PYTHON! cannot run Tools/scripts/generate_opcode_h.py"
-else
- OPCODEHGEN="$PYTHON"
-fi
-
-
-
 case $MACHDEP in
 bsdos*|hp*|HP*)
 	# install -d does not work on BSDI or HP-UX
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,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 python3 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 <make touch> or <make -t $@>." && \
+ echo "Otherwise, set python in PATH and run configure or run <make PYTHON_FOR_GEN=python>." && 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
@@ -1178,23 +1186,6 @@
 fi
 AC_SUBST(READELF)
 
-AC_SUBST(ASDLGEN)
-AC_CHECK_PROGS(PYTHON, python$PACKAGE_VERSION python3 python, not-found)
-if test "$PYTHON" = not-found; then
- ASDLGEN="@echo python: $PYTHON! cannot run \$(srcdir)/Parser/asdl_c.py #"
-else
- ASDLGEN="$PYTHON"
-fi
-
-AC_SUBST(OPCODEHGEN)
-AC_CHECK_PROGS(PYTHON, python$PACKAGE_VERSION python3 python, not-found)
-if test "$PYTHON" = not-found; then
- OPCODEHGEN="@echo python: $PYTHON! cannot run Tools/scripts/generate_opcode_h.py"
-else
- OPCODEHGEN="$PYTHON"
-fi
-
-
 
 case $MACHDEP in
 bsdos*|hp*|HP*)
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /