churchyard / rpms / python3

Forked from rpms/python3 3 years ago
Clone

Blame python-3.2a1-debug-build.patch

7eb10c
diff -up Python-3.2a1/configure.in.debug-build Python-3.2a1/configure.in
7eb10c
--- Python-3.2a1/configure.in.debug-build	2010-08-20 16:06:24.616082276 -0400
7eb10c
+++ Python-3.2a1/configure.in	2010-08-20 16:06:24.632127011 -0400
7eb10c
@@ -584,7 +584,7 @@ AC_SUBST(LIBRARY)
55cf58
 AC_MSG_CHECKING(LIBRARY)
55cf58
 if test -z "$LIBRARY"
55cf58
 then
55cf58
-	LIBRARY='libpython$(VERSION).a'
55cf58
+	LIBRARY='libpython$(VERSION)$(DEBUG_EXT).a'
55cf58
 fi
55cf58
 AC_MSG_RESULT($LIBRARY)
55cf58
 
7eb10c
@@ -726,8 +726,8 @@ if test $enable_shared = "yes"; then
55cf58
 	  INSTSONAME="$LDLIBRARY".$SOVERSION
55cf58
           ;;
55cf58
     Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
55cf58
-	  LDLIBRARY='libpython$(VERSION).so'
55cf58
-	  BLDLIBRARY='-L. -lpython$(VERSION)'
55cf58
+	  LDLIBRARY='libpython$(VERSION)$(DEBUG_EXT).so'
55cf58
+	  BLDLIBRARY='-L. -lpython$(VERSION)$(DEBUG_EXT)'
55cf58
 	  RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
55cf58
 	  case $ac_sys_system in
55cf58
 	      FreeBSD*)
7eb10c
@@ -825,6 +825,14 @@ else AC_MSG_RESULT(no); Py_DEBUG='false'
55cf58
 fi],
55cf58
 [AC_MSG_RESULT(no)])
55cf58
 
55cf58
+if test "$Py_DEBUG" = 'true'
55cf58
+then
55cf58
+	DEBUG_EXT=_d
55cf58
+	DEBUG_SUFFIX=-debug
55cf58
+fi
55cf58
+AC_SUBST(DEBUG_EXT)
55cf58
+AC_SUBST(DEBUG_SUFFIX)
55cf58
+
55cf58
 # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
55cf58
 # merged with this chunk of code?
55cf58
 
7eb10c
diff -up Python-3.2a1/Lib/distutils/command/build_ext.py.debug-build Python-3.2a1/Lib/distutils/command/build_ext.py
7eb10c
--- Python-3.2a1/Lib/distutils/command/build_ext.py.debug-build	2010-07-22 08:50:05.000000000 -0400
7eb10c
+++ Python-3.2a1/Lib/distutils/command/build_ext.py	2010-08-20 16:06:24.633125472 -0400
55cf58
@@ -673,7 +673,10 @@ class build_ext(Command):
55cf58
         so_ext = get_config_var('SO')
55cf58
         if os.name == 'nt' and self.debug:
55cf58
             return os.path.join(*ext_path) + '_d' + so_ext
55cf58
-        return os.path.join(*ext_path) + so_ext
55cf58
+        
55cf58
+        # Similarly, extensions in debug mode are named 'module_d.so', to
55cf58
+        # avoid adding the _d to the SO config variable:
55cf58
+        return os.path.join(*ext_path) + (sys.pydebug and "_d" or "") + so_ext
55cf58
 
55cf58
     def get_export_symbols(self, ext):
55cf58
         """Return the list of symbols that a shared extension has to
55cf58
@@ -754,6 +757,8 @@ class build_ext(Command):
55cf58
                 template = "python%d.%d"
55cf58
                 pythonlib = (template %
55cf58
                              (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
55cf58
+                if sys.pydebug:
55cf58
+                    pythonlib += '_d'
55cf58
                 return ext.libraries + [pythonlib]
55cf58
             else:
55cf58
                 return ext.libraries
7eb10c
diff -up Python-3.2a1/Lib/distutils/sysconfig.py.debug-build Python-3.2a1/Lib/distutils/sysconfig.py
7eb10c
--- Python-3.2a1/Lib/distutils/sysconfig.py.debug-build	2010-08-20 16:06:24.623083865 -0400
7eb10c
+++ Python-3.2a1/Lib/distutils/sysconfig.py	2010-08-20 16:06:24.633125472 -0400
55cf58
@@ -83,7 +83,8 @@ def get_python_inc(plat_specific=0, pref
55cf58
             else:
55cf58
                 incdir = os.path.join(get_config_var('srcdir'), 'Include')
55cf58
                 return os.path.normpath(incdir)
55cf58
-        return os.path.join(prefix, "include", "python" + get_python_version())
55cf58
+        return os.path.join(prefix, "include",
55cf58
+                            "python" + get_python_version() + (sys.pydebug and '-debug' or ''))
55cf58
     elif os.name == "nt":
55cf58
         return os.path.join(prefix, "include")
55cf58
     elif os.name == "mac":
55cf58
@@ -229,7 +230,7 @@ def get_makefile_filename():
55cf58
     if python_build:
55cf58
         return os.path.join(os.path.dirname(sys.executable), "Makefile")
55cf58
     lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
55cf58
-    return os.path.join(lib_dir, "config", "Makefile")
55cf58
+    return os.path.join(lib_dir, "config" + (sys.pydebug and "-debug" or ""), "Makefile")
55cf58
 
55cf58
 
55cf58
 def parse_config_h(fp, g=None):
7eb10c
diff -up Python-3.2a1/Makefile.pre.in.debug-build Python-3.2a1/Makefile.pre.in
7eb10c
--- Python-3.2a1/Makefile.pre.in.debug-build	2010-08-20 16:06:24.624081000 -0400
7eb10c
+++ Python-3.2a1/Makefile.pre.in	2010-08-20 16:06:57.287084214 -0400
7eb10c
@@ -105,8 +105,8 @@ SCRIPTDIR=	$(prefix)/lib64
55cf58
 # Detailed destination directories
55cf58
 BINLIBDEST=	$(LIBDIR)/python$(VERSION)
55cf58
 LIBDEST=	$(SCRIPTDIR)/python$(VERSION)
55cf58
-INCLUDEPY=	$(INCLUDEDIR)/python$(VERSION)
55cf58
-CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(VERSION)
55cf58
+INCLUDEPY=	$(INCLUDEDIR)/python$(VERSION)$(DEBUG_SUFFIX)
55cf58
+CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(VERSION)$(DEBUG_SUFFIX)
55cf58
 LIBP=		$(LIBDIR)/python$(VERSION)
55cf58
 
55cf58
 # Symbols used for using shared libraries
7eb10c
@@ -120,6 +120,12 @@ DESTSHARED=	$(BINLIBDEST)/lib-dynload
55cf58
 EXE=		@EXEEXT@
55cf58
 BUILDEXE=	@BUILDEXEEXT@
55cf58
 
55cf58
+# DEBUG_EXT is used by ELF files (names and SONAMEs); it will be "_d" for a debug build
55cf58
+# DEBUG_SUFFIX is used by filesystem paths; it will be "-debug" for a debug build
55cf58
+# Both will be empty in an optimized build
55cf58
+DEBUG_EXT=	@DEBUG_EXT@
55cf58
+DEBUG_SUFFIX=	@DEBUG_SUFFIX@
55cf58
+
55cf58
 # Short name and location for Mac OS X Python framework
55cf58
 UNIVERSALSDK=@UNIVERSALSDK@
55cf58
 PYTHONFRAMEWORK=	@PYTHONFRAMEWORK@
7eb10c
@@ -183,7 +189,7 @@ LIBOBJDIR=	Python/
55cf58
 LIBOBJS=	@LIBOBJS@
55cf58
 
55cf58
 PYTHON=		python$(EXE)
55cf58
-BUILDPYTHON=	python$(BUILDEXE)
55cf58
+BUILDPYTHON=	python$(BUILD_SUFFIX)$(BUILDEXE)
55cf58
 
55cf58
 # The task to run while instrument when building the profile-opt target
55cf58
 PROFILE_TASK=	$(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
7eb10c
@@ -433,7 +439,7 @@ sharedmods: $(BUILDPYTHON)
7eb10c
 	*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(PY_LDFLAGS)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
55cf58
 	esac
55cf58
 
55cf58
-libpython$(VERSION).so: $(LIBRARY_OBJS)
55cf58
+libpython$(VERSION)$(DEBUG_EXT).so: $(LIBRARY_OBJS)
55cf58
 	if test $(INSTSONAME) != $(LDLIBRARY); then \
7eb10c
 		$(LDSHARED) $(PY_LDFLAGS) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
55cf58
 		$(LN) -f $(INSTSONAME) $@; \
7eb10c
@@ -817,7 +823,7 @@ altbininstall: $(BUILDPYTHON)
55cf58
 		else	true; \
55cf58
 		fi; \
55cf58
 	done
55cf58
-	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
55cf58
+	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(DEBUG_SUFFIX)$(EXE)
55cf58
 	if test -f $(LDLIBRARY); then \
55cf58
 		if test -n "$(DLLLIBRARY)" ; then \
55cf58
 			$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
7eb10c
@@ -831,15 +837,15 @@ altbininstall: $(BUILDPYTHON)
55cf58
 	fi
55cf58
 
55cf58
 bininstall: altbininstall
55cf58
-	-if test -f $(DESTDIR)$(BINDIR)/$(PYTHON)3$(EXE) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON)3$(EXE); \
55cf58
-	then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON)3$(EXE); \
55cf58
+	-if test -f $(DESTDIR)$(BINDIR)/$(PYTHON)3$(DEBUG_SUFFIX)$(EXE) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON)3$(DEBUG_SUFFIX)$(EXE); \
55cf58
+	then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON)3$(DEBUG_SUFFIX)$(EXE); \
55cf58
 	else true; \
55cf58
 	fi
55cf58
-	(cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON)3$(EXE))
55cf58
-	-rm -f $(DESTDIR)$(BINDIR)/python3-config
55cf58
-	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python3-config)
55cf58
-	-rm -f $(DESTDIR)$(LIBPC)/python3.pc
55cf58
-	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python3.pc)
55cf58
+	(cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(DEBUG_SUFFIX)$(EXE) $(PYTHON)3$(DEBUG_SUFFIX)$(EXE))
55cf58
+	-rm -f $(DESTDIR)$(BINDIR)/python3$(DEBUG_SUFFIX)-config
55cf58
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(DEBUG_SUFFIX)-config python3$(DEBUG_SUFFIX)-config)
55cf58
+	-rm -f $(DESTDIR)$(LIBPC)/python3$(DEBUG_SUFFIX).pc
55cf58
+	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION)$(DEBUG_SUFFIX).pc python3$(DEBUG_SUFFIX).pc)
55cf58
 
55cf58
 # Install the manual page
55cf58
 maninstall:
7eb10c
@@ -965,10 +971,10 @@ $(srcdir)/Lib/$(PLATDIR):
7eb10c
 	export EXE; EXE="$(BUILDEXE)"; \
7eb10c
 	cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
7eb10c
 
7eb10c
-python-config: $(srcdir)/Misc/python-config.in
7eb10c
+python$(DEBUG_SUFFIX)-config: $(srcdir)/Misc/python-config.in
7eb10c
 	# Substitution happens here, as the completely-expanded BINDIR
7eb10c
 	# is not available in configure
7eb10c
-	sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
7eb10c
+	sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(DEBUG_SUFFIX)$(EXE)," < $(srcdir)/Misc/python-config.in >python$(DEBUG_SUFFIX)-config
7eb10c
 
7eb10c
 # Install the include files
7eb10c
 INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
7eb10c
@@ -990,12 +996,12 @@ inclinstall:
55cf58
 
55cf58
 # Install the library and miscellaneous stuff needed for extending/embedding
55cf58
 # This goes into $(exec_prefix)
55cf58
-LIBPL=		$(LIBP)/config
55cf58
+LIBPL=		$(LIBP)/config$(DEBUG_SUFFIX)
55cf58
 
55cf58
 # pkgconfig directory
55cf58
 LIBPC=		$(LIBDIR)/pkgconfig
7eb10c
 
7eb10c
-libainstall:	all python-config
7eb10c
+libainstall:	all python$(DEBUG_SUFFIX)-config
7eb10c
 	@for i in $(LIBDIR) $(LIBP) $(LIBPL) $(LIBPC); \
7eb10c
 	do \
7eb10c
 		if test ! -d $(DESTDIR)$$i; then \
7eb10c
@@ -1011,11 +1017,11 @@ libainstall:	all python-config
55cf58
 	$(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
55cf58
 	$(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
55cf58
 	$(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config
55cf58
-	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
55cf58
+	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION)$(DEBUG_SUFFIX).pc
55cf58
 	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
55cf58
 	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
55cf58
-	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
55cf58
-	rm python-config
55cf58
+	$(INSTALL_SCRIPT) python$(DEBUG_SUFFIX)-config $(DESTDIR)$(BINDIR)/python$(VERSION)$(DEBUG_SUFFIX)-config
55cf58
+	rm python$(DEBUG_SUFFIX)-config
55cf58
 	@if [ -s Modules/python.exp -a \
55cf58
 		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
55cf58
 		echo; echo "Installing support files for building shared extension modules on AIX:"; \
7eb10c
diff -up Python-3.2a1/Misc/python-config.in.debug-build Python-3.2a1/Misc/python-config.in
7eb10c
--- Python-3.2a1/Misc/python-config.in.debug-build	2010-04-06 17:30:42.000000000 -0400
7eb10c
+++ Python-3.2a1/Misc/python-config.in	2010-08-20 16:06:24.635124366 -0400
7eb10c
@@ -45,7 +45,7 @@ for opt in opt_flags:
55cf58
 
7eb10c
     elif opt in ('--libs', '--ldflags'):
7eb10c
         libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
7eb10c
-        libs.append('-lpython'+pyver)
7eb10c
+        libs.append('-lpython' + pyver + (sys.pydebug and "_d" or ""))
7eb10c
         # add the prefix/lib/pythonX.Y/config dir, but only if there is no
7eb10c
         # shared library in prefix/lib/.
7eb10c
         if opt == '--ldflags':
7eb10c
diff -up Python-3.2a1/Modules/makesetup.debug-build Python-3.2a1/Modules/makesetup
7eb10c
--- Python-3.2a1/Modules/makesetup.debug-build	2010-07-09 12:30:58.000000000 -0400
7eb10c
+++ Python-3.2a1/Modules/makesetup	2010-08-20 16:06:24.635124366 -0400
55cf58
@@ -233,7 +233,7 @@ sed -e 's/[ 	]*#.*//' -e '/^[ 	]*$/d' |
55cf58
 			*$mod.o*)	base=$mod;;
55cf58
 			*)		base=${mod}module;;
55cf58
 			esac
55cf58
-			file="$srcdir/$base\$(SO)"
55cf58
+			file="$srcdir/$base\$(DEBUG_EXT)\$(SO)"
55cf58
 			case $doconfig in
55cf58
 			no)	SHAREDMODS="$SHAREDMODS $file";;
55cf58
 			esac
7eb10c
diff -up Python-3.2a1/Python/dynload_shlib.c.debug-build Python-3.2a1/Python/dynload_shlib.c
7eb10c
--- Python-3.2a1/Python/dynload_shlib.c.debug-build	2010-05-09 11:52:27.000000000 -0400
7eb10c
+++ Python-3.2a1/Python/dynload_shlib.c	2010-08-20 16:06:24.635124366 -0400
55cf58
@@ -46,11 +46,16 @@ const struct filedescr _PyImport_DynLoad
7eb10c
     {"module.exe", "rb", C_EXTENSION},
7eb10c
     {"MODULE.EXE", "rb", C_EXTENSION},
55cf58
 #else
55cf58
+#ifdef Py_DEBUG
7eb10c
+    {"_d.so", "rb", C_EXTENSION},
7eb10c
+    {"module_d.so", "rb", C_EXTENSION},
55cf58
+#else
7eb10c
     {".so", "rb", C_EXTENSION},
7eb10c
     {"module.so", "rb", C_EXTENSION},
55cf58
-#endif
55cf58
-#endif
55cf58
-#endif
55cf58
+#endif /* Py_DEBUG */
55cf58
+#endif /* __VMS */
55cf58
+#endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */
55cf58
+#endif /* __CYGWIN__ */
7eb10c
     {0, 0}
55cf58
 };
55cf58
 
7eb10c
diff -up Python-3.2a1/Python/sysmodule.c.debug-build Python-3.2a1/Python/sysmodule.c
7eb10c
--- Python-3.2a1/Python/sysmodule.c.debug-build	2010-07-06 06:53:30.000000000 -0400
7eb10c
+++ Python-3.2a1/Python/sysmodule.c	2010-08-20 16:06:24.636251716 -0400
7eb10c
@@ -1598,6 +1598,12 @@ _PySys_Init(void)
7eb10c
     WindowsVersionType.tp_new = NULL;
7eb10c
 #endif
55cf58
 
55cf58
+#ifdef Py_DEBUG
7eb10c
+    PyDict_SetItemString(sysdict, "pydebug", Py_True);
55cf58
+#else
7eb10c
+    PyDict_SetItemString(sysdict, "pydebug", Py_False);
55cf58
+#endif
55cf58
+
7eb10c
     /* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */
55cf58
 #ifndef PY_NO_SHORT_FLOAT_REPR
7eb10c
     SET_SYS_FROM_STRING("float_repr_style",
7eb10c
diff -up Python-3.2a1/runtests.sh.debug-build Python-3.2a1/runtests.sh
7eb10c
--- Python-3.2a1/runtests.sh.debug-build	2008-10-17 08:05:40.000000000 -0400
7eb10c
+++ Python-3.2a1/runtests.sh	2010-08-20 16:06:24.637251276 -0400
55cf58
@@ -16,11 +16,14 @@ Flags (arguments starting with '-') are 
55cf58
 regrtest.py, except for -x, which is processed here."
55cf58
 
55cf58
 # Choose the Python binary.
55cf58
-case `uname` in
55cf58
-Darwin) PYTHON=./python.exe;;
55cf58
-CYGWIN*) PYTHON=./python.exe;;
55cf58
-*)      PYTHON=./python;;
55cf58
-esac
55cf58
+if [ -z $PYTHON ]
55cf58
+then
55cf58
+    case `uname` in
55cf58
+    Darwin) PYTHON=./python.exe;;
55cf58
+    CYGWIN*) PYTHON=./python.exe;;
55cf58
+    *)      PYTHON=./python;;
55cf58
+    esac
55cf58
+fi
55cf58
 
55cf58
 PYTHON="$PYTHON -bb"
55cf58