Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8d49896

Browse files
author
Xavier de Gaye
committed
(merge from 3.5) Issue #26662: Set PYTHON_FOR_GEN in configure
as the Python program to be used for file generation during the build.
2 parents c75885b + fd0d593 commit 8d49896

5 files changed

Lines changed: 108 additions & 164 deletions

File tree

Makefile.pre.in

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ PYTHON= python$(EXE)
223223
BUILDPYTHON= python$(BUILDEXE)
224224

225225
cross_compiling=@cross_compiling@
226+
PYTHON_FOR_GEN=@PYTHON_FOR_GEN@
226227
PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
227228
_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
228229
BUILD_GNU_TYPE= @build@
@@ -340,7 +341,7 @@ PGENOBJS= $(POBJS) $(PGOBJS)
340341
OPCODE_H_DIR= $(srcdir)/Include
341342
OPCODE_H_SCRIPT= $(srcdir)/Tools/scripts/generate_opcode_h.py
342343
OPCODE_H= $(OPCODE_H_DIR)/opcode.h
343-
OPCODE_H_GEN= @OPCODEHGEN@ $(OPCODE_H_SCRIPT) $(srcdir)/Lib/opcode.py $(OPCODE_H)
344+
OPCODE_H_GEN= $(PYTHON_FOR_GEN) $(OPCODE_H_SCRIPT) $(srcdir)/Lib/opcode.py $(OPCODE_H)
344345
#
345346
##########################################################################
346347
# AST
@@ -353,7 +354,7 @@ AST_ASDL= $(srcdir)/Parser/Python.asdl
353354
ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
354355
# Note that a build now requires Python to exist before the build starts.
355356
# Use "hg touch" to fix up screwed up file mtimes in a checkout.
356-
ASDLGEN= @ASDLGEN@ $(srcdir)/Parser/asdl_c.py
357+
ASDLGEN= $(PYTHON_FOR_GEN) $(srcdir)/Parser/asdl_c.py
357358

358359
##########################################################################
359360
# Python
@@ -882,15 +883,15 @@ Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h
882883
Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h
883884

884885
$(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES)
885-
$(OPCODETARGETGEN) $(OPCODETARGETS_H)
886+
$(PYTHON_FOR_GEN) $(OPCODETARGETGEN) $(OPCODETARGETS_H)
886887

887888
Python/ceval.o: $(OPCODETARGETS_H) $(srcdir)/Python/ceval_gil.h
888889

889890
Python/frozen.o: Python/importlib.h Python/importlib_external.h
890891

891892
Objects/typeobject.o: Objects/typeslots.inc
892893
Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
893-
$(PYTHON) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h > Objects/typeslots.inc
894+
$(PYTHON_FOR_GEN) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h Objects/typeslots.inc
894895

895896
############################################################################
896897
# Header files

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ Windows
7777

7878
- Issue #27309: Enables proper Windows styles in python[w].exe manifest.
7979

80+
Build
81+
-----
82+
83+
- Issue #26662: Set PYTHON_FOR_GEN in configure as the Python program to be
84+
used for file generation during the build.
85+
8086
What's New in Python 3.6.0 alpha 3
8187
==================================
8288

Objects/typeslots.py

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,43 @@
11
#!/usr/bin/python
2-
# Usage: typeslots.py < Include/typeslots.h > typeslots.inc
2+
# Usage: typeslots.py < Include/typeslots.h typeslots.inc
33

44
import sys, re
55

6-
print("/* Generated by typeslots.py */")
7-
res = {}
8-
for line in sys.stdin:
9-
m = re.match("#define Py_([a-z_]+) ([0-9]+)", line)
10-
if not m:
11-
continue
12-
member = m.group(1)
13-
if member.startswith("tp_"):
14-
member = "ht_type."+member
15-
elif member.startswith("am_"):
16-
member = "as_async."+member
17-
elif member.startswith("nb_"):
18-
member = "as_number."+member
19-
elif member.startswith("mp_"):
20-
member = "as_mapping."+member
21-
elif member.startswith("sq_"):
22-
member = "as_sequence."+member
23-
elif member.startswith("bf_"):
24-
member = "as_buffer."+member
25-
res[int(m.group(2))] = member
6+
def generate_typeslots(out=sys.stdout):
7+
out.write("/* Generated by typeslots.py */\n")
8+
res = {}
9+
for line in sys.stdin:
10+
m = re.match("#define Py_([a-z_]+) ([0-9]+)", line)
11+
if not m:
12+
continue
13+
member = m.group(1)
14+
if member.startswith("tp_"):
15+
member = "ht_type."+member
16+
elif member.startswith("am_"):
17+
member = "as_async."+member
18+
elif member.startswith("nb_"):
19+
member = "as_number."+member
20+
elif member.startswith("mp_"):
21+
member = "as_mapping."+member
22+
elif member.startswith("sq_"):
23+
member = "as_sequence."+member
24+
elif member.startswith("bf_"):
25+
member = "as_buffer."+member
26+
res[int(m.group(2))] = member
2627

27-
M = max(res.keys())+1
28-
for i in range(1,M):
29-
if i in res:
30-
print("offsetof(PyHeapTypeObject, %s)," % res[i])
28+
M = max(res.keys())+1
29+
for i in range(1,M):
30+
if i in res:
31+
out.write("offsetof(PyHeapTypeObject, %s),\n" % res[i])
32+
else:
33+
out.write("0,\n")
34+
35+
def main():
36+
if len(sys.argv) == 2:
37+
with open(sys.argv[1], "w") as f:
38+
generate_typeslots(f)
3139
else:
32-
print("0,")
40+
generate_typeslots()
41+
42+
if __name__ == "__main__":
43+
main()

configure

Lines changed: 52 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,6 @@ MKDIR_P
680680
INSTALL_DATA
681681
INSTALL_SCRIPT
682682
INSTALL_PROGRAM
683-
OPCODEHGEN
684-
PYTHON
685-
ASDLGEN
686683
ac_ct_READELF
687684
READELF
688685
ARFLAGS
@@ -744,6 +741,7 @@ CONFIG_ARGS
744741
SOVERSION
745742
VERSION
746743
PYTHON_FOR_BUILD
744+
PYTHON_FOR_GEN
747745
host_os
748746
host_vendor
749747
host_cpu
@@ -777,7 +775,6 @@ infodir
777775
docdir
778776
oldincludedir
779777
includedir
780-
runstatedir
781778
localstatedir
782779
sharedstatedir
783780
sysconfdir
@@ -888,7 +885,6 @@ datadir='${datarootdir}'
888885
sysconfdir='${prefix}/etc'
889886
sharedstatedir='${prefix}/com'
890887
localstatedir='${prefix}/var'
891-
runstatedir='${localstatedir}/run'
892888
includedir='${prefix}/include'
893889
oldincludedir='/usr/include'
894890
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1141,15 +1137,6 @@ do
11411137
| -silent | --silent | --silen | --sile | --sil)
11421138
silent=yes ;;
11431139

1144-
-runstatedir | --runstatedir | --runstatedi | --runstated \
1145-
| --runstate | --runstat | --runsta | --runst | --runs \
1146-
| --run | --ru | --r)
1147-
ac_prev=runstatedir ;;
1148-
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
1149-
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
1150-
| --run=* | --ru=* | --r=*)
1151-
runstatedir=$ac_optarg ;;
1152-
11531140
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
11541141
ac_prev=sbindir ;;
11551142
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1287,7 +1274,7 @@ fi
12871274
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
12881275
datadir sysconfdir sharedstatedir localstatedir includedir \
12891276
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
1290-
libdir localedir mandir runstatedir
1277+
libdir localedir mandir
12911278
do
12921279
eval ac_val=\$$ac_var
12931280
# Remove trailing slashes.
@@ -1440,7 +1427,6 @@ Fine tuning of the installation directories:
14401427
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
14411428
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
14421429
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
1443-
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
14441430
--libdir=DIR object code libraries [EPREFIX/lib]
14451431
--includedir=DIR C header files [PREFIX/include]
14461432
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -2996,6 +2982,56 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
29962982
# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
29972983
rm -f pybuilddir.txt
29982984

2985+
for ac_prog in python$PACKAGE_VERSION python3 python
2986+
do
2987+
# Extract the first word of "$ac_prog", so it can be a program name with args.
2988+
set dummy $ac_prog; ac_word=$2
2989+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2990+
$as_echo_n "checking for $ac_word... " >&6; }
2991+
if ${ac_cv_prog_PYTHON_FOR_GEN+:} false; then :
2992+
$as_echo_n "(cached) " >&6
2993+
else
2994+
if test -n "$PYTHON_FOR_GEN"; then
2995+
ac_cv_prog_PYTHON_FOR_GEN="$PYTHON_FOR_GEN" # Let the user override the test.
2996+
else
2997+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2998+
for as_dir in $PATH
2999+
do
3000+
IFS=$as_save_IFS
3001+
test -z "$as_dir" && as_dir=.
3002+
for ac_exec_ext in '' $ac_executable_extensions; do
3003+
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
3004+
ac_cv_prog_PYTHON_FOR_GEN="$ac_prog"
3005+
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3006+
break 2
3007+
fi
3008+
done
3009+
done
3010+
IFS=$as_save_IFS
3011+
3012+
fi
3013+
fi
3014+
PYTHON_FOR_GEN=$ac_cv_prog_PYTHON_FOR_GEN
3015+
if test -n "$PYTHON_FOR_GEN"; then
3016+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_FOR_GEN" >&5
3017+
$as_echo "$PYTHON_FOR_GEN" >&6; }
3018+
else
3019+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3020+
$as_echo "no" >&6; }
3021+
fi
3022+
3023+
3024+
test -n "$PYTHON_FOR_GEN" && break
3025+
done
3026+
test -n "$PYTHON_FOR_GEN" || PYTHON_FOR_GEN="not-found"
3027+
3028+
if test "$PYTHON_FOR_GEN" = not-found; then
3029+
PYTHON_FOR_GEN='@echo "Cannot generate $@, python not found !" && \
3030+
echo "To skip re-generation of $@ run <make touch> or <make -t $@>." && \
3031+
echo "Otherwise, set python in PATH and run configure or run <make PYTHON_FOR_GEN=python>." && false &&'
3032+
fi
3033+
3034+
29993035
if test "$cross_compiling" = yes; then
30003036
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for python interpreter for cross build" >&5
30013037
$as_echo_n "checking for python interpreter for cross build... " >&6; }
@@ -6329,107 +6365,6 @@ fi
63296365

63306366

63316367

6332-
for ac_prog in python$PACKAGE_VERSION python3 python
6333-
do
6334-
# Extract the first word of "$ac_prog", so it can be a program name with args.
6335-
set dummy $ac_prog; ac_word=$2
6336-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6337-
$as_echo_n "checking for $ac_word... " >&6; }
6338-
if ${ac_cv_prog_PYTHON+:} false; then :
6339-
$as_echo_n "(cached) " >&6
6340-
else
6341-
if test -n "$PYTHON"; then
6342-
ac_cv_prog_PYTHON="$PYTHON" # Let the user override the test.
6343-
else
6344-
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6345-
for as_dir in $PATH
6346-
do
6347-
IFS=$as_save_IFS
6348-
test -z "$as_dir" && as_dir=.
6349-
for ac_exec_ext in '' $ac_executable_extensions; do
6350-
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6351-
ac_cv_prog_PYTHON="$ac_prog"
6352-
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6353-
break 2
6354-
fi
6355-
done
6356-
done
6357-
IFS=$as_save_IFS
6358-
6359-
fi
6360-
fi
6361-
PYTHON=$ac_cv_prog_PYTHON
6362-
if test -n "$PYTHON"; then
6363-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
6364-
$as_echo "$PYTHON" >&6; }
6365-
else
6366-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6367-
$as_echo "no" >&6; }
6368-
fi
6369-
6370-
6371-
test -n "$PYTHON" && break
6372-
done
6373-
test -n "$PYTHON" || PYTHON="not-found"
6374-
6375-
if test "$PYTHON" = not-found; then
6376-
ASDLGEN="@echo python: $PYTHON! cannot run \$(srcdir)/Parser/asdl_c.py #"
6377-
else
6378-
ASDLGEN="$PYTHON"
6379-
fi
6380-
6381-
6382-
for ac_prog in python$PACKAGE_VERSION python3 python
6383-
do
6384-
# Extract the first word of "$ac_prog", so it can be a program name with args.
6385-
set dummy $ac_prog; ac_word=$2
6386-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6387-
$as_echo_n "checking for $ac_word... " >&6; }
6388-
if ${ac_cv_prog_PYTHON+:} false; then :
6389-
$as_echo_n "(cached) " >&6
6390-
else
6391-
if test -n "$PYTHON"; then
6392-
ac_cv_prog_PYTHON="$PYTHON" # Let the user override the test.
6393-
else
6394-
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6395-
for as_dir in $PATH
6396-
do
6397-
IFS=$as_save_IFS
6398-
test -z "$as_dir" && as_dir=.
6399-
for ac_exec_ext in '' $ac_executable_extensions; do
6400-
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6401-
ac_cv_prog_PYTHON="$ac_prog"
6402-
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6403-
break 2
6404-
fi
6405-
done
6406-
done
6407-
IFS=$as_save_IFS
6408-
6409-
fi
6410-
fi
6411-
PYTHON=$ac_cv_prog_PYTHON
6412-
if test -n "$PYTHON"; then
6413-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
6414-
$as_echo "$PYTHON" >&6; }
6415-
else
6416-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6417-
$as_echo "no" >&6; }
6418-
fi
6419-
6420-
6421-
test -n "$PYTHON" && break
6422-
done
6423-
test -n "$PYTHON" || PYTHON="not-found"
6424-
6425-
if test "$PYTHON" = not-found; then
6426-
OPCODEHGEN="@echo python: $PYTHON! cannot run Tools/scripts/generate_opcode_h.py"
6427-
else
6428-
OPCODEHGEN="$PYTHON"
6429-
fi
6430-
6431-
6432-
64336368
case $MACHDEP in
64346369
bsdos*|hp*|HP*)
64356370
# install -d does not work on BSDI or HP-UX

configure.ac

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ AC_SUBST(host)
5757
# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
5858
rm -f pybuilddir.txt
5959

60+
AC_CHECK_PROGS(PYTHON_FOR_GEN, python$PACKAGE_VERSION python3 python, not-found)
61+
if test "$PYTHON_FOR_GEN" = not-found; then
62+
PYTHON_FOR_GEN='@echo "Cannot generate $@, python not found !" && \
63+
echo "To skip re-generation of $@ run <make touch> or <make -t $@>." && \
64+
echo "Otherwise, set python in PATH and run configure or run <make PYTHON_FOR_GEN=python>." && false &&'
65+
fi
66+
AC_SUBST(PYTHON_FOR_GEN)
67+
6068
if test "$cross_compiling" = yes; then
6169
AC_MSG_CHECKING([for python interpreter for cross build])
6270
if test -z "$PYTHON_FOR_BUILD"; then
@@ -1204,23 +1212,6 @@ if test "$cross_compiling" = yes; then
12041212
fi
12051213
AC_SUBST(READELF)
12061214

1207-
AC_SUBST(ASDLGEN)
1208-
AC_CHECK_PROGS(PYTHON, python$PACKAGE_VERSION python3 python, not-found)
1209-
if test "$PYTHON" = not-found; then
1210-
ASDLGEN="@echo python: $PYTHON! cannot run \$(srcdir)/Parser/asdl_c.py #"
1211-
else
1212-
ASDLGEN="$PYTHON"
1213-
fi
1214-
1215-
AC_SUBST(OPCODEHGEN)
1216-
AC_CHECK_PROGS(PYTHON, python$PACKAGE_VERSION python3 python, not-found)
1217-
if test "$PYTHON" = not-found; then
1218-
OPCODEHGEN="@echo python: $PYTHON! cannot run Tools/scripts/generate_opcode_h.py"
1219-
else
1220-
OPCODEHGEN="$PYTHON"
1221-
fi
1222-
1223-
12241215

12251216
case $MACHDEP in
12261217
bsdos*|hp*|HP*)

0 commit comments

Comments
 (0)