aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven 'sleipnir' Rebhan <odinshorse@googlemail.com>2009-01-08 19:27:14 +0000
committerSven 'sleipnir' Rebhan <odinshorse@googlemail.com>2009-01-08 19:27:14 +0000
commit2108875f630022e2b689f1712af49b4b77332180 (patch)
treeae60adbfa93ee49f93b74781fc2b51b985c0d72a /dev-lang
parentSite file for crossdev-wrappers. (diff)
downloadembedded-cross-2108875f630022e2b689f1712af49b4b77332180.tar.gz
embedded-cross-2108875f630022e2b689f1712af49b4b77332180.tar.bz2
embedded-cross-2108875f630022e2b689f1712af49b4b77332180.zip
Cross-compilable python version (supporting SYSROOT env variable).
Diffstat (limited to 'dev-lang')
-rw-r--r--dev-lang/python/Manifest11
-rw-r--r--dev-lang/python/files/pydoc.conf8
-rwxr-xr-xdev-lang/python/files/pydoc.init26
-rw-r--r--dev-lang/python/files/python-2.4.4-test-cross.patch19
-rw-r--r--dev-lang/python/files/python-2.5.2-cross-compile.patch11
-rw-r--r--dev-lang/python/files/python-2.5.2-cross-distutils.patch51
-rw-r--r--dev-lang/python/files/python-2.5.2-cross-enable-ctypes-module.patch109
-rw-r--r--dev-lang/python/files/python-2.5.2-cross-sysroot-setup.patch234
-rw-r--r--dev-lang/python/files/python-2.5.2-test-cross-printf_zd.patch23
-rw-r--r--dev-lang/python/python-2.5.2-r8.ebuild338
10 files changed, 830 insertions, 0 deletions
diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest
new file mode 100644
index 0000000..ad4758f
--- /dev/null
+++ b/dev-lang/python/Manifest
@@ -0,0 +1,11 @@
+AUX pydoc.conf 330 RMD160 0cd619ec251597e0fcadc05bfd249915e73baa17 SHA1 a56100d45378c554b9822f6ed512a6cb7841ef50 SHA256 a45ebba2de5f2b0e963db4101507203d095c5ff667ae5002c4897a9c87786fa1
+AUX pydoc.init 666 RMD160 11caf3a78bce4cdaebacaf21eaf26cc1ce30282e SHA1 88c5cb6d5bf737c74e1be93118cf157630af9ad7 SHA256 0d25c71232b74adb87dc709cc7cd8f8b13c452c0fe82fa33808f907f7a96d628
+AUX python-2.4.4-test-cross.patch 977 RMD160 8fdcd45dc202993988f7a1c2b3d918068883b99e SHA1 96f25777150ba05765282a43f08da6b6fab3cb73 SHA256 ff2a131776d560d188ec5069e17fea3eb09c26fdd02124ae5ff34d791c9fd9f6
+AUX python-2.5.2-cross-compile.patch 322 RMD160 f392c8087ae168279132a6b6cced3f41a4462b05 SHA1 5b581ecca82f7c204df856ac45940ea495a3ca36 SHA256 4cdf0c771ee858d4e6fb30f33d1d5d989310d9ceacf0cfe955872337527b98d0
+AUX python-2.5.2-cross-distutils.patch 2199 RMD160 ce61c129438ac25d19857d7a2f6c43759208280b SHA1 d2b564d4d2f116c40eff3a8a1b05b9ec991ba8b9 SHA256 4a8b541b739e5a375e12abb208be4974dda0c25c88587d04e8066a532242a6e5
+AUX python-2.5.2-cross-enable-ctypes-module.patch 3830 RMD160 52e92eae2ba60d67efb0494f9c4b47544991dcbb SHA1 c77c0c2db298619b2d4f57dc28609d4b1586565b SHA256 028c3ed4bf841fd19641e2c1af0dce68626aeb26168a97acabbba48aa1085cb6
+AUX python-2.5.2-cross-sysroot-setup.patch 11300 RMD160 b90c9e4d4b97a85e925131713c8c830ea7827c80 SHA1 75d10dd6d33bb641769fa93e137b126a72ae7d0c SHA256 193a8018a5a2f9a6fe573ddba8893bf03fe831a953fbcb0958fa2b48272ca865
+AUX python-2.5.2-test-cross-printf_zd.patch 618 RMD160 5f4d038edc6521e43e872bef42f039d2e91cbe81 SHA1 6a9a761c260d36c0ae4d458978e1ce18d9189ebf SHA256 7b4df16f7044f853819115679c1262b83e54be5141606143879e545d95b136ab
+DIST Python-2.5.2.tar.bz2 9807597 RMD160 b23b02739833e6730799c5866e2b77aae884b63f SHA1 4755d212f50af704c20224a6966e23acc5aea60f SHA256 f2f80e2a62a039e9a1ffa0fdf58707b2d12b3ff33c56472b46bb6d53f45e083e
+DIST python-gentoo-patches-2.5.2-r8.tar.bz2 28376 RMD160 c4e02a5ed947b253781ec11fd9f5f26498e41c81 SHA1 92e359402e7b6751b28671e19ad7ea0736b62614 SHA256 c008abb01c40057facf3d7fa8ad3a31e792f1b7d41bba96e0084e7476e05a0e3
+EBUILD python-2.5.2-r8.ebuild 10984 RMD160 74096230fe9b7b40d61e433e4aa48580ab75bea1 SHA1 5d19ff9383b3190bf203c57acb0d99ae304f8705 SHA256 1d0798b2e8bf8a5dc54b47d6e9971dcb840619d81031b7ab34d4ed6469d0642c
diff --git a/dev-lang/python/files/pydoc.conf b/dev-lang/python/files/pydoc.conf
new file mode 100644
index 0000000..4a98fd4
--- /dev/null
+++ b/dev-lang/python/files/pydoc.conf
@@ -0,0 +1,8 @@
+# /etc/init.d/pydoc.conf
+# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/files/pydoc.conf,v 1.2 2008/06/30 15:10:28 hawking Exp $
+
+# This file contains the configuration information for pydoc's internal
+# webserver. The variables should be rather self explanatory :-)
+
+# Default port for Python's pydoc server
+PYDOC_PORT=7464
diff --git a/dev-lang/python/files/pydoc.init b/dev-lang/python/files/pydoc.init
new file mode 100755
index 0000000..19b63e3
--- /dev/null
+++ b/dev-lang/python/files/pydoc.init
@@ -0,0 +1,26 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public Licence v2
+# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/files/pydoc.init,v 1.2 2008/06/30 15:10:28 hawking Exp $
+
+depend() {
+ need net
+}
+
+start() {
+ if [ -z $PYDOC_PORT ] ; then
+ eerror "Port not set"
+ return 1
+ fi
+ ebegin "Starting pydoc server on port $PYDOC_PORT"
+ start-stop-daemon --start --background --make-pidfile \
+ --pidfile /var/run/pydoc.pid \
+ --startas /usr/bin/pydoc -- -p $PYDOC_PORT
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping pydoc server"
+ start-stop-daemon --stop --quiet --pidfile /var/run/pydoc.pid
+ eend $?
+}
diff --git a/dev-lang/python/files/python-2.4.4-test-cross.patch b/dev-lang/python/files/python-2.4.4-test-cross.patch
new file mode 100644
index 0000000..d32cb3f
--- /dev/null
+++ b/dev-lang/python/files/python-2.4.4-test-cross.patch
@@ -0,0 +1,19 @@
+--- Python-2.4.4/Lib/test/test_multibytecodec.py.orig 2007-09-10 14:52:34.424592960 -0400
++++ Python-2.4.4/Lib/test/test_multibytecodec.py 2007-09-10 14:53:30.646201491 -0400
+@@ -81,11 +81,11 @@ class Test_ISO2022(unittest.TestCase):
+ uni = u':hu4:unit\xe9 de famille'
+ self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni)
+
+- def test_iso2022_jp_g0(self):
+- self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
+- for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'):
+- e = u'\u3406'.encode(encoding)
+- self.failIf(filter(lambda x: x >= '\x80', e))
++# def test_iso2022_jp_g0(self):
++# self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
++# for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'):
++# e = u'\u3406'.encode(encoding)
++# self.failIf(filter(lambda x: x >= '\x80', e))
+
+ def test_bug1572832(self):
+ if sys.maxunicode >= 0x10000:
diff --git a/dev-lang/python/files/python-2.5.2-cross-compile.patch b/dev-lang/python/files/python-2.5.2-cross-compile.patch
new file mode 100644
index 0000000..902dac4
--- /dev/null
+++ b/dev-lang/python/files/python-2.5.2-cross-compile.patch
@@ -0,0 +1,11 @@
+--- Makefile.pre.in 2008-09-28 13:21:04.000000000 +0200
++++ Makefile.pre.in.new 2008-09-28 13:20:54.000000000 +0200
+@@ -87,7 +87,7 @@
+
+ # Expanded directories
+ BINDIR= $(exec_prefix)/bin
+-LIBDIR= $(exec_prefix)/lib
++LIBDIR= @libdir@
+ MANDIR= @mandir@
+ INCLUDEDIR= @includedir@
+ CONFINCLUDEDIR= $(exec_prefix)/include
diff --git a/dev-lang/python/files/python-2.5.2-cross-distutils.patch b/dev-lang/python/files/python-2.5.2-cross-distutils.patch
new file mode 100644
index 0000000..1e2c198
--- /dev/null
+++ b/dev-lang/python/files/python-2.5.2-cross-distutils.patch
@@ -0,0 +1,51 @@
+This patch adds prepends the 'SYSROOT' path specified by the environment
+to the standard prefixes. By doing so we solve a whole bunch of problems
+with cross-compiling and installing python extensions.
+
+The second part provides a fallback if the lib64 directory does not exist.
+This is an ugly hack for now, the right fix would be to determine if the
+target system is 32 or 64bit and adapt the libdir accordingly.
+
+--- Lib/distutils/sysconfig.py 2008-09-27 15:55:24.000000000 +0200
++++ Lib/distutils/sysconfig.py.new 2008-09-27 15:55:36.000000000 +0200
+@@ -19,9 +19,16 @@
+ from distutils.errors import DistutilsPlatformError
+
+ # These are needed in a couple of spots, so just compute them once.
++SYSROOT = os.getenv('SYSROOT')
+ PREFIX = os.path.normpath(sys.prefix)
+ EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
+
++# Make sure we respect the user specified SYSROOT environment variable
++# This is the first step to get distutils to crosscompile stuff
++if SYSROOT is not None:
++ PREFIX = os.path.normpath(SYSROOT+os.path.sep+PREFIX)
++ EXEC_PREFIX = os.path.normpath(SYSROOT+os.path.sep+EXEC_PREFIX)
++
+ # python_build: (Boolean) if true, we're either building Python or
+ # building an extension with an un-installed Python, so we use
+ # different (hard-wired) directories.
+@@ -94,6 +101,10 @@
+
+ If 'prefix' is supplied, use it instead of sys.prefix or
+ sys.exec_prefix -- i.e., ignore 'plat_specific'.
++
++ For the posix system we can not always assume to have a lib64 directory
++ e.g. for cross-compile between 32 & 64 bit systems. So we test if the
++ 'lib64' directory exists and use the normal 'lib' dir as fallback.
+ """
+ if prefix is None:
+ prefix = plat_specific and EXEC_PREFIX or PREFIX
+@@ -102,6 +113,12 @@
+ libpython = os.path.join(prefix,
+ "lib64",
+ "python" + get_python_version())
++
++ if not os.path.exists(libpython):
++ libpython = os.path.join(prefix,
++ "lib",
++ "python" + get_python_version())
++
+ if standard_lib:
+ return libpython
+ else:
diff --git a/dev-lang/python/files/python-2.5.2-cross-enable-ctypes-module.patch b/dev-lang/python/files/python-2.5.2-cross-enable-ctypes-module.patch
new file mode 100644
index 0000000..bc4771c
--- /dev/null
+++ b/dev-lang/python/files/python-2.5.2-cross-enable-ctypes-module.patch
@@ -0,0 +1,109 @@
+This patch was taken from gitweb.openembedded.org (Author: Michael 'mickey' Lauer) and
+enables the cross compilation of the ctypes module.
+
+diff -Naur Python-2.5.1.orig/setup.py Python-2.5.1/setup.py
+--- Python-2.5.orig/setup.py 2006-08-10 01:42:18.000000000 +0200
++++ Python-2.5/setup.py 2007-11-21 18:00:43.000000000 +0100
+@@ -1321,16 +1329,16 @@
+ ffi_configfile):
+ from distutils.dir_util import mkpath
+ mkpath(ffi_builddir)
+- config_args = []
++ config_args = ['--host=%s' % os.environ["CHOST"], ]
+
+ # Pass empty CFLAGS because we'll just append the resulting
+ # CFLAGS to Python's; -g or -O2 is to be avoided.
+- cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
+- % (ffi_builddir, ffi_srcdir, " ".join(config_args))
++ cmd = "(cd %s && autoconf -W cross) && (cd %s && env CFLAGS='' '%s/configure' %s)" \
++ % (ffi_srcdir, ffi_builddir, ffi_srcdir, " ".join(config_args))
+
+ res = os.system(cmd)
+ if res or not os.path.exists(ffi_configfile):
+- print "Failed to configure _ctypes module"
++ print "Failed to configure _ctypes module, ret %d or missing %s"% (res, ffi_configfile, )
+ return False
+
+ fficonfig = {}
+diff -Naur Python-2.5.1.orig/Modules/_ctypes/callbacks.c Python-2.5.1/Modules/_ctypes/callbacks.c
+--- Python-2.5.1.orig/Modules/_ctypes/callbacks.c 2006-10-17 21:41:10.000000000 +0200
++++ Python-2.5.1/Modules/_ctypes/callbacks.c 2007-11-22 10:29:33.000000000 +0100
+@@ -273,11 +273,13 @@
+ PyErr_NoMemory();
+ return NULL;
+ }
++#if FFI_CLOSURES
+ p->pcl = MallocClosure();
+ if (p->pcl == NULL) {
+ PyErr_NoMemory();
+ goto error;
+ }
++#endif
+
+ for (i = 0; i < nArgs; ++i) {
+ PyObject *cnv = PySequence_GetItem(converters, i);
+@@ -315,12 +317,14 @@
+ "ffi_prep_cif failed with %d", result);
+ goto error;
+ }
++#if FFI_CLOSURES
+ result = ffi_prep_closure(p->pcl, &p->cif, closure_fcn, p);
+ if (result != FFI_OK) {
+ PyErr_Format(PyExc_RuntimeError,
+ "ffi_prep_closure failed with %d", result);
+ goto error;
+ }
++#endif
+
+ p->converters = converters;
+ p->callable = callable;
+@@ -328,8 +332,10 @@
+
+ error:
+ if (p) {
++#if FFI_CLOSURES
+ if (p->pcl)
+ FreeClosure(p->pcl);
++#endif
+ PyMem_Free(p);
+ }
+ return NULL;
+diff -Naur Python-2.5.1.orig/Modules/_ctypes/_ctypes.c Python-2.5.1/Modules/_ctypes/_ctypes.c
+--- Python-2.5.1.orig/Modules/_ctypes/_ctypes.c 2007-03-23 20:56:45.000000000 +0100
++++ Python-2.5.1/Modules/_ctypes/_ctypes.c 2007-11-22 10:29:01.000000000 +0100
+@@ -3419,7 +3419,9 @@
+ Py_CLEAR(self->paramflags);
+
+ if (self->thunk) {
++#if FFI_CLOSURES
+ FreeClosure(self->thunk->pcl);
++#endif
+ PyMem_Free(self->thunk);
+ self->thunk = NULL;
+ }
+diff -Naur Python-2.5.1.orig/Modules/_ctypes/ctypes.h Python-2.5.1/Modules/_ctypes/ctypes.h
+--- Python-2.5.1.orig/Modules/_ctypes/ctypes.h 2006-08-14 13:17:48.000000000 +0200
++++ Python-2.5.1/Modules/_ctypes/ctypes.h 2007-11-22 10:29:44.000000000 +0100
+@@ -68,7 +68,9 @@
+ };
+
+ typedef struct {
++#if FFI_CLOSURES
+ ffi_closure *pcl; /* the C callable */
++#endif
+ ffi_cif cif;
+ PyObject *converters;
+ PyObject *callable;
+diff -Naur Python-2.5.1.orig/Modules/_ctypes/malloc_closure.c Python-2.5.1/Modules/_ctypes/malloc_closure.c
+--- Python-2.5.1.orig/Modules/_ctypes/malloc_closure.c 2006-06-12 22:56:48.000000000 +0200
++++ Python-2.5.1/Modules/_ctypes/malloc_closure.c 2007-11-22 10:30:17.000000000 +0100
+@@ -27,7 +27,9 @@
+ /******************************************************************/
+
+ typedef union _tagITEM {
++#if FFI_CLOSURES
+ ffi_closure closure;
++#endif
+ union _tagITEM *next;
+ } ITEM;
+
diff --git a/dev-lang/python/files/python-2.5.2-cross-sysroot-setup.patch b/dev-lang/python/files/python-2.5.2-cross-sysroot-setup.patch
new file mode 100644
index 0000000..ce21c16
--- /dev/null
+++ b/dev-lang/python/files/python-2.5.2-cross-sysroot-setup.patch
@@ -0,0 +1,234 @@
+This lengthy patch adds the 'sysroot' variable as a prefix
+to all instances of include and libdirs in the python setup
+module. The 'sysroot' variable itself can be set using the
+SYSROOT environment variable used in the Gentoo cross-compile
+framework, making it possible to install python and its
+extensions into a root environment.
+
+--- setup.py 2008-09-28 19:17:01.000000000 +0200
++++ setup.py.new 2008-09-28 19:19:25.000000000 +0200
+@@ -263,9 +263,15 @@
+
+ def detect_modules(self):
+ global disable_ssl
++
++ # We must respect the user specified sysroot!
++ sysroot=os.getenv('SYSROOT')
++ if sysroot is None:
++ sysroot=''
++
+ # 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, sysroot+'/usr/local/lib')
++ add_dir_to_list(self.compiler.include_dirs, sysroot+'/usr/local/include')
+
+ # Add paths specified in the environment variables LDFLAGS and
+ # CPPFLAGS for header and library files.
+@@ -300,12 +306,20 @@
+ for directory in reversed(options.dirs):
+ add_dir_to_list(dir_list, directory)
+
+- if os.path.normpath(sys.prefix) != '/usr':
++ if os.path.normpath(sys.prefix) != '/usr/local':
+ add_dir_to_list(self.compiler.library_dirs,
+ sysconfig.get_config_var("LIBDIR"))
+ add_dir_to_list(self.compiler.include_dirs,
+ sysconfig.get_config_var("INCLUDEDIR"))
+
++ # We should always look into sysroot/usr/include and consider
++ # also the lib dirs there for searching for files
++ add_dir_to_list(self.compiler.include_dirs, sysroot+'/usr/include')
++ add_dir_to_list(self.compiler.library_dirs, sysroot+'/lib')
++ add_dir_to_list(self.compiler.library_dirs, sysroot+'/lib64')
++ add_dir_to_list(self.compiler.library_dirs, sysroot+'/usr/lib')
++ add_dir_to_list(self.compiler.library_dirs, sysroot+'/usr/lib64')
++
+ try:
+ have_unicode = unicode
+ except NameError:
+@@ -314,11 +328,8 @@
+ # 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 + [
+- '/lib64', '/usr/lib64',
+- '/lib', '/usr/lib',
+- ]
+- inc_dirs = self.compiler.include_dirs + ['/usr/include']
++ lib_dirs = self.compiler.library_dirs
++ inc_dirs = self.compiler.include_dirs
+ exts = []
+
+ config_h = sysconfig.get_config_h_filename()
+@@ -518,11 +529,11 @@
+ elif self.compiler.find_library_file(lib_dirs, 'curses'):
+ readline_libs.append('curses')
+ elif self.compiler.find_library_file(lib_dirs +
+- ['/usr/lib/termcap'],
++ [sysroot+'/usr/lib/termcap'],
+ 'termcap'):
+ readline_libs.append('termcap')
+ exts.append( Extension('readline', ['readline.c'],
+- library_dirs=['/usr/lib/termcap'],
++ library_dirs=[sysroot+'/usr/lib/termcap'],
+ extra_link_args=readline_extra_link_args,
+ libraries=readline_libs) )
+ if platform not in ['mac']:
+@@ -542,20 +553,20 @@
+ 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/'
++ sysroot+'/usr/local/ssl/include',
++ sysroot+'/usr/contrib/ssl/include/'
+ ]
+ ssl_incs = find_file('openssl/ssl.h', inc_dirs,
+ search_for_ssl_incs_in
+ )
+ if ssl_incs is not None:
+ krb5_h = find_file('krb5.h', inc_dirs,
+- ['/usr/kerberos/include'])
++ [sysroot+'/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/'
++ [sysroot+'/usr/local/ssl/lib',
++ sysroot+'/usr/contrib/ssl/lib/'
+ ] )
+
+ if (ssl_incs is not None and
+@@ -641,28 +652,28 @@
+ # 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.3',
+- '/usr/include/db4.2',
+- '/usr/include/db4.1',
+- '/usr/include/db4',
+- '/usr/include/db3.2',
+- '/usr/include/db3'
++ sysroot+'/usr/include/db4.3',
++ sysroot+'/usr/include/db4.2',
++ sysroot+'/usr/include/db4.1',
++ sysroot+'/usr/include/db4',
++ sysroot+'/usr/include/db3.2',
++ sysroot+'/usr/include/db3'
+ ]
+ # 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)
++ db_inc_paths.append(sysroot+'/usr/include/db4%d' % x)
++ db_inc_paths.append(sysroot+'/usr/include/db4.%d' % x)
++ db_inc_paths.append(sysroot+'/usr/local/BerkeleyDB.4.%d/include' % x)
++ db_inc_paths.append(sysroot+'/usr/local/include/db4%d' % x)
++ db_inc_paths.append(sysroot+'/pkg/db-4.%d/include' % x)
++ db_inc_paths.append(sysroot+'/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)
++ db_inc_paths.append(sysroot+'/usr/include/db3%d' % x)
++ db_inc_paths.append(sysroot+'/usr/local/BerkeleyDB.3.%d/include' % x)
++ db_inc_paths.append(sysroot+'/usr/local/include/db3%d' % x)
++ db_inc_paths.append(sysroot+'/pkg/db-3.%d/include' % x)
++ db_inc_paths.append(sysroot+'/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
+@@ -781,12 +792,12 @@
+ # 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 = [ sysroot+'/usr/include',
++ sysroot+'/usr/include/sqlite',
++ sysroot+'/usr/include/sqlite3',
++ sysroot+'/usr/local/include',
++ sysroot+'/usr/local/include/sqlite',
++ sysroot+'/usr/local/include/sqlite3',
+ ]
+ MIN_SQLITE_VERSION_NUMBER = (3, 0, 8)
+ MIN_SQLITE_VERSION = ".".join([str(x)
+@@ -877,7 +888,7 @@
+ # we do not build this one. Otherwise this build will pick up
+ # the more recent berkeleydb's db.h file first in the include path
+ # when attempting to compile and it will fail.
+- f = "/usr/include/db.h"
++ f = sysroot+"/usr/include/db.h"
+ if os.path.exists(f) and not db_incs:
+ data = open(f).read()
+ m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
+@@ -1038,7 +1049,7 @@
+ # More information on Expat can be found at www.libexpat.org.
+ #
+ # Use system expat
+- expatinc = '/usr/include'
++ expatinc = sysroot+'/usr/include'
+ define_macros = []
+
+ exts.append(Extension('pyexpat',
+@@ -1219,7 +1230,7 @@
+ # For 8.4a2, the X11 headers are not included. Rather than include a
+ # complicated search, this is a hard-coded path. It could bail out
+ # if X11 libs are not found...
+- include_dirs.append('/usr/X11R6/include')
++ include_dirs.append(sysroot+'/usr/X11R6/include')
+ frameworks = ['-framework', 'Tcl', '-framework', 'Tk']
+
+ ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
+@@ -1236,6 +1247,11 @@
+ def detect_tkinter(self, inc_dirs, lib_dirs):
+ # The _tkinter module.
+
++ # We must respect the user specified sysroot!
++ sysroot=os.getenv('SYSROOT')
++ if sysroot is None:
++ sysroot=''
++
+ # Rather than complicate the code below, detecting and building
+ # AquaTk is a separate method. Only one Tkinter will be built on
+ # Darwin - either AquaTk, if it is found, or X11 based Tk.
+@@ -1290,17 +1306,17 @@
+ if platform == 'sunos5':
+ include_dirs.append('/usr/openwin/include')
+ added_lib_dirs.append('/usr/openwin/lib')
+- elif os.path.exists('/usr/X11R6/include'):
+- include_dirs.append('/usr/X11R6/include')
+- added_lib_dirs.append('/usr/X11R6/lib64')
+- added_lib_dirs.append('/usr/X11R6/lib')
+- elif os.path.exists('/usr/X11R5/include'):
+- include_dirs.append('/usr/X11R5/include')
+- added_lib_dirs.append('/usr/X11R5/lib')
++ elif os.path.exists(sysroot+'/usr/X11R6/include'):
++ include_dirs.append(sysroot+'/usr/X11R6/include')
++ added_lib_dirs.append(sysroot+'/usr/X11R6/lib64')
++ added_lib_dirs.append(sysroot+'/usr/X11R6/lib')
++ elif os.path.exists(sysroot+'/usr/X11R5/include'):
++ include_dirs.append(sysroot+'/usr/X11R5/include')
++ added_lib_dirs.append(sysroot+'/usr/X11R5/lib')
+ else:
+ # Assume default location for X11
+- include_dirs.append('/usr/X11/include')
+- added_lib_dirs.append('/usr/X11/lib')
++ include_dirs.append(sysroot+'/usr/X11/include')
++ added_lib_dirs.append(sysroot+'/usr/X11/lib')
+
+ # If Cygwin, then verify that X is installed before proceeding
+ if platform == 'cygwin':
diff --git a/dev-lang/python/files/python-2.5.2-test-cross-printf_zd.patch b/dev-lang/python/files/python-2.5.2-test-cross-printf_zd.patch
new file mode 100644
index 0000000..4ec6c45
--- /dev/null
+++ b/dev-lang/python/files/python-2.5.2-test-cross-printf_zd.patch
@@ -0,0 +1,23 @@
+Make the printf %zd test-result cacheable.
+
+--- configure.in 2008-09-16 15:38:42.000000000 +0200
++++ configure.in.new 2008-09-16 17:02:58.000000000 +0200
+@@ -3418,7 +3418,8 @@
+
+
+ AC_MSG_CHECKING(for %zd printf() format support)
+-AC_TRY_RUN([#include <stdio.h>
++AC_CACHE_VAL(ac_cv_printf_zd_format,
++ AC_TRY_RUN([#include <stdio.h>
+ #include <stddef.h>
+ #include <string.h>
+
+@@ -3454,7 +3455,7 @@
+ }],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
+- AC_MSG_RESULT(no))
++ AC_MSG_RESULT(no)))
+
+ AC_CHECK_TYPE(socklen_t,,
+ AC_DEFINE(socklen_t,int,
diff --git a/dev-lang/python/python-2.5.2-r8.ebuild b/dev-lang/python/python-2.5.2-r8.ebuild
new file mode 100644
index 0000000..5542e14
--- /dev/null
+++ b/dev-lang/python/python-2.5.2-r8.ebuild
@@ -0,0 +1,338 @@
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.5.2-r8.ebuild,v 1.3 2008/10/26 21:40:28 hawking Exp $
+
+# NOTE about python-portage interactions :
+# - Do not add a pkg_setup() check for a certain version of portage
+# in dev-lang/python. It _WILL_ stop people installing from
+# Gentoo 1.4 images.
+
+EAPI=1
+
+inherit eutils autotools flag-o-matic python multilib versionator toolchain-funcs alternatives libtool
+
+# we need this so that we don't depends on python.eclass
+PYVER_MAJOR=$(get_major_version)
+PYVER_MINOR=$(get_version_component_range 2)
+PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
+
+MY_P="Python-${PV}"
+S="${WORKDIR}/${MY_P}"
+
+DESCRIPTION="Python is an interpreted, interactive, object-oriented programming language."
+HOMEPAGE="http://www.python.org/"
+SRC_URI="http://www.python.org/ftp/python/${PV}/${MY_P}.tar.bz2
+ mirror://gentoo/python-gentoo-patches-${PV}-r8.tar.bz2"
+
+LICENSE="PSF-2.2"
+SLOT="2.5"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~sparc-fbsd ~x86 ~x86-fbsd"
+IUSE="ncurses gdbm ssl readline tk berkdb ipv6 build ucs2 sqlite doc +threads examples elibc_uclibc wininst"
+
+# NOTE: dev-python/{elementtree,celementtree,pysqlite,ctypes,cjkcodecs}
+# do not conflict with the ones in python proper. - liquidx
+
+DEPEND=">=sys-libs/zlib-1.1.3
+ !build? (
+ sqlite? ( >=dev-db/sqlite-3 )
+ tk? ( >=dev-lang/tk-8.0 )
+ ncurses? ( >=sys-libs/ncurses-5.2
+ readline? ( >=sys-libs/readline-4.1 ) )
+ berkdb? ( || ( sys-libs/db:4.5 sys-libs/db:4.4 sys-libs/db:4.3
+ sys-libs/db:4.2 ) )
+ gdbm? ( sys-libs/gdbm )
+ ssl? ( dev-libs/openssl )
+ doc? ( dev-python/python-docs:2.5 )
+ dev-libs/expat
+ )"
+
+# NOTE: changed RDEPEND to PDEPEND to resolve bug 88777. - kloeri
+# NOTE: added blocker to enforce correct merge order for bug 88777. - zmedico
+
+PDEPEND="${DEPEND} app-admin/python-updater"
+PROVIDE="virtual/python"
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+
+ if tc-is-cross-compiler ; then
+ [[ $(python -V 2>&1) != "Python ${PV}" ]] && \
+ die "Crosscompiling requires the same host and build versions."
+ epatch "${FILESDIR}/python-2.4.4-test-cross.patch"
+ epatch "${FILESDIR}/python-2.5.2-test-cross-printf_zd.patch"
+ epatch "${FILESDIR}/python-2.5.2-cross-enable-ctypes-module.patch"
+ else
+ rm "${WORKDIR}/${PV}"/*_all_crosscompile.patch
+ fi
+
+ EPATCH_SUFFIX="patch" epatch "${WORKDIR}/${PV}"
+ sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
+ Lib/distutils/command/install.py \
+ Lib/distutils/sysconfig.py \
+ Lib/site.py \
+ Makefile.pre.in \
+ Modules/Setup.dist \
+ Modules/getpath.c \
+ setup.py || die
+
+ # We must put the following patches AFTER the patch-bomb above, because they were generated afterwards
+ if tc-is-cross-compiler ; then
+ # Change setup.py to respect the SYSROOT environment variable
+ epatch "${FILESDIR}/python-2.5.2-cross-sysroot-setup.patch"
+
+ # Make Makefile.pre.in using the user specifyable libdir
+ epatch "${FILESDIR}/python-2.5.2-cross-compile.patch"
+ fi
+ # Make distutils cross-compile aware
+ epatch "${FILESDIR}/python-2.5.2-cross-distutils.patch"
+
+ # fix os.utime() on hppa. utimes it not supported but unfortunately reported as working - gmsoft (22 May 04)
+ # PLEASE LEAVE THIS FIX FOR NEXT VERSIONS AS IT'S A CRITICAL FIX !!!
+ [ "${ARCH}" = "hppa" ] && sed -e 's/utimes //' -i "${S}"/configure
+
+ if ! use wininst; then
+ # remove microsoft windows executables
+ rm Lib/distutils/command/wininst-*.exe
+ fi
+
+ eautoreconf
+}
+
+src_configure() {
+ # disable extraneous modules with extra dependencies
+ if use build; then
+ export PYTHON_DISABLE_MODULES="readline pyexpat dbm gdbm bsddb _curses _curses_panel _tkinter _sqlite3"
+ export PYTHON_DISABLE_SSL=1
+ else
+ # dbm module can link to berkdb or gdbm
+ # defaults to gdbm when both are enabled, #204343
+ local disable
+ use berkdb || use gdbm || disable="${disable} dbm"
+ use berkdb || disable="${disable} bsddb"
+ use gdbm || disable="${disable} gdbm"
+ use ncurses || disable="${disable} _curses _curses_panel"
+ use readline || disable="${disable} readline"
+ use sqlite || disable="${disable} _sqlite3"
+ use ssl || export PYTHON_DISABLE_SSL=1
+ use tk || disable="${disable} _tkinter"
+ export PYTHON_DISABLE_MODULES="${disable}"
+ fi
+ einfo "Disabled modules: $PYTHON_DISABLE_MODULES"
+}
+
+src_compile() {
+ filter-flags -malign-double
+
+ # Seems to no longer be necessary
+ #[ "${ARCH}" = "amd64" ] && append-flags -fPIC
+ [ "${ARCH}" = "alpha" ] && append-flags -fPIC
+
+ # http://bugs.gentoo.org/show_bug.cgi?id=50309
+ if is-flag -O3; then
+ is-flag -fstack-protector-all && replace-flags -O3 -O2
+ use hardened && replace-flags -O3 -O2
+ fi
+
+ # See #228905
+ if [[ $(gcc-major-version) -ge 4 ]]; then
+ append-flags -fwrapv
+ fi
+
+ export OPT="${CFLAGS}"
+
+ local myconf
+
+ # super-secret switch. don't use this unless you know what you're
+ # doing. enabling UCS2 support will break your existing python
+ # modules
+ use ucs2 \
+ && myconf="${myconf} --enable-unicode=ucs2" \
+ || myconf="${myconf} --enable-unicode=ucs4"
+
+ use threads \
+ && myconf="${myconf} --with-threads" \
+ || myconf="${myconf} --without-threads"
+
+ src_configure
+
+ if tc-is-cross-compiler ; then
+ OPT="-O1" CFLAGS="" LDFLAGS="" CC="" \
+ ./configure || die "cross-configure failed"
+ emake python Parser/pgen || die "cross-make failed"
+ mv python hostpython
+ mv Parser/pgen Parser/hostpgen
+ make distclean
+ sed -i \
+ -e '/^HOSTPYTHON/s:=.*:=./hostpython:' \
+ -e '/^HOSTPGEN/s:=.*:=./Parser/hostpgen:' \
+ Makefile.pre.in || die
+ fi
+
+ # export CXX so it ends up in /usr/lib/python2.x/config/Makefile
+ tc-export CXX
+
+ # set LDFLAGS so we link modules with -lpython2.5 correctly.
+ # Needed on FreeBSD unless python2.5 is already installed.
+ # Please query BSD team before removing this!
+ append-ldflags "-L."
+
+ econf \
+ --with-fpectl \
+ --enable-shared \
+ `use_enable ipv6` \
+ --infodir='${prefix}'/share/info \
+ --mandir='${prefix}'/share/man \
+ --with-libc='' \
+ ${myconf} || die
+ emake || die "Parallel make failed"
+}
+
+src_install() {
+ dodir /usr
+ src_configure
+ make DESTDIR="${D}" altinstall maninstall || die
+
+ mv "${D}"/usr/bin/python${PYVER}-config "${D}"/usr/bin/python-config-${PYVER}
+
+ # Fix slotted collisions
+ mv "${D}"/usr/bin/pydoc "${D}"/usr/bin/pydoc${PYVER}
+ mv "${D}"/usr/bin/idle "${D}"/usr/bin/idle${PYVER}
+ mv "${D}"/usr/share/man/man1/python.1 \
+ "${D}"/usr/share/man/man1/python${PYVER}.1
+ rm -f "${D}"/usr/bin/smtpd.py
+
+ # While we're working on the config stuff... Let's fix the OPT var
+ # so that it doesn't have any opts listed in it. Prevents the problem
+ # with compiling things with conflicting opts later.
+ dosed -e 's:^OPT=.*:OPT=-DNDEBUG:' \
+ /usr/$(get_libdir)/python${PYVER}/config/Makefile
+
+ if use build ; then
+ rm -rf "${D}"/usr/$(get_libdir)/python${PYVER}/{test,encodings,email,lib-tk,bsddb/test}
+ else
+ use elibc_uclibc && rm -rf "${D}"/usr/$(get_libdir)/python${PYVER}/{test,bsddb/test}
+ use berkdb || rm -rf "${D}"/usr/$(get_libdir)/python${PYVER}/bsddb
+ use tk || rm -rf "${D}"/usr/$(get_libdir)/python${PYVER}/lib-tk
+ fi
+
+ prep_ml_includes usr/include/python${PYVER}
+
+ # The stuff below this line extends from 2.1, and should be deprecated
+ # in 2.3, or possibly can wait till 2.4
+
+ # seems like the build do not install Makefile.pre.in anymore
+ # it probably shouldn't - use DistUtils, people!
+ insinto /usr/$(get_libdir)/python${PYVER}/config
+ doins "${S}"/Makefile.pre.in
+
+ if use examples ; then
+ insinto /usr/share/doc/${PF}/examples
+ doins -r "${S}"/Tools || die "doins failed"
+ fi
+
+ newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT}
+ newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT}
+}
+
+pkg_postrm() {
+ local mansuffix=$(ecompress --suffix)
+ python_makesym
+ alternatives_auto_makesym "/usr/bin/idle" "idle[0-9].[0-9]"
+ alternatives_auto_makesym "/usr/bin/pydoc" "pydoc[0-9].[0-9]"
+ alternatives_auto_makesym "/usr/bin/python-config" \
+ "python-config-[0-9].[0-9]"
+
+ alternatives_auto_makesym "/usr/share/man/man1/python.1${mansuffix}" \
+ "python[0-9].[0-9].1${mansuffix}"
+
+ python_mod_cleanup /usr/lib/python${PYVER}
+ [[ "$(get_libdir)" == "lib" ]] || \
+ python_mod_cleanup /usr/$(get_libdir)/python${PYVER}
+}
+
+pkg_postinst() {
+ local myroot
+ myroot=$(echo $ROOT | sed 's:/$::')
+ local mansuffix=$(ecompress --suffix)
+
+ python_makesym
+ alternatives_auto_makesym "/usr/bin/idle" "idle[0-9].[0-9]"
+ alternatives_auto_makesym "/usr/bin/pydoc" "pydoc[0-9].[0-9]"
+ alternatives_auto_makesym "/usr/bin/python-config" \
+ "python-config-[0-9].[0-9]"
+
+ alternatives_auto_makesym "/usr/share/man/man1/python.1${mansuffix}" \
+ "python[0-9].[0-9].1${mansuffix}"
+
+ python_mod_optimize
+ python_mod_optimize -x "(site-packages|test)" \
+ /usr/lib/python${PYVER}
+ [[ "$(get_libdir)" == "lib" ]] || \
+ python_mod_optimize -x "(site-packages|test)" \
+ /usr/$(get_libdir)/python${PYVER}
+
+ # workaround possible python-upgrade-breaks-portage situation
+ if [ ! -f ${myroot}/usr/lib/portage/pym/portage.py ]; then
+ if [ -f ${myroot}/usr/lib/python2.3/site-packages/portage.py ]; then
+ einfo "Working around possible python-portage upgrade breakage"
+ mkdir -p ${myroot}/usr/lib/portage/pym
+ cp ${myroot}/usr/lib/python2.4/site-packages/{portage,xpak,output,cvstree,getbinpkg,emergehelp,dispatch_conf}.py ${myroot}/usr/lib/portage/pym
+ python_mod_optimize /usr/lib/portage/pym
+ fi
+ fi
+
+ echo
+ ewarn
+ ewarn "If you have just upgraded from an older version of python you will"
+ ewarn "need to run:"
+ ewarn
+ ewarn "/usr/sbin/python-updater"
+ ewarn
+ ewarn "This will automatically rebuild all the python dependent modules"
+ ewarn "to run with python-${PYVER}."
+ ewarn
+ ewarn "Your original Python is still installed and can be accessed via"
+ ewarn "/usr/bin/python2.x."
+ ewarn
+ ebeep 5
+}
+
+src_test() {
+ # Tests won't work when cross compiling
+ if tc-is-cross-compiler ; then
+ elog "Disabling tests due to crosscompiling."
+ return
+ fi
+
+ # Disabling byte compiling breaks test_import
+ python_enable_pyc
+
+ #skip all tests that fail during emerge but pass without emerge:
+ #(See bug# 67970)
+ local skip_tests="distutils global mimetools minidom mmap posix pyexpat sax strptime subprocess syntax tcl time urllib urllib2 webbrowser xml_etree"
+
+ # test_pow fails on alpha.
+ # http://bugs.python.org/issue756093
+ [[ ${ARCH} == "alpha" ]] && skip_tests="${skip_tests} pow"
+
+ for test in ${skip_tests} ; do
+ mv "${S}"/Lib/test/test_${test}.py "${T}"
+ done
+
+ # rerun failed tests in verbose mode (regrtest -w)
+ EXTRATESTOPTS="-w" make test || die "make test failed"
+
+ for test in ${skip_tests} ; do
+ mv "${T}"/test_${test}.py "${S}"/Lib/test/test_${test}.py
+ done
+
+ elog "Portage skipped the following tests which aren't able to run from emerge:"
+ for test in ${skip_tests} ; do
+ elog "test_${test}.py"
+ done
+
+ elog "If you'd like to run them, you may:"
+ elog "cd /usr/lib/python${PYVER}/test"
+ elog "and run the tests separately."
+}