churchyard / rpms / python38

Forked from rpms/python38 5 years ago
Clone
55cf580
diff -up Python-3.1.2/configure.in.debug-build Python-3.1.2/configure.in
55cf580
--- Python-3.1.2/configure.in.debug-build	2010-05-20 22:48:14.573026391 -0400
55cf580
+++ Python-3.1.2/configure.in	2010-05-20 22:48:14.580902316 -0400
55cf580
@@ -569,7 +569,7 @@ AC_SUBST(LIBRARY)
55cf580
 AC_MSG_CHECKING(LIBRARY)
55cf580
 if test -z "$LIBRARY"
55cf580
 then
55cf580
-	LIBRARY='libpython$(VERSION).a'
55cf580
+	LIBRARY='libpython$(VERSION)$(DEBUG_EXT).a'
55cf580
 fi
55cf580
 AC_MSG_RESULT($LIBRARY)
55cf580
 
55cf580
@@ -711,8 +711,8 @@ if test $enable_shared = "yes"; then
55cf580
 	  INSTSONAME="$LDLIBRARY".$SOVERSION
55cf580
           ;;
55cf580
     Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
55cf580
-	  LDLIBRARY='libpython$(VERSION).so'
55cf580
-	  BLDLIBRARY='-L. -lpython$(VERSION)'
55cf580
+	  LDLIBRARY='libpython$(VERSION)$(DEBUG_EXT).so'
55cf580
+	  BLDLIBRARY='-L. -lpython$(VERSION)$(DEBUG_EXT)'
55cf580
 	  RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
55cf580
 	  case $ac_sys_system in
55cf580
 	      FreeBSD*)
55cf580
@@ -816,6 +816,14 @@ else AC_MSG_RESULT(no); Py_DEBUG='false'
55cf580
 fi],
55cf580
 [AC_MSG_RESULT(no)])
55cf580
 
55cf580
+if test "$Py_DEBUG" = 'true'
55cf580
+then
55cf580
+	DEBUG_EXT=_d
55cf580
+	DEBUG_SUFFIX=-debug
55cf580
+fi
55cf580
+AC_SUBST(DEBUG_EXT)
55cf580
+AC_SUBST(DEBUG_SUFFIX)
55cf580
+
55cf580
 # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
55cf580
 # merged with this chunk of code?
55cf580
 
55cf580
diff -up Python-3.1.2/Lib/distutils/command/build_ext.py.debug-build Python-3.1.2/Lib/distutils/command/build_ext.py
55cf580
--- Python-3.1.2/Lib/distutils/command/build_ext.py.debug-build	2010-03-19 17:56:34.000000000 -0400
55cf580
+++ Python-3.1.2/Lib/distutils/command/build_ext.py	2010-05-20 22:48:14.581902928 -0400
55cf580
@@ -673,7 +673,10 @@ class build_ext(Command):
55cf580
         so_ext = get_config_var('SO')
55cf580
         if os.name == 'nt' and self.debug:
55cf580
             return os.path.join(*ext_path) + '_d' + so_ext
55cf580
-        return os.path.join(*ext_path) + so_ext
55cf580
+        
55cf580
+        # Similarly, extensions in debug mode are named 'module_d.so', to
55cf580
+        # avoid adding the _d to the SO config variable:
55cf580
+        return os.path.join(*ext_path) + (sys.pydebug and "_d" or "") + so_ext
55cf580
 
55cf580
     def get_export_symbols(self, ext):
55cf580
         """Return the list of symbols that a shared extension has to
55cf580
@@ -754,6 +757,8 @@ class build_ext(Command):
55cf580
                 template = "python%d.%d"
55cf580
                 pythonlib = (template %
55cf580
                              (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
55cf580
+                if sys.pydebug:
55cf580
+                    pythonlib += '_d'
55cf580
                 return ext.libraries + [pythonlib]
55cf580
             else:
55cf580
                 return ext.libraries
55cf580
diff -up Python-3.1.2/Lib/distutils/sysconfig.py.debug-build Python-3.1.2/Lib/distutils/sysconfig.py
55cf580
--- Python-3.1.2/Lib/distutils/sysconfig.py.debug-build	2010-05-20 22:48:14.577026372 -0400
55cf580
+++ Python-3.1.2/Lib/distutils/sysconfig.py	2010-05-20 22:48:14.581902928 -0400
55cf580
@@ -83,7 +83,8 @@ def get_python_inc(plat_specific=0, pref
55cf580
             else:
55cf580
                 incdir = os.path.join(get_config_var('srcdir'), 'Include')
55cf580
                 return os.path.normpath(incdir)
55cf580
-        return os.path.join(prefix, "include", "python" + get_python_version())
55cf580
+        return os.path.join(prefix, "include",
55cf580
+                            "python" + get_python_version() + (sys.pydebug and '-debug' or ''))
55cf580
     elif os.name == "nt":
55cf580
         return os.path.join(prefix, "include")
55cf580
     elif os.name == "mac":
55cf580
@@ -229,7 +230,7 @@ def get_makefile_filename():
55cf580
     if python_build:
55cf580
         return os.path.join(os.path.dirname(sys.executable), "Makefile")
55cf580
     lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
55cf580
-    return os.path.join(lib_dir, "config", "Makefile")
55cf580
+    return os.path.join(lib_dir, "config" + (sys.pydebug and "-debug" or ""), "Makefile")
55cf580
 
55cf580
 
55cf580
 def parse_config_h(fp, g=None):
55cf580
diff -up Python-3.1.2/Makefile.pre.in.debug-build Python-3.1.2/Makefile.pre.in
55cf580
--- Python-3.1.2/Makefile.pre.in.debug-build	2010-05-20 22:48:14.577901061 -0400
55cf580
+++ Python-3.1.2/Makefile.pre.in	2010-05-20 22:48:14.581902928 -0400
55cf580
@@ -99,8 +99,8 @@ SCRIPTDIR=	$(prefix)/lib64
55cf580
 # Detailed destination directories
55cf580
 BINLIBDEST=	$(LIBDIR)/python$(VERSION)
55cf580
 LIBDEST=	$(SCRIPTDIR)/python$(VERSION)
55cf580
-INCLUDEPY=	$(INCLUDEDIR)/python$(VERSION)
55cf580
-CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(VERSION)
55cf580
+INCLUDEPY=	$(INCLUDEDIR)/python$(VERSION)$(DEBUG_SUFFIX)
55cf580
+CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(VERSION)$(DEBUG_SUFFIX)
55cf580
 LIBP=		$(LIBDIR)/python$(VERSION)
55cf580
 
55cf580
 # Symbols used for using shared libraries
55cf580
@@ -113,6 +113,12 @@ DESTSHARED=	$(BINLIBDEST)/lib-dynload
55cf580
 EXE=		@EXEEXT@
55cf580
 BUILDEXE=	@BUILDEXEEXT@
55cf580
 
55cf580
+# DEBUG_EXT is used by ELF files (names and SONAMEs); it will be "_d" for a debug build
55cf580
+# DEBUG_SUFFIX is used by filesystem paths; it will be "-debug" for a debug build
55cf580
+# Both will be empty in an optimized build
55cf580
+DEBUG_EXT=	@DEBUG_EXT@
55cf580
+DEBUG_SUFFIX=	@DEBUG_SUFFIX@
55cf580
+
55cf580
 # Short name and location for Mac OS X Python framework
55cf580
 UNIVERSALSDK=@UNIVERSALSDK@
55cf580
 PYTHONFRAMEWORK=	@PYTHONFRAMEWORK@
55cf580
@@ -176,7 +182,7 @@ LIBOBJDIR=	Python/
55cf580
 LIBOBJS=	@LIBOBJS@
55cf580
 
55cf580
 PYTHON=		python$(EXE)
55cf580
-BUILDPYTHON=	python$(BUILDEXE)
55cf580
+BUILDPYTHON=	python$(BUILD_SUFFIX)$(BUILDEXE)
55cf580
 
55cf580
 # The task to run while instrument when building the profile-opt target
55cf580
 PROFILE_TASK=	$(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
55cf580
@@ -422,7 +428,7 @@ sharedmods: $(BUILDPYTHON)
55cf580
 	*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
55cf580
 	esac
55cf580
 
55cf580
-libpython$(VERSION).so: $(LIBRARY_OBJS)
55cf580
+libpython$(VERSION)$(DEBUG_EXT).so: $(LIBRARY_OBJS)
55cf580
 	if test $(INSTSONAME) != $(LDLIBRARY); then \
55cf580
 		$(LDSHARED) $(LDFLAGS) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
55cf580
 		$(LN) -f $(INSTSONAME) $@; \
55cf580
@@ -793,7 +799,7 @@ altbininstall: $(BUILDPYTHON)
55cf580
 		else	true; \
55cf580
 		fi; \
55cf580
 	done
55cf580
-	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
55cf580
+	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(DEBUG_SUFFIX)$(EXE)
55cf580
 	if test -f $(LDLIBRARY); then \
55cf580
 		if test -n "$(DLLLIBRARY)" ; then \
55cf580
 			$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
55cf580
@@ -807,15 +813,15 @@ altbininstall: $(BUILDPYTHON)
55cf580
 	fi
55cf580
 
55cf580
 bininstall: altbininstall
55cf580
-	-if test -f $(DESTDIR)$(BINDIR)/$(PYTHON)3$(EXE) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON)3$(EXE); \
55cf580
-	then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON)3$(EXE); \
55cf580
+	-if test -f $(DESTDIR)$(BINDIR)/$(PYTHON)3$(DEBUG_SUFFIX)$(EXE) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON)3$(DEBUG_SUFFIX)$(EXE); \
55cf580
+	then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON)3$(DEBUG_SUFFIX)$(EXE); \
55cf580
 	else true; \
55cf580
 	fi
55cf580
-	(cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON)3$(EXE))
55cf580
-	-rm -f $(DESTDIR)$(BINDIR)/python3-config
55cf580
-	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python3-config)
55cf580
-	-rm -f $(DESTDIR)$(LIBPC)/python3.pc
55cf580
-	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python3.pc)
55cf580
+	(cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(DEBUG_SUFFIX)$(EXE) $(PYTHON)3$(DEBUG_SUFFIX)$(EXE))
55cf580
+	-rm -f $(DESTDIR)$(BINDIR)/python3$(DEBUG_SUFFIX)-config
55cf580
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(DEBUG_SUFFIX)-config python3$(DEBUG_SUFFIX)-config)
55cf580
+	-rm -f $(DESTDIR)$(LIBPC)/python3$(DEBUG_SUFFIX).pc
55cf580
+	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION)$(DEBUG_SUFFIX).pc python3$(DEBUG_SUFFIX).pc)
55cf580
 
55cf580
 # Install the manual page
55cf580
 maninstall:
55cf580
@@ -960,7 +966,7 @@ inclinstall:
55cf580
 
55cf580
 # Install the library and miscellaneous stuff needed for extending/embedding
55cf580
 # This goes into $(exec_prefix)
55cf580
-LIBPL=		$(LIBP)/config
55cf580
+LIBPL=		$(LIBP)/config$(DEBUG_SUFFIX)
55cf580
 
55cf580
 # pkgconfig directory
55cf580
 LIBPC=		$(LIBDIR)/pkgconfig
55cf580
@@ -981,14 +987,14 @@ libainstall:	all
55cf580
 	$(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
55cf580
 	$(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
55cf580
 	$(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config
55cf580
-	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
55cf580
+	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION)$(DEBUG_SUFFIX).pc
55cf580
 	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
55cf580
 	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
55cf580
 	# Substitution happens here, as the completely-expanded BINDIR
55cf580
 	# is not available in configure
55cf580
-	sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
55cf580
-	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
55cf580
-	rm python-config
55cf580
+	sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(DEBUG_SUFFIX)$(EXE)," < $(srcdir)/Misc/python-config.in >python$(DEBUG_SUFFIX)-config
55cf580
+	$(INSTALL_SCRIPT) python$(DEBUG_SUFFIX)-config $(DESTDIR)$(BINDIR)/python$(VERSION)$(DEBUG_SUFFIX)-config
55cf580
+	rm python$(DEBUG_SUFFIX)-config
55cf580
 	@if [ -s Modules/python.exp -a \
55cf580
 		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
55cf580
 		echo; echo "Installing support files for building shared extension modules on AIX:"; \
55cf580
diff -up Python-3.1.2/Misc/python-config.in.debug-build Python-3.1.2/Misc/python-config.in
55cf580
--- Python-3.1.2/Misc/python-config.in.debug-build	2007-09-01 03:27:37.000000000 -0400
55cf580
+++ Python-3.1.2/Misc/python-config.in	2010-05-20 22:48:14.582902254 -0400
55cf580
@@ -44,7 +44,7 @@ elif opt in ('--includes', '--cflags'):
55cf580
 
55cf580
 elif opt in ('--libs', '--ldflags'):
55cf580
     libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
55cf580
-    libs.append('-lpython'+pyver)
55cf580
+    libs.append('-lpython' + pyver + (sys.pydebug and "_d" or ""))
55cf580
     # add the prefix/lib/pythonX.Y/config dir, but only if there is no
55cf580
     # shared library in prefix/lib/.
55cf580
     if opt == '--ldflags' and not getvar('Py_ENABLE_SHARED'):
55cf580
diff -up Python-3.1.2/Modules/makesetup.debug-build Python-3.1.2/Modules/makesetup
55cf580
--- Python-3.1.2/Modules/makesetup.debug-build	2008-06-11 01:26:20.000000000 -0400
55cf580
+++ Python-3.1.2/Modules/makesetup	2010-05-20 22:48:14.582902254 -0400
55cf580
@@ -233,7 +233,7 @@ sed -e 's/[ 	]*#.*//' -e '/^[ 	]*$/d' |
55cf580
 			*$mod.o*)	base=$mod;;
55cf580
 			*)		base=${mod}module;;
55cf580
 			esac
55cf580
-			file="$srcdir/$base\$(SO)"
55cf580
+			file="$srcdir/$base\$(DEBUG_EXT)\$(SO)"
55cf580
 			case $doconfig in
55cf580
 			no)	SHAREDMODS="$SHAREDMODS $file";;
55cf580
 			esac
55cf580
diff -up Python-3.1.2/Python/dynload_shlib.c.debug-build Python-3.1.2/Python/dynload_shlib.c
55cf580
--- Python-3.1.2/Python/dynload_shlib.c.debug-build	2008-06-11 01:26:20.000000000 -0400
55cf580
+++ Python-3.1.2/Python/dynload_shlib.c	2010-05-20 22:48:14.582902254 -0400
55cf580
@@ -46,11 +46,16 @@ const struct filedescr _PyImport_DynLoad
55cf580
         {"module.exe", "rb", C_EXTENSION},
55cf580
         {"MODULE.EXE", "rb", C_EXTENSION},
55cf580
 #else
55cf580
+#ifdef Py_DEBUG
55cf580
+	{"_d.so", "rb", C_EXTENSION},
55cf580
+	{"module_d.so", "rb", C_EXTENSION},
55cf580
+#else
55cf580
 	{".so", "rb", C_EXTENSION},
55cf580
 	{"module.so", "rb", C_EXTENSION},
55cf580
-#endif
55cf580
-#endif
55cf580
-#endif
55cf580
+#endif /* Py_DEBUG */
55cf580
+#endif /* __VMS */
55cf580
+#endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */
55cf580
+#endif /* __CYGWIN__ */
55cf580
 	{0, 0}
55cf580
 };
55cf580
 
55cf580
diff -up Python-3.1.2/Python/sysmodule.c.debug-build Python-3.1.2/Python/sysmodule.c
55cf580
--- Python-3.1.2/Python/sysmodule.c.debug-build	2010-03-03 06:55:53.000000000 -0500
55cf580
+++ Python-3.1.2/Python/sysmodule.c	2010-05-20 22:48:14.582902254 -0400
55cf580
@@ -1429,6 +1429,12 @@ _PySys_Init(void)
55cf580
 	FlagsType.tp_init = NULL;
55cf580
 	FlagsType.tp_new = NULL;
55cf580
 
55cf580
+#ifdef Py_DEBUG
55cf580
+	PyDict_SetItemString(sysdict, "pydebug", Py_True);
55cf580
+#else
55cf580
+	PyDict_SetItemString(sysdict, "pydebug", Py_False);
55cf580
+#endif
55cf580
+
55cf580
 	/* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */
55cf580
 #ifndef PY_NO_SHORT_FLOAT_REPR
55cf580
 	SET_SYS_FROM_STRING("float_repr_style",
55cf580
diff -up Python-3.1.2/runtests.sh.debug-build Python-3.1.2/runtests.sh
55cf580
--- Python-3.1.2/runtests.sh.debug-build	2010-05-22 00:42:41.950889054 -0400
55cf580
+++ Python-3.1.2/runtests.sh	2010-05-22 00:54:47.503851503 -0400
55cf580
@@ -16,11 +16,14 @@ Flags (arguments starting with '-') are 
55cf580
 regrtest.py, except for -x, which is processed here."
55cf580
 
55cf580
 # Choose the Python binary.
55cf580
-case `uname` in
55cf580
-Darwin) PYTHON=./python.exe;;
55cf580
-CYGWIN*) PYTHON=./python.exe;;
55cf580
-*)      PYTHON=./python;;
55cf580
-esac
55cf580
+if [ -z $PYTHON ]
55cf580
+then
55cf580
+    case `uname` in
55cf580
+    Darwin) PYTHON=./python.exe;;
55cf580
+    CYGWIN*) PYTHON=./python.exe;;
55cf580
+    *)      PYTHON=./python;;
55cf580
+    esac
55cf580
+fi
55cf580
 
55cf580
 PYTHON="$PYTHON -bb"
55cf580