Blame SOURCES/python-2.7.3-debug-build.patch

ae2451
diff -up Python-2.7.3/configure.ac.debug-build Python-2.7.3/configure.ac
ae2451
--- Python-2.7.3/configure.ac.debug-build	2012-04-18 19:46:22.066498521 -0400
ae2451
+++ Python-2.7.3/configure.ac	2012-04-18 19:46:22.078498372 -0400
ae2451
@@ -635,7 +635,7 @@ AC_SUBST(LIBRARY)
ae2451
 AC_MSG_CHECKING(LIBRARY)
ae2451
 if test -z "$LIBRARY"
ae2451
 then
ae2451
-	LIBRARY='libpython$(VERSION).a'
ae2451
+	LIBRARY='libpython$(VERSION)$(DEBUG_EXT).a'
ae2451
 fi
ae2451
 AC_MSG_RESULT($LIBRARY)
ae2451
 
ae2451
@@ -780,8 +780,8 @@ if test $enable_shared = "yes"; then
ae2451
 	  INSTSONAME="$LDLIBRARY".$SOVERSION
ae2451
           ;;
ae2451
     Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
ae2451
-	  LDLIBRARY='libpython$(VERSION).so'
ae2451
-	  BLDLIBRARY='-L. -lpython$(VERSION)'
ae2451
+	  LDLIBRARY='libpython$(VERSION)$(DEBUG_EXT).so'
ae2451
+	  BLDLIBRARY='-L. -lpython$(VERSION)$(DEBUG_EXT)'
ae2451
 	  RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
ae2451
 	  case $ac_sys_system in
ae2451
 	      FreeBSD*)
ae2451
@@ -905,6 +905,14 @@ else AC_MSG_RESULT(no); Py_DEBUG='false'
ae2451
 fi],
ae2451
 [AC_MSG_RESULT(no)])
ae2451
 
ae2451
+if test "$Py_DEBUG" = 'true'
ae2451
+then
ae2451
+	DEBUG_EXT=_d
ae2451
+	DEBUG_SUFFIX=-debug
ae2451
+fi
ae2451
+AC_SUBST(DEBUG_EXT)
ae2451
+AC_SUBST(DEBUG_SUFFIX)
ae2451
+
ae2451
 # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
ae2451
 # merged with this chunk of code?
ae2451
 
ae2451
diff -up Python-2.7.3/Lib/distutils/command/build_ext.py.debug-build Python-2.7.3/Lib/distutils/command/build_ext.py
ae2451
--- Python-2.7.3/Lib/distutils/command/build_ext.py.debug-build	2012-04-09 19:07:29.000000000 -0400
ae2451
+++ Python-2.7.3/Lib/distutils/command/build_ext.py	2012-04-18 19:46:22.079498360 -0400
ae2451
@@ -676,7 +676,10 @@ class build_ext (Command):
ae2451
         so_ext = get_config_var('SO')
ae2451
         if os.name == 'nt' and self.debug:
ae2451
             return os.path.join(*ext_path) + '_d' + so_ext
ae2451
-        return os.path.join(*ext_path) + so_ext
ae2451
+
ae2451
+        # Similarly, extensions in debug mode are named 'module_d.so', to
ae2451
+        # avoid adding the _d to the SO config variable:
ae2451
+        return os.path.join(*ext_path) + (sys.pydebug and "_d" or "") + so_ext
ae2451
 
ae2451
     def get_export_symbols (self, ext):
ae2451
         """Return the list of symbols that a shared extension has to
ae2451
@@ -761,6 +764,8 @@ class build_ext (Command):
ae2451
                 template = "python%d.%d"
ae2451
                 pythonlib = (template %
ae2451
                              (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
ae2451
+                if sys.pydebug:
ae2451
+                    pythonlib += '_d'
ae2451
                 return ext.libraries + [pythonlib]
ae2451
             else:
ae2451
                 return ext.libraries
ae2451
diff -up Python-2.7.3/Lib/distutils/sysconfig.py.debug-build Python-2.7.3/Lib/distutils/sysconfig.py
ae2451
--- Python-2.7.3/Lib/distutils/sysconfig.py.debug-build	2012-04-18 19:46:21.988499499 -0400
ae2451
+++ Python-2.7.3/Lib/distutils/sysconfig.py	2012-04-18 19:46:22.080498348 -0400
ae2451
@@ -85,7 +85,8 @@ def get_python_inc(plat_specific=0, pref
ae2451
                 # Include is located in the srcdir
ae2451
                 inc_dir = os.path.join(srcdir, "Include")
ae2451
             return inc_dir
ae2451
-        return os.path.join(prefix, "include", "python" + get_python_version())
ae2451
+        return os.path.join(prefix, "include",
ae2451
+                            "python" + get_python_version() + (sys.pydebug and '-debug' or ''))
ae2451
     elif os.name == "nt":
ae2451
         return os.path.join(prefix, "include")
ae2451
     elif os.name == "os2":
ae2451
@@ -250,7 +251,7 @@ def get_makefile_filename():
ae2451
     if python_build:
ae2451
         return os.path.join(project_base, "Makefile")
ae2451
     lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
ae2451
-    return os.path.join(lib_dir, "config", "Makefile")
ae2451
+    return os.path.join(lib_dir, "config" + (sys.pydebug and "-debug" or ""), "Makefile")
ae2451
 
ae2451
 
ae2451
 def parse_config_h(fp, g=None):
ae2451
diff -up Python-2.7.3/Lib/distutils/tests/test_install.py.debug-build Python-2.7.3/Lib/distutils/tests/test_install.py
ae2451
--- Python-2.7.3/Lib/distutils/tests/test_install.py.debug-build	2012-04-18 19:46:21.997499385 -0400
ae2451
+++ Python-2.7.3/Lib/distutils/tests/test_install.py	2012-04-18 19:46:22.080498348 -0400
ae2451
@@ -20,8 +20,9 @@ from distutils.tests import support
ae2451
 
ae2451
 
ae2451
 def _make_ext_name(modname):
ae2451
-    if os.name == 'nt' and sys.executable.endswith('_d.exe'):
ae2451
+    if sys.pydebug:
ae2451
         modname += '_d'
ae2451
+    
ae2451
     return modname + sysconfig.get_config_var('SO')
ae2451
 
ae2451
 
ae2451
diff -up Python-2.7.3/Makefile.pre.in.debug-build Python-2.7.3/Makefile.pre.in
ae2451
--- Python-2.7.3/Makefile.pre.in.debug-build	2012-04-18 19:46:22.073498437 -0400
ae2451
+++ Python-2.7.3/Makefile.pre.in	2012-04-18 19:48:46.336694896 -0400
ae2451
@@ -102,8 +102,8 @@ SCRIPTDIR=	$(prefix)/lib64
ae2451
 # Detailed destination directories
ae2451
 BINLIBDEST=	$(LIBDIR)/python$(VERSION)
ae2451
 LIBDEST=	$(SCRIPTDIR)/python$(VERSION)
ae2451
-INCLUDEPY=	$(INCLUDEDIR)/python$(VERSION)
ae2451
-CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(VERSION)
ae2451
+INCLUDEPY=	$(INCLUDEDIR)/python$(VERSION)$(DEBUG_SUFFIX)
ae2451
+CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(VERSION)$(DEBUG_SUFFIX)
ae2451
 LIBP=		$(LIBDIR)/python$(VERSION)
ae2451
 
ae2451
 # Symbols used for using shared libraries
ae2451
@@ -117,6 +117,12 @@ DESTSHARED=	$(BINLIBDEST)/lib-dynload
ae2451
 EXE=		@EXEEXT@
ae2451
 BUILDEXE=	@BUILDEXEEXT@
ae2451
 
ae2451
+# DEBUG_EXT is used by ELF files (names and SONAMEs); it will be "_d" for a debug build
ae2451
+# DEBUG_SUFFIX is used by filesystem paths; it will be "-debug" for a debug build
ae2451
+# Both will be empty in an optimized build
ae2451
+DEBUG_EXT=	@DEBUG_EXT@
ae2451
+DEBUG_SUFFIX=	@DEBUG_SUFFIX@
ae2451
+
ae2451
 # Short name and location for Mac OS X Python framework
ae2451
 UNIVERSALSDK=@UNIVERSALSDK@
ae2451
 PYTHONFRAMEWORK=	@PYTHONFRAMEWORK@
ae2451
@@ -180,8 +186,8 @@ LIBOBJDIR=	Python/
ae2451
 LIBOBJS=	@LIBOBJS@
ae2451
 UNICODE_OBJS=   @UNICODE_OBJS@
ae2451
 
ae2451
-PYTHON=		python$(EXE)
ae2451
-BUILDPYTHON=	python$(BUILDEXE)
ae2451
+PYTHON=		python$(DEBUG_SUFFIX)$(EXE)
ae2451
+BUILDPYTHON=	python$(DEBUG_SUFFIX)$(BUILDEXE)
ae2451
 
ae2451
 PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
ae2451
 _PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
ae2451
@@ -413,7 +419,7 @@ sharedmods: $(BUILDPYTHON)
ae2451
 	$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
ae2451
 		$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
ae2451
 
ae2451
-libpython$(VERSION).so: $(LIBRARY_OBJS)
ae2451
+libpython$(VERSION)$(DEBUG_EXT).so: $(LIBRARY_OBJS)
ae2451
 	if test $(INSTSONAME) != $(LDLIBRARY); then \
ae2451
 		$(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
ae2451
 		$(LN) -f $(INSTSONAME) $@; \
ae2451
@@ -796,18 +802,18 @@ bininstall:	altbininstall
ae2451
 	then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
ae2451
 	else true; \
ae2451
 	fi
ae2451
-	(cd $(DESTDIR)$(BINDIR); $(LN) -s python2$(EXE) $(PYTHON))
ae2451
-	-rm -f $(DESTDIR)$(BINDIR)/python2$(EXE)
ae2451
-	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python2$(EXE))
ae2451
-	-rm -f $(DESTDIR)$(BINDIR)/python2-config
ae2451
-	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python2-config)
ae2451
-	-rm -f $(DESTDIR)$(BINDIR)/python-config
ae2451
-	(cd $(DESTDIR)$(BINDIR); $(LN) -s python2-config python-config)
ae2451
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s python2$(DEBUG_SUFFIX)$(EXE) $(PYTHON))
ae2451
+	-rm -f $(DESTDIR)$(BINDIR)/python2$(DEBUG_SUFFIX)$(EXE)
ae2451
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(DEBUG_SUFFIX)$(EXE) python2$(DEBUG_SUFFIX)$(EXE))
ae2451
+	-rm -f $(DESTDIR)$(BINDIR)/python2$(DEBUG_SUFFIX)-config
ae2451
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(DEBUG_SUFFIX)-config python2$(DEBUG_SUFFIX)-config)
ae2451
+	-rm -f $(DESTDIR)$(BINDIR)/python$(DEBUG_SUFFIX)-config
ae2451
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s python2$(DEBUG_SUFFIX)-config python$(DEBUG_SUFFIX)-config)
ae2451
 	-test -d $(DESTDIR)$(LIBPC) || $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC)
ae2451
-	-rm -f $(DESTDIR)$(LIBPC)/python2.pc
ae2451
-	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python2.pc)
ae2451
-	-rm -f $(DESTDIR)$(LIBPC)/python.pc
ae2451
-	(cd $(DESTDIR)$(LIBPC); $(LN) -s python2.pc python.pc)
ae2451
+	-rm -f $(DESTDIR)$(LIBPC)/python2$(DEBUG_SUFFIX).pc
ae2451
+	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION)$(DEBUG_SUFFIX).pc python2$(DEBUG_SUFFIX).pc)
ae2451
+	-rm -f $(DESTDIR)$(LIBPC)/python$(DEBUG_SUFFIX).pc
ae2451
+	(cd $(DESTDIR)$(LIBPC); $(LN) -s python2$(DEBUG_SUFFIX).pc python$(DEBUG_SUFFIX).pc)
ae2451
 
ae2451
 # Install the interpreter with $(VERSION) affixed
ae2451
 # This goes into $(exec_prefix)
ae2451
@@ -820,7 +826,7 @@ altbininstall:	$(BUILDPYTHON)
ae2451
 		else	true; \
ae2451
 		fi; \
ae2451
 	done
ae2451
-	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
ae2451
+	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(DEBUG_SUFFIX)$(EXE)
ae2451
 	if test -f $(LDLIBRARY); then \
ae2451
 		if test -n "$(DLLLIBRARY)" ; then \
ae2451
 			$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
ae2451
@@ -970,10 +976,11 @@ $(srcdir)/Lib/$(PLATDIR):
ae2451
 	fi; \
ae2451
 	cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
ae2451
 
ae2451
-python-config: $(srcdir)/Misc/python-config.in
ae2451
+python$(DEBUG_SUFFIX)-config: $(srcdir)/Misc/python-config.in
ae2451
 	# Substitution happens here, as the completely-expanded BINDIR
ae2451
 	# is not available in configure
ae2451
-	sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
ae2451
+	sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(DEBUG_SUFFIX)$(EXE)," < $(srcdir)/Misc/python-config.in >python$(DEBUG_SUFFIX)-config
ae2451
+
ae2451
 
ae2451
 # Install the include files
ae2451
 INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
ae2451
@@ -994,13 +1001,13 @@ inclinstall:
ae2451
 	$(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
ae2451
 
ae2451
 # Install the library and miscellaneous stuff needed for extending/embedding
ae2451
-# This goes into $(exec_prefix)
ae2451
-LIBPL=		$(LIBP)/config
ae2451
+# This goes into $(exec_prefix)$(DEBUG_SUFFIX)
ae2451
+LIBPL=		$(LIBP)/config$(DEBUG_SUFFIX)
ae2451
 
ae2451
 # pkgconfig directory
ae2451
 LIBPC=		$(LIBDIR)/pkgconfig
ae2451
 
ae2451
-libainstall:	all python-config
ae2451
+libainstall:	all python$(DEBUG_SUFFIX)-config
ae2451
 	@for i in $(LIBDIR) $(LIBP) $(LIBPL) $(LIBPC); \
ae2451
 	do \
ae2451
 		if test ! -d $(DESTDIR)$$i; then \
ae2451
@@ -1016,11 +1023,10 @@ libainstall:	all python-config
ae2451
 	$(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
ae2451
 	$(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
ae2451
 	$(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config
ae2451
-	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
ae2451
+	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION)$(DEBUG_SUFFIX).pc
ae2451
 	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
ae2451
 	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
ae2451
-	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
ae2451
-	rm python-config
ae2451
+	$(INSTALL_SCRIPT) python$(DEBUG_SUFFIX)-config $(DESTDIR)$(BINDIR)/python$(VERSION)$(DEBUG_SUFFIX)-config
ae2451
 	@if [ -s Modules/python.exp -a \
ae2451
 		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
ae2451
 		echo; echo "Installing support files for building shared extension modules on AIX:"; \
ae2451
diff -up Python-2.7.3/Misc/python-config.in.debug-build Python-2.7.3/Misc/python-config.in
ae2451
--- Python-2.7.3/Misc/python-config.in.debug-build	2012-04-09 19:07:33.000000000 -0400
ae2451
+++ Python-2.7.3/Misc/python-config.in	2012-04-18 19:46:22.082498324 -0400
ae2451
@@ -45,7 +45,7 @@ for opt in opt_flags:
ae2451
 
ae2451
     elif opt in ('--libs', '--ldflags'):
ae2451
         libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
ae2451
-        libs.append('-lpython'+pyver)
ae2451
+        libs.append('-lpython' + pyver + (sys.pydebug and "_d" or ""))
ae2451
         # add the prefix/lib/pythonX.Y/config dir, but only if there is no
ae2451
         # shared library in prefix/lib/.
ae2451
         if opt == '--ldflags':
ae2451
diff -up Python-2.7.3/Modules/makesetup.debug-build Python-2.7.3/Modules/makesetup
ae2451
--- Python-2.7.3/Modules/makesetup.debug-build	2012-04-09 19:07:34.000000000 -0400
ae2451
+++ Python-2.7.3/Modules/makesetup	2012-04-18 19:46:22.083498312 -0400
ae2451
@@ -233,7 +233,7 @@ sed -e 's/[ 	]*#.*//' -e '/^[ 	]*$/d' |
ae2451
 			*$mod.o*)	base=$mod;;
ae2451
 			*)		base=${mod}module;;
ae2451
 			esac
ae2451
-			file="$srcdir/$base\$(SO)"
ae2451
+			file="$srcdir/$base\$(DEBUG_EXT)\$(SO)"
ae2451
 			case $doconfig in
ae2451
 			no)	SHAREDMODS="$SHAREDMODS $file";;
ae2451
 			esac
ae2451
diff -up Python-2.7.3/Python/dynload_shlib.c.debug-build Python-2.7.3/Python/dynload_shlib.c
ae2451
--- Python-2.7.3/Python/dynload_shlib.c.debug-build	2012-04-09 19:07:35.000000000 -0400
ae2451
+++ Python-2.7.3/Python/dynload_shlib.c	2012-04-18 19:46:22.083498312 -0400
ae2451
@@ -46,11 +46,16 @@ const struct filedescr _PyImport_DynLoad
ae2451
     {"module.exe", "rb", C_EXTENSION},
ae2451
     {"MODULE.EXE", "rb", C_EXTENSION},
ae2451
 #else
ae2451
+#ifdef Py_DEBUG
ae2451
+    {"_d.so", "rb", C_EXTENSION},
ae2451
+    {"module_d.so", "rb", C_EXTENSION},
ae2451
+#else
ae2451
     {".so", "rb", C_EXTENSION},
ae2451
     {"module.so", "rb", C_EXTENSION},
ae2451
-#endif
ae2451
-#endif
ae2451
-#endif
ae2451
+#endif /* Py_DEBUG */
ae2451
+#endif /* __VMS */
ae2451
+#endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */
ae2451
+#endif /* __CYGWIN__ */
ae2451
     {0, 0}
ae2451
 };
ae2451
 
ae2451
diff -up Python-2.7.3/Python/sysmodule.c.debug-build Python-2.7.3/Python/sysmodule.c
ae2451
--- Python-2.7.3/Python/sysmodule.c.debug-build	2012-04-09 19:07:35.000000000 -0400
ae2451
+++ Python-2.7.3/Python/sysmodule.c	2012-04-18 19:46:22.083498312 -0400
ae2451
@@ -1506,6 +1506,12 @@ _PySys_Init(void)
ae2451
                         PyString_FromString("legacy"));
ae2451
 #endif
ae2451
 
ae2451
+#ifdef Py_DEBUG
ae2451
+	PyDict_SetItemString(sysdict, "pydebug", Py_True);
ae2451
+#else
ae2451
+	PyDict_SetItemString(sysdict, "pydebug", Py_False);
ae2451
+#endif
ae2451
+
ae2451
 #undef SET_SYS_FROM_STRING
ae2451
     if (PyErr_Occurred())
ae2451
         return NULL;