diff -Nurd -x'*~' Python-2.5.4.orig/Lib/pydoc.py Python-2.5.4/Lib/pydoc.py
--- Python-2.5.4.orig/Lib/pydoc.py	2008-12-10 21:09:36.000000000 -0500
+++ Python-2.5.4/Lib/pydoc.py	2009-03-17 01:53:23.000000000 -0400
@@ -1621,19 +1621,7 @@
     def __init__(self, input, output):
         self.input = input
         self.output = output
-        self.docdir = None
-        execdir = os.path.dirname(sys.executable)
-        homedir = os.environ.get('PYTHONHOME')
-        for dir in [os.environ.get('PYTHONDOCS'),
-                    homedir and os.path.join(homedir, 'doc'),
-                    os.path.join(execdir, 'doc'),
-                    '/usr/doc/python-docs-' + split(sys.version)[0],
-                    '/usr/doc/python-' + split(sys.version)[0],
-                    '/usr/doc/python-docs-' + sys.version[:3],
-                    '/usr/doc/python-' + sys.version[:3],
-                    os.path.join(sys.prefix, 'Resources/English.lproj/Documentation')]:
-            if dir and os.path.isdir(os.path.join(dir, 'lib')):
-                self.docdir = dir
+        self.docdir = os.path.join(sys.prefix, 'share','doc','python'+sys.version[0]+sys.version[2],'html')
 
     def __repr__(self):
         if inspect.stack()[1][3] == '?':
diff -Nurd -x'*~' Python-2.5.4.orig/Modules/posixmodule.c Python-2.5.4/Modules/posixmodule.c
--- Python-2.5.4.orig/Modules/posixmodule.c	2008-12-13 10:14:30.000000000 -0500
+++ Python-2.5.4/Modules/posixmodule.c	2009-10-31 15:47:35.000000000 -0400
@@ -339,7 +339,7 @@
 #endif
 
 /* Return a dictionary corresponding to the POSIX environment table */
-#ifdef WITH_NEXT_FRAMEWORK
+#ifdef __APPLE__
 /* On Darwin/MacOSX a shared library or framework has no access to
 ** environ directly, we must obtain it with _NSGetEnviron().
 */
@@ -357,7 +357,7 @@
 	d = PyDict_New();
 	if (d == NULL)
 		return NULL;
-#ifdef WITH_NEXT_FRAMEWORK
+#ifdef __APPLE__
 	if (environ == NULL)
 		environ = *_NSGetEnviron();
 #endif
@@ -3638,6 +3638,9 @@
 "getgroups() -> list of group IDs\n\n\
 Return list of supplemental group IDs for the process.");
 
+#include <pwd.h>
+int getgrouplist_2(const char *name, gid_t basegid, gid_t **groups);
+
 static PyObject *
 posix_getgroups(PyObject *self, PyObject *noargs)
 {
@@ -3649,13 +3652,20 @@
         /* defined to be 16 on Solaris7, so this should be a small number */
 #define MAX_GROUPS 64
 #endif
-        gid_t grouplist[MAX_GROUPS];
+        gid_t *grouplist = NULL;
+        struct passwd *pw;
         int n;
 
-        n = getgroups(MAX_GROUPS, grouplist);
-        if (n < 0)
+        if ((pw = getpwuid(getuid())) == NULL) {
+            errno = EINVAL;
             posix_error();
-        else {
+            return NULL;
+        }
+        n = getgrouplist_2(pw->pw_name, pw->pw_gid, &grouplist);
+        if (n < 0) {
+            errno = EINVAL;
+            posix_error();
+        } else {
             result = PyList_New(n);
             if (result != NULL) {
                 int i;
@@ -3671,6 +3681,7 @@
             }
         }
 
+    if (grouplist) free(grouplist);
     return result;
 }
 #endif
@@ -5453,15 +5464,15 @@
 posix_setgroups(PyObject *self, PyObject *groups)
 {
 	int i, len;
-        gid_t grouplist[MAX_GROUPS];
+        gid_t *grouplist;
 
 	if (!PySequence_Check(groups)) {
 		PyErr_SetString(PyExc_TypeError, "setgroups argument must be a sequence");
 		return NULL;
 	}
 	len = PySequence_Size(groups);
-	if (len > MAX_GROUPS) {
-		PyErr_SetString(PyExc_ValueError, "too many groups");
+	if ((grouplist = (gid_t *)malloc(len * sizeof(gid_t))) == NULL) {
+		PyErr_NoMemory();
 		return NULL;
 	}
 	for(i = 0; i < len; i++) {
@@ -5507,6 +5518,7 @@
 
 	if (setgroups(len, grouplist) < 0)
 		return posix_error();
+	free(grouplist);
 	Py_INCREF(Py_None);
 	return Py_None;
 }
@@ -7199,6 +7211,15 @@
 #ifdef _MIPS_CS_VENDOR
     {"MIPS_CS_VENDOR",	_MIPS_CS_VENDOR},
 #endif
+#ifdef _CS_DARWIN_USER_DIR
+    {"CS_DARWIN_USER_DIR", _CS_DARWIN_USER_DIR},
+#endif
+#ifdef _CS_DARWIN_USER_TEMP_DIR
+    {"CS_DARWIN_USER_TEMP_DIR", _CS_DARWIN_USER_TEMP_DIR},
+#endif
+#ifdef _CS_DARWIN_USER_CACHE_DIR
+    {"CS_DARWIN_USER_CACHE_DIR", _CS_DARWIN_USER_CACHE_DIR},
+#endif
 };
 
 static int
diff -Nurd -x'*~' Python-2.5.5.orig/Modules/mmapmodule.c Python-2.5.5/Modules/mmapmodule.c
--- Python-2.5.5.orig/Modules/mmapmodule.c	2008-07-31 18:08:14.000000000 +0100
+++ Python-2.5.5/Modules/mmapmodule.c	2010-05-14 15:24:55.000000000 +0100
@@ -55,6 +55,11 @@
 #include <sys/types.h>
 #endif /* HAVE_SYS_TYPES_H */
 
+/* Force inclusion of fcntl.h, seems to be broken on MacOS 10.6. */
+#ifndef _SYS_FCNTL_H_
+#include <sys/fcntl.h>
+#endif /* _SYS_FCNTL_H_ */
+
 /* Prefer MAP_ANONYMOUS since MAP_ANON is deprecated according to man page. */
 #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
 #  define MAP_ANONYMOUS MAP_ANON
diff -Nurd -x'*~' Python-2.5.4.orig/configure Python-2.5.4/configure
--- Python-2.5.4.orig/configure	2008-12-13 09:13:52.000000000 -0500
+++ Python-2.5.4/configure	2009-03-17 01:53:23.000000000 -0400
@@ -4534,7 +4534,7 @@
 	    ;;
 	# is there any other compiler on Darwin besides gcc?
 	Darwin*)
-	    BASECFLAGS="$BASECFLAGS -Wno-long-double -no-cpp-precomp -mno-fused-madd"
+	    BASECFLAGS="$BASECFLAGS -Wno-long-double -mno-fused-madd -fno-common"
 	    if test "${enable_universalsdk}"; then
 		BASECFLAGS="-arch ppc -arch i386 -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
 	    fi
@@ -11491,7 +11491,7 @@
 			LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 		else
 			# No framework. Ignore undefined symbols, assuming they come from Python
-			LDSHARED="$LDSHARED -undefined suppress"
+  			LDSHARED="$LDSHARED -flat_namespace -undefined suppress"
 		fi ;;
 	Darwin/1.4*|Darwin/5.*|Darwin/6.*)
 		LDSHARED='$(CC) $(LDFLAGS) -bundle'
@@ -11501,8 +11501,8 @@
 			LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 		else
 			# No framework, use the Python app as bundle-loader
-			BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
-			LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
+  			BLDSHARED="$LDSHARED -flat_namespace -undefined suppress"
+  			LDSHARED="$LDSHARED -flat_namespace -undefined suppress"
 		fi ;;
 	Darwin/*)
 		# Use -undefined dynamic_lookup whenever possible (10.3 and later).
@@ -11536,8 +11536,8 @@
 				LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 			else
 				# No framework, use the Python app as bundle-loader
-				BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
-				LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
+				BLDSHARED="$LDSHARED -flat_namespace -undefined suppress"
+				LDSHARED="$LDSHARED -flat_namespace -undefined suppress"
 			fi
 		fi
 		;;
diff -Nurd -x'*~' Python-2.5.4.orig/setup.py Python-2.5.4/setup.py
--- Python-2.5.4.orig/setup.py	2008-10-16 14:58:19.000000000 -0400
+++ Python-2.5.4/setup.py	2009-03-17 01:53:23.000000000 -0400
@@ -244,8 +244,8 @@
 
     def detect_modules(self):
         # Ensure that /usr/local is always used
-        add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
-        add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+        add_dir_to_list(self.compiler.library_dirs, '@PREFIX@/lib')
+        add_dir_to_list(self.compiler.include_dirs, '@PREFIX@/include')
 
         # Add paths specified in the environment variables LDFLAGS and
         # CPPFLAGS for header and library files.
@@ -295,11 +295,11 @@
         # lib_dirs and inc_dirs are used to search for files;
         # if a file is found in one of those directories, it can
         # be assumed that no additional -I,-L directives are needed.
-        lib_dirs = self.compiler.library_dirs + [
+        lib_dirs = self.compiler.library_dirs + ['@PREFIX@/lib',
             '/lib64', '/usr/lib64',
             '/lib', '/usr/lib',
             ]
-        inc_dirs = self.compiler.include_dirs + ['/usr/include']
+        inc_dirs = self.compiler.include_dirs + ['@PREFIX@/include','/usr/include']
         exts = []
 
         config_h = sysconfig.get_config_h_filename()
@@ -522,10 +522,9 @@
                                depends = ['socketmodule.h']) )
         # Detect SSL support for the socket module (via _ssl)
         search_for_ssl_incs_in = [
-                              '/usr/local/ssl/include',
-                              '/usr/contrib/ssl/include/'
+                              '@PREFIX@/lib/system-openssl/include'
                              ]
-        ssl_incs = find_file('openssl/ssl.h', inc_dirs,
+        ssl_incs = find_file('openssl/ssl.h', [],
                              search_for_ssl_incs_in
                              )
         if ssl_incs is not None:
@@ -533,9 +532,8 @@
                                ['/usr/kerberos/include'])
             if krb5_h:
                 ssl_incs += krb5_h
-        ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
-                                     ['/usr/local/ssl/lib',
-                                      '/usr/contrib/ssl/lib/'
+        ssl_libs = find_library_file(self.compiler, 'ssl', [],
+                                     ['@PREFIX@/lib/system-openssl/lib'
                                      ] )
 
         if (ssl_incs is not None and
@@ -550,7 +548,7 @@
         openssl_ver = 0
         openssl_ver_re = re.compile(
             '^\s*#\s*define\s+OPENSSL_VERSION_NUMBER\s+(0x[0-9a-fA-F]+)' )
-        for ssl_inc_dir in inc_dirs + search_for_ssl_incs_in:
+        for ssl_inc_dir in search_for_ssl_incs_in:
             name = os.path.join(ssl_inc_dir, 'openssl', 'opensslv.h')
             if os.path.isfile(name):
                 try:
@@ -619,47 +617,8 @@
         # construct a list of paths to look for the header file in on
         # top of the normal inc_dirs.
         db_inc_paths = [
-            '/usr/include/db4',
-            '/usr/local/include/db4',
-            '/opt/sfw/include/db4',
-            '/sw/include/db4',
-            '/usr/include/db3',
-            '/usr/local/include/db3',
-            '/opt/sfw/include/db3',
-            '/sw/include/db3',
+            '@PREFIX@/include/db4'
         ]
-        # 4.x minor number specific paths
-        for x in range(max_db_ver[1]+1):
-            db_inc_paths.append('/usr/include/db4%d' % x)
-            db_inc_paths.append('/usr/include/db4.%d' % x)
-            db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x)
-            db_inc_paths.append('/usr/local/include/db4%d' % x)
-            db_inc_paths.append('/pkg/db-4.%d/include' % x)
-            db_inc_paths.append('/opt/db-4.%d/include' % x)
-        # 3.x minor number specific paths
-        for x in (3,):
-            db_inc_paths.append('/usr/include/db3%d' % x)
-            db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
-            db_inc_paths.append('/usr/local/include/db3%d' % x)
-            db_inc_paths.append('/pkg/db-3.%d/include' % x)
-            db_inc_paths.append('/opt/db-3.%d/include' % x)
-
-        # Add some common subdirectories for Sleepycat DB to the list,
-        # based on the standard include directories. This way DB3/4 gets
-        # picked up when it is installed in a non-standard prefix and
-        # the user has added that prefix into inc_dirs.
-        std_variants = []
-        for dn in inc_dirs:
-            std_variants.append(os.path.join(dn, 'db3'))
-            std_variants.append(os.path.join(dn, 'db4'))
-            for x in range(max_db_ver[1]+1):
-                std_variants.append(os.path.join(dn, "db4%d"%x))
-                std_variants.append(os.path.join(dn, "db4.%d"%x))
-            for x in (2,3):
-                std_variants.append(os.path.join(dn, "db3%d"%x))
-                std_variants.append(os.path.join(dn, "db3.%d"%x))
-
-        db_inc_paths = std_variants + db_inc_paths
 
 
         db_ver_inc_map = {}
@@ -761,12 +720,7 @@
         # We hunt for #define SQLITE_VERSION "n.n.n"
         # We need to find >= sqlite version 3.0.8
         sqlite_incdir = sqlite_libdir = None
-        sqlite_inc_paths = [ '/usr/include',
-                             '/usr/include/sqlite',
-                             '/usr/include/sqlite3',
-                             '/usr/local/include',
-                             '/usr/local/include/sqlite',
-                             '/usr/local/include/sqlite3',
+        sqlite_inc_paths = [ '@PREFIX@/include'
                            ]
         MIN_SQLITE_VERSION_NUMBER = (3, 0, 8)
         MIN_SQLITE_VERSION = ".".join([str(x)
@@ -1216,15 +1170,12 @@
         # AquaTk is a separate method. Only one Tkinter will be built on
         # Darwin - either AquaTk, if it is found, or X11 based Tk.
         platform = self.get_platform()
-        if (platform == 'darwin' and
-            self.detect_tkinter_darwin(inc_dirs, lib_dirs)):
-            return
 
         # Assume we haven't found any of the libraries or include files
         # The versions with dots are used on Unix, and the versions without
         # dots on Windows, for detection by cygwin.
         tcllib = tklib = tcl_includes = tk_includes = None
-        for version in ['8.5', '85', '8.4', '84', '8.3', '83', '8.2',
+        for version in ['8.4', '84', '8.3', '83', '8.2',
                         '82', '8.1', '81', '8.0', '80']:
             tklib = self.compiler.find_library_file(lib_dirs, 'tk' + version)
             tcllib = self.compiler.find_library_file(lib_dirs, 'tcl' + version)
