# HG changeset patch # User Jan Nieuwenhuizen # Date 1346076311 -7200 # Node ID a4dfe4e574ec88a8564fb57b5de5345b53e632af # Parent d4129de9433831320777a97f6c0bf38e4ed0b5b6 python: setup.py handle cross compilation. Fixes /usr-dependencies. This also removes the need for dbm and crypt fixes (actually, crypt and nis should not build, as we do not have those libraries in GUB). diff -r d4129de94338 -r a4dfe4e574ec gub/specs/python.py --- a/gub/specs/python.py Mon Aug 27 15:47:39 2012 +0200 +++ b/gub/specs/python.py Mon Aug 27 16:05:11 2012 +0200 @@ -30,6 +30,7 @@ 'python-2.4.5-python-2.6.patch', 'python-2.4.5-native.patch', 'python-2.4.5-db4.7.patch', + 'python-2.4.5-setup-cross.patch', ] dependencies = ['db-devel', 'expat-devel', 'zlib-devel', 'tools::python'] force_autoupdate = True @@ -39,6 +40,7 @@ 'struct', 'time', ] + not_supported = [] make_flags = misc.join_lines (r''' BLDLIBRARY='%(rpath)s -L. -lpython$(VERSION)' ''') @@ -50,7 +52,7 @@ + target.AutoBuild.install_command) def patch (self): target.AutoBuild.patch (self) - self.file_sub ([('@CC@', '@CC@ -I$(shell pwd)')], + self.file_sub ([('@CC@', '@CC@ -I%(builddir)s')], '%(srcdir)s/Makefile.pre.in') def autoupdate (self): target.AutoBuild.autoupdate (self) @@ -66,6 +68,10 @@ so = self.expand ('%(so_extension)s') all = [x.replace (dynload_dir + '/', '') for x in misc.find_files (dynload_dir, '.*' + so)] failed = [x.replace (dynload_dir + '/', '') for x in misc.find_files (dynload_dir, '.*failed' + so)] + for i in self.not_supported: + m = i + '_failed' + so + if m in failed: + failed.remove (m) if failed: logger.write_log ('failed python modules:' + ', '.join (failed), 'error') for module in self.so_modules: @@ -180,6 +186,7 @@ 'python-2.4.5-readline.patch', # Stop python from reading ~/.inputrc 'python-2.4.5-db4.7.patch', 'python-2.4.5-regen.patch', + 'python-2.4.5-setup-cross.patch', ] dependencies = [ 'autoconf', @@ -188,6 +195,7 @@ ] force_autoupdate = True parallel_build_broken = True + not_supported = ['nis', 'crypt'] make_flags = Python.make_flags def patch (self): Python.patch (self) diff -r d4129de94338 -r a4dfe4e574ec patches/python-2.4.5-setup-cross.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/python-2.4.5-setup-cross.patch Mon Aug 27 16:05:11 2012 +0200 @@ -0,0 +1,102 @@ +Teach the python module compiler setup.py about cross compilation. + +--- python-2.4.5/setup.py~ 2012-08-27 11:07:07.049617420 +0200 ++++ python-2.4.5/setup.py 2012-08-27 11:46:45.350781819 +0200 +@@ -14,6 +14,20 @@ + from distutils.command.install import install + from distutils.command.install_lib import install_lib + ++def exists_in_sysroot (f): ++ print >>sys.stderr, 'GUB: ', f ++ print >>sys.stderr, 'targetdir', os.environ.get ('targetdir', '') ++ print >>sys.stderr, 'system_root', os.environ.get ('system_root', '') ++ if (f.startswith ('/') ++ and not f.startswith (os.environ.get ('alltargetdir', ''))): ++ f = os.environ.get ('system_root', '') + f ++ print >>sys.stderr, 'GUB: looking for', f ++ if os_path_exists (f): ++ return f ++ return False ++os_path_exists = os.path.exists ++os.path.exists = exists_in_sysroot ++ + # This global variable is used to hold the list of modules to be disabled. + disabled_module_list = [] + +@@ -58,13 +58,14 @@ def find_file(filename, std_dirs, paths) + # Check the standard locations + for dir in std_dirs: + f = os.path.join(dir, filename) +- if os.path.exists(f): return [] ++ if os.path.exists(f): ++ return [os.path.exists(dir)] + + # Check the additional directories + for dir in paths: + f = os.path.join(dir, filename) + if os.path.exists(f): +- return [dir] ++ return [os.path.exists (dir)] + + # Not found anywhere + return None +@@ -590,7 +590,8 @@ + for d in inc_dirs + db_inc_paths: + f = os.path.join(d, "db.h") + if db_setup_debug: print "db: looking for db.h in", f +- if os.path.exists(f): ++ f = os.path.exists(f) ++ if f: + f = open(f).read() + m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f) + if m: +@@ -629,7 +632,7 @@ class PyBuildExt(build_ext): + (db_ver <= max_db_ver and db_ver >= min_db_ver) ): + # save the include directory with the db.h version + # (first occurrance only) +- db_ver_inc_map[db_ver] = d ++ db_ver_inc_map[db_ver] = os.path.exists (d) + print "db.h: found", db_ver, "in", d + else: + # we already found a header for this library version +@@ -673,7 +674,8 @@ + # underlying db library. May BSD-ish Unixes incorporate db 1.85 + # symbols into libc and place the include file in /usr/include. + f = "/usr/include/db.h" +- if os.path.exists(f): ++ f = os.path.exists(f) ++ if f: + data = open(f).read() + m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data) + if m is not None: +--- python-2.4.5/Makefile.pre.in~ 2012-08-27 18:01:49.608729518 +0200 ++++ python-2.4.5/Makefile.pre.in 2012-08-27 18:06:05.118707910 +0200 +@@ -895,7 +895,7 @@ sharedinstall: + --prefix=$(prefix) \ + --install-scripts=$(BINDIR) \ + --install-platlib=$(DESTSHARED) \ +- --root=/$(DESTDIR) ++ --root=$(DESTDIR) + + # Here are a couple of targets for MacOSX again, to install a full + # framework-based Python. frameworkinstall installs everything, the +@@ -965,7 +965,7 @@ scriptsinstall: + ./$(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \ + --prefix=$(prefix) \ + --install-scripts=$(BINDIR) \ +- --root=/$(DESTDIR) ++ --root=$(DESTDIR) + + # Build the toplevel Makefile + Makefile.pre: Makefile.pre.in config.status +--- python-2.4.5/Lib/distutils/unixccompiler.py~ 2012-08-27 21:51:36.950636210 +0200 ++++ python-2.4.5/Lib/distutils/unixccompiler.py 2012-08-27 21:50:00.732128349 +0200 +@@ -249,7 +249,7 @@ + # this time, there's no way to determine this information from + # the configuration data stored in the Python installation, so + # we use this hack. +- compiler = os.path.basename(sysconfig.get_config_var("CC")) ++ compiler = os.path.basename(sysconfig.get_config_var("CC").split ()[0]) + if sys.platform[:6] == "darwin": + # MacOSX's linker doesn't understand the -R flag at all + return "-L" + dir