From: "Fred L. Drake" Subject: Patches to support Python 1.4 Date: Fri, 30 Aug 1996 14:31:54 PDT Bill, I'm including my patch below. I've checked this using against the development version of Python (as of this morning) and ILU 2.0alpha8 with the patches on the web page (but not the signal handling patch you posted to the list). The platforms I've used include Solaris 2.5 (Sparc & Intel), IRIX 5.3, and Linux 2.0.13 (Intel, RedHat Rembrandt II distribution). One problem I found for which I don't have a good solution was that the configure script doesn't correctly determine the use of shared object support on the Linux system. The host id determined by config.guess was "i586-unknown-linux", and configure required a version number on that to use dynamic loading. Specifying --host=i586-unknown-linux2.0.13 to the configure script did the trick but is not a sufficiently general solution. -Fred -- Fred L. Drake, Jr. fdrake@cnri.reston.va.us Corporation for National Research Initiatives 1895 Preston White Drive Reston, VA 20191-5434 diff -C 2 -rb 2.0a8-stock/src/examples/multlang/Imakefile 2.0a8/src/examples/multlang/Imakefile *** 2.0a8-stock/src/examples/multlang/Imakefile Fri Aug 30 16:18:29 1996 --- 2.0a8/src/examples/multlang/Imakefile Thu Aug 29 12:36:09 1996 *************** *** 21,25 **** runImakefile : runImakefile.dist $(RM) python-libs ! $(PYTHON_EXEC_PREFIX)/bin/python figurePythonLibs $(PYTHON_PREFIX)/lib/python/lib/Makefile >python-libs $(SED) -e "s;PYTHON_SYSTEM_LIBS;`cat python-libs`;" runImakefile --- 21,25 ---- runImakefile : runImakefile.dist $(RM) python-libs ! $(PYTHON_EXEC_PREFIX)/bin/python figurePythonLibs $(PYTHON_EXEC_PREFIX)/lib/$(PYTHON_EXEC_SUFFIX)/Makefile >python-libs $(SED) -e "s;PYTHON_SYSTEM_LIBS;`cat python-libs`;" runImakefile diff -C 2 -rb 2.0a8-stock/src/examples/multlang/runImakefile.dist 2.0a8/src/examples/multlang/runImakefile.dist *** 2.0a8-stock/src/examples/multlang/runImakefile.dist Wed Jul 17 18:23:50 1996 --- 2.0a8/src/examples/multlang/runImakefile.dist Fri Aug 30 09:57:33 1996 *************** *** 35,39 **** /* note: Python libs must be in this order (as of Python 1.2) */ ! PYTHONLIBS = $(ILUHOME)/lib/libilupython.a $(PYTHON_EXEC_PREFIX)/lib/python/lib/libModules.a $(PYTHON_EXEC_PREFIX)/lib/python/lib/libPython.a $(PYTHON_EXEC_PREFIX)/lib/python/lib/libObjects.a $(PYTHON_EXEC_PREFIX)/lib/python/lib/libParser.a $(ILUHOME)/lib/libilupythonaux.a libconfig.o : $(ILUHOME)/lib/libilupython.a --- 35,39 ---- /* note: Python libs must be in this order (as of Python 1.2) */ ! PYTHONLIBS = $(ILUHOME)/lib/libilupython.a $(PYTHON_EXEC_PREFIX)/lib/$(PYTHON_EXEC_SUFFIX)/libModules.a $(PYTHON_EXEC_PREFIX)/lib/$(PYTHON_EXEC_SUFFIX)/libPython.a $(PYTHON_EXEC_PREFIX)/lib/$(PYTHON_EXEC_SUFFIX)/libObjects.a $(PYTHON_EXEC_PREFIX)/lib/$(PYTHON_EXEC_SUFFIX)/libParser.a $(ILUHOME)/lib/libilupythonaux.a libconfig.o : $(ILUHOME)/lib/libilupython.a diff -C 2 -rb 2.0a8-stock/src/imake/configure.in 2.0a8/src/imake/configure.in *** 2.0a8-stock/src/imake/configure.in Wed Jul 17 16:37:59 1996 --- 2.0a8/src/imake/configure.in Fri Aug 30 12:47:40 1996 *************** *** 1002,1007 **** if test "x$PYTHONHOME" != "x"; then AC_SUBST(PYTHON_PREFIX) AC_MSG_CHECKING(whether Python libraries are installed) ! if test -f "${PYTHONHOME}/lib/python/lib/libPython.a" ; then AC_DEFINE(PYTHON_LIBRARIES_INSTALLED) AC_MSG_RESULT(yes) --- 1002,1031 ---- if test "x$PYTHONHOME" != "x"; then AC_SUBST(PYTHON_PREFIX) + dnl + dnl The PYTHON_*SUFFIX entries are required to provide compatibility + dnl between pre-1.4 and 1.4+ versions of Python. Changes in the + dnl Python installation procedure require these distinctions be made here. + dnl + AC_SUBST(PYTHON_SUFFIX) + AC_SUBST(PYTHON_EXEC_SUFFIX) + AC_SUBST(PYTHON_INCLUDE_SUFFIX) + AC_MSG_CHECKING(Python version) + PYTHONMAJORVERSION=[`$PYTHONHOME/bin/python -c "import sys; import string; print string.splitfields(string.split(sys.version)[0], '.')[0]"`] + PYTHONMINORVERSION=[`$PYTHONHOME/bin/python -c "import sys; import string; print string.splitfields(string.split(sys.version)[0], '.')[1][0]"`] + AC_MSG_RESULT([$PYTHONMAJORVERSION . $PYTHONMINORVERSION]) + if test $PYTHONMAJORVERSION -gt 1 -o $PYTHONMINORVERSION -gt 3; then + PYTHON_SUFFIX=python$PYTHONMAJORVERSION.$PYTHONMINORVERSION + PYTHON_EXEC_SUFFIX=$PYTHON_SUFFIX/config + PYTHON_INCLUDE_SUFFIX=$PYTHON_SUFFIX + else + PYTHON_SUFFIX=python + PYTHON_EXEC_SUFFIX=$PYTHON_SUFFIX/lib + PYTHON_INCLUDE_SUFFIX=Py + fi + AC_DEFINE_UNQUOTED(PYTHON_SUFFIX,$PYTHON_SUFFIX) + AC_DEFINE_UNQUOTED(PYTHON_EXEC_SUFFIX,$PYTHON_EXEC_SUFFIX) + AC_DEFINE_UNQUOTED(PYTHON_INCLUDE_SUFFIX,$PYTHON_INCLUDE_SUFFIX) AC_MSG_CHECKING(whether Python libraries are installed) ! if test -f "${PYTHONHOME}/lib/$PYTHON_EXEC_SUFFIX/libPython.a" ; then AC_DEFINE(PYTHON_LIBRARIES_INSTALLED) AC_MSG_RESULT(yes) *************** *** 1009,1016 **** AC_MSG_RESULT(no) fi - AC_MSG_CHECKING(Python version) - PYTHONMAJORVERSION=[`$PYTHONHOME/bin/python -c "import sys; import string; print string.splitfields(string.split(sys.version)[0], '.')[0]"`] - PYTHONMINORVERSION=[`$PYTHONHOME/bin/python -c "import sys; import string; print string.splitfields(string.split(sys.version)[0], '.')[1]"`] - AC_MSG_RESULT([$PYTHONMAJORVERSION . $PYTHONMINORVERSION]) AC_DEFINE_UNQUOTED(PYTHON_MAJOR_VERSION, $PYTHONMAJORVERSION) AC_DEFINE_UNQUOTED(PYTHON_MINOR_VERSION, $PYTHONMINORVERSION) --- 1033,1036 ---- *************** *** 1210,1215 **** echo -n "*** Where are the Tcl include files? " read TK_INCLUDE_2 ! TK_INCLUDES="-I$x_includes -I$TK_INCLUDE_1 -I$TK_INCLUDE_2" ! AC_MSG_RESULT([tk includes are $TK_INCLUDES]) fi fi], [AC_MSG_RESULT(no)]) --- 1230,1243 ---- echo -n "*** Where are the Tcl include files? " read TK_INCLUDE_2 ! TK_INCLUDES="-I$x_includes -I$TK_INCLUDE_1" ! if test "$x_includes" ; then ! TK_INCLUDES="-I$x_includes -I$TK_INCLUDE_1" ! else ! TK_INCLUDES="-I$TK_INCLUDE_1" ! fi ! if test ! "$TK_INCLUDE_1" = "$TK_INCLUDE_2" ; then ! TK_INCLUDES="$TK_INCLUDES -I$TK_INCLUDE_2" ! fi ! AC_MSG_RESULT([Tk includes are $TK_INCLUDES]) fi fi], [AC_MSG_RESULT(no)]) diff -C 2 -rb 2.0a8-stock/src/imake/figpythonprefix 2.0a8/src/imake/figpythonprefix *** 2.0a8-stock/src/imake/figpythonprefix Wed Jul 17 16:38:02 1996 --- 2.0a8/src/imake/figpythonprefix Wed Aug 28 10:45:25 1996 *************** *** 1,5 **** import sys prefix = '' ! for dir in sys.path: if dir[-11:] == '/lib/python': prefix = dir[:-11] --- 1,16 ---- import sys + + # This is best for recent Python versions: + try: + print sys.prefix + sys.exit(0) + except AttributeError: + pass + + # This doesn't always work: prefix = '' ! path = sys.path[:] ! path.reverse() ! for dir in path: if dir[-11:] == '/lib/python': prefix = dir[:-11] diff -C 2 -rb 2.0a8-stock/src/imake/iludefs.in 2.0a8/src/imake/iludefs.in *** 2.0a8-stock/src/imake/iludefs.in Wed Jul 17 16:38:00 1996 --- 2.0a8/src/imake/iludefs.in Fri Aug 30 12:26:47 1996 *************** *** 36,39 **** --- 36,42 ---- PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_EXEC_PREFIX = @PYTHONHOME@ + PYTHON_SUFFIX = @PYTHON_SUFFIX@ + PYTHON_EXEC_SUFFIX = @PYTHON_EXEC_SUFFIX@ + PYTHON_INCLUDE_SUFFIX = @PYTHON_INCLUDE_SUFFIX@ #endif diff -C 2 -rb 2.0a8-stock/src/imake/ilugss_conf.h 2.0a8/src/imake/ilugss_conf.h *** 2.0a8-stock/src/imake/ilugss_conf.h Wed Jul 17 16:46:05 1996 --- 2.0a8/src/imake/ilugss_conf.h Thu Aug 29 17:20:35 1996 *************** *** 9,13 **** Some security mechanisms need to have this information to do marshalling properly. */ ! #define WORDS_BIGENDIAN 1 /* figure the sizes of char, short, int, and long */ --- 9,13 ---- Some security mechanisms need to have this information to do marshalling properly. */ ! /* #undef WORDS_BIGENDIAN */ /* figure the sizes of char, short, int, and long */ diff -C 2 -rb 2.0a8-stock/src/runtime/python/Imakefile 2.0a8/src/runtime/python/Imakefile *** 2.0a8-stock/src/runtime/python/Imakefile Fri Aug 30 16:18:29 1996 --- 2.0a8/src/runtime/python/Imakefile Fri Aug 30 12:39:47 1996 *************** *** 46,50 **** #endif ! LOCALINCLUDES = -I$(PYTHON_PREFIX)/include/Py -I../kernel ${ISEC} ILUCINCLUDES = KERNELHEADERS = ../kernel/iluxport.h ../kernel/iluerror.h ../kernel/iluerrs.h ../kernel/iluconf.h ../kernel/ilubasic.h --- 46,50 ---- #endif ! LOCALINCLUDES = -I$(PYTHON_PREFIX)/include/$(PYTHON_INCLUDE_SUFFIX) -I$(PYTHON_EXEC_PREFIX)/lib/$(PYTHON_EXEC_SUFFIX) -I../kernel ${ISEC} ILUCINCLUDES = KERNELHEADERS = ../kernel/iluxport.h ../kernel/iluerror.h ../kernel/iluerrs.h ../kernel/iluconf.h ../kernel/ilubasic.h *************** *** 60,64 **** iluPrmodule.o : iluPrmodule.c $(RM) $@ ! $(ANSI_C_COMPILER) -D_POSIX_SOURCE -c $(CFLAGS) $(ILUCINCLUDES) $*.c #endif /* _IS_POSIX */ --- 60,64 ---- iluPrmodule.o : iluPrmodule.c $(RM) $@ ! $(ANSI_C_COMPILER) -D_POSIX_SOURCE -c $(CFLAGS) $(ILUCINCLUDES) $(LOCALINCLUDES) $*.c #endif /* _IS_POSIX */ *************** *** 100,107 **** #if ((PYTHON_MAJOR_VERSION == 1) && (PYTHON_MINOR_VERSION > 2)) ! ADDOBJS = $(PYTHON_EXEC_PREFIX)/lib/python/lib/main.o getpath.o ! getpath.o : $(PYTHON_EXEC_PREFIX)/lib/python/lib/getpath.c ! $(ANSI_C_COMPILER) $(CFLAGS) -c -o ./getpath.o $(PYTHON_EXEC_PREFIX)/lib/python/lib/getpath.c #else --- 100,107 ---- #if ((PYTHON_MAJOR_VERSION == 1) && (PYTHON_MINOR_VERSION > 2)) ! ADDOBJS = $(PYTHON_EXEC_PREFIX)/lib/$(PYTHON_EXEC_SUFFIX)/main.o getpath.o ! getpath.o : $(PYTHON_EXEC_PREFIX)/lib/$(PYTHON_EXEC_SUFFIX)/getpath.c ! $(ANSI_C_COMPILER) $(CFLAGS) -c -o ./getpath.o $(PYTHON_EXEC_PREFIX)/lib/$(PYTHON_EXEC_SUFFIX)/getpath.c #else *************** *** 155,162 **** config.c Setup Makefile.build: Setup.in Makefile.pre.in -rm -f Setup ! make -f Makefile.pre.in Makefile.build installdir=$(PYTHON_EXEC_PREFIX) ilupython: config.c Makefile.build Setup $(OBJS) $(ADDOBJS) ../kernel/libilu.a ! make -f Makefile.build ilupython CC="$(ANSI_C_COMPILER)" ADDOBJS="$(ADDOBJS)" CleanTarget(python ilupython Makefile.build Setup.in Setup Makefile.pre sedscript) --- 155,170 ---- config.c Setup Makefile.build: Setup.in Makefile.pre.in -rm -f Setup ! make -f Makefile.pre.in Makefile.build \ ! installdir=$(PYTHON_PREFIX) \ ! exec_installdir=$(PYTHON_EXEC_PREFIX) \ ! PYTHON_INCLUDE_SUFFIX=$(PYTHON_INCLUDE_SUFFIX) \ ! PYTHON_EXEC_SUFFIX=$(PYTHON_EXEC_SUFFIX) ilupython: config.c Makefile.build Setup $(OBJS) $(ADDOBJS) ../kernel/libilu.a ! make -f Makefile.build ilupython CC="$(ANSI_C_COMPILER)" \ ! ADDOBJS="$(ADDOBJS)" \ ! PYTHON_SUFFIX=$(PYTHON_SUFFIX) \ ! PYTHON_EXEC_SUFFIX=$(PYTHON_EXEC_SUFFIX) \ ! PYTHON_INCLUDE_SUFFIX=$(PYTHON_INCLUDE_SUFFIX) CleanTarget(python ilupython Makefile.build Setup.in Setup Makefile.pre sedscript) *************** *** 172,180 **** */ ! libconfig.c : $(PYTHON_EXEC_PREFIX)/lib/python/lib/config.c ! $(SED) -f makelibconfig.sed <$(PYTHON_EXEC_PREFIX)/lib/python/lib/config.c >libconfig.c libconfig.o : libconfig.c ! $(ANSI_C_COMPILER) $(CFLAGS) -I$(PYTHON_PREFIX)/include/Py -DNO_MAIN -o libconfig.o -c libconfig.c LibraryTarget(libilupython.a, $(OBJS) libconfig.o) --- 180,188 ---- */ ! libconfig.c : $(PYTHON_EXEC_PREFIX)/lib/$(PYTHON_EXEC_SUFFIX)/config.c ! $(SED) -f makelibconfig.sed <$(PYTHON_EXEC_PREFIX)/lib/$(PYTHON_EXEC_SUFFIX)/config.c >libconfig.c libconfig.o : libconfig.c ! $(ANSI_C_COMPILER) $(CFLAGS) -I$(PYTHON_PREFIX)/include/$(PYTHON_INCLUDE_SUFFIX) -DNO_MAIN -o libconfig.o -c libconfig.c LibraryTarget(libilupython.a, $(OBJS) libconfig.o) diff -C 2 -rb 2.0a8-stock/src/runtime/python/Makefile.pre.in.1.2 2.0a8/src/runtime/python/Makefile.pre.in.1.2 *** 2.0a8-stock/src/runtime/python/Makefile.pre.in.1.2 Wed Jul 17 16:34:40 1996 --- 2.0a8/src/runtime/python/Makefile.pre.in.1.2 Fri Aug 30 12:22:30 1996 *************** *** 97,103 **** # === Fixed definitions === ! INCLUDEPY= $(installdir)/include/Py ! LIBP= $(exec_installdir)/lib/python ! LIBPL= $(LIBP)/lib PYTHONLIBS= $(LIBPL)/libModules.a \ --- 97,103 ---- # === Fixed definitions === ! INCLUDEPY= $(installdir)/include/$(PYTHON_INCLUDE_SUFFIX) ! LIBP= $(exec_installdir)/lib/$(PYTHON_SUFFIX) ! LIBPL= $(exec_installdir)/lib/$(PYTHON_EXEC_SUFFIX) PYTHONLIBS= $(LIBPL)/libModules.a \ *************** *** 132,136 **** $(MAKESETUP) \ -m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP) ! $(MAKE) -f Makefile.build do-it-again do-it-again: --- 132,140 ---- $(MAKESETUP) \ -m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP) ! $(MAKE) -f Makefile.build \ ! PYTHON_SUFFIX=$(PYTHON_SUFFIX) \ ! PYTHON_EXEC_SUFFIX=$(PYTHON_EXEC_SUFFIX) \ ! PYTHON_INCLUDE_SUFFIX=$(PYTHON_INCLUDE_SUFFIX) \ ! do-it-again do-it-again: *************** *** 182,186 **** distclean: clobber ! -rm -f Makefile.build Setup # === Rules added by makesetup === --- 186,194 ---- distclean: clobber ! -rm -f Makefile.build \ ! PYTHON_SUFFIX=$(PYTHON_SUFFIX) \ ! PYTHON_EXEC_SUFFIX=$(PYTHON_EXEC_SUFFIX) \ ! PYTHON_INCLUDE_SUFFIX=$(PYTHON_INCLUDE_SUFFIX) \ ! Setup # === Rules added by makesetup === diff -C 2 -rb 2.0a8-stock/src/runtime/python/python.h 2.0a8/src/runtime/python/python.h *** 2.0a8-stock/src/runtime/python/python.h Wed Jul 17 16:34:37 1996 --- 2.0a8/src/runtime/python/python.h Fri Aug 30 16:06:53 1996 *************** *** 29,33 **** #define HAVE_PROTOTYPES 1 /* We assume an ANSI C compiler */ ! #define HAVE_STDARG_PROTOTYPES /* Again, ANSI C */ #include "pythonversion.h" --- 29,33 ---- #define HAVE_PROTOTYPES 1 /* We assume an ANSI C compiler */ ! #define HAVE_STDARG_PROTOTYPES 1 /* Again, ANSI C */ #include "pythonversion.h" *************** *** 54,60 **** /* The following are for convenience. */ - #define PyCallable_Check(obj) \ - (PyFunction_Check(obj) || PyCFunction_Check(obj) || PyMethod_Check(obj)) - extern char * _ilupython_formErrDescription (char * /* buf into which to print the error */, ilu_Error *); extern PyObject *_ilupython_GeneralError; --- 54,57 ----