summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/python/python')
-rw-r--r--meta/recipes-devtools/python/python/00-fix-bindir-libdir-for-cross.patch20
-rw-r--r--meta/recipes-devtools/python/python/01-use-proper-tools-for-cross-build.patch116
-rw-r--r--meta/recipes-devtools/python/python/02-remove-test-for-cross.patch106
-rw-r--r--meta/recipes-devtools/python/python/03-fix-tkinter-detection.patch40
-rw-r--r--meta/recipes-devtools/python/python/04-default-is-optimized.patch52
-rw-r--r--meta/recipes-devtools/python/python/05-enable-ctypes-cross-build.patch28
-rw-r--r--meta/recipes-devtools/python/python/99-ignore-optimization-flag.patch19
-rw-r--r--meta/recipes-devtools/python/python/sitecustomize.py45
8 files changed, 426 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python/00-fix-bindir-libdir-for-cross.patch b/meta/recipes-devtools/python/python/00-fix-bindir-libdir-for-cross.patch
new file mode 100644
index 0000000000..2559e3a0e4
--- /dev/null
+++ b/meta/recipes-devtools/python/python/00-fix-bindir-libdir-for-cross.patch
@@ -0,0 +1,20 @@
1# $(exec_prefix) points to the wrong directory, when installing
2# a cross-build. @bindir@ and @libdir@ works better and doesn't
3# affect the native build.
4# Signed-Off: Michael 'Mickey' Lauer <mickey@vanille-media.de>
5
6Index: Python-2.6.1/Makefile.pre.in
7===================================================================
8--- Python-2.6.1.orig/Makefile.pre.in
9+++ Python-2.6.1/Makefile.pre.in
10@@ -86,8 +86,8 @@ exec_prefix= @exec_prefix@
11 datarootdir= @datarootdir@
12
13 # Expanded directories
14-BINDIR= $(exec_prefix)/bin
15-LIBDIR= $(exec_prefix)/lib
16+BINDIR= @bindir@
17+LIBDIR= @libdir@
18 MANDIR= @mandir@
19 INCLUDEDIR= @includedir@
20 CONFINCLUDEDIR= $(exec_prefix)/include
diff --git a/meta/recipes-devtools/python/python/01-use-proper-tools-for-cross-build.patch b/meta/recipes-devtools/python/python/01-use-proper-tools-for-cross-build.patch
new file mode 100644
index 0000000000..e89faa4fb0
--- /dev/null
+++ b/meta/recipes-devtools/python/python/01-use-proper-tools-for-cross-build.patch
@@ -0,0 +1,116 @@
1# We need to ensure our host tools get run during build, not the freshly
2# built cross-tools (this will not work), so we introduce HOSTPYTHON and HOSTPGEN.
3# Signed-Off: Michael 'Mickey' Lauer <mickey@vanille-media.de>
4
5Index: Python-2.6.1/Makefile.pre.in
6===================================================================
7--- Python-2.6.1.orig/Makefile.pre.in
8+++ Python-2.6.1/Makefile.pre.in
9@@ -175,6 +175,7 @@ UNICODE_OBJS= @UNICODE_OBJS@
10
11 PYTHON= python$(EXE)
12 BUILDPYTHON= python$(BUILDEXE)
13+HOSTPYTHON= $(BUILDPYTHON)
14
15 # The task to run while instrument when building the profile-opt target
16 PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
17@@ -205,7 +206,7 @@ GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
18 ##########################################################################
19 # Parser
20 PGEN= Parser/pgen$(EXE)
21-
22+HOSTPGEN= $(PGEN)$(EXE)
23 POBJS= \
24 Parser/acceler.o \
25 Parser/grammar1.o \
26@@ -394,8 +395,8 @@ platform: $(BUILDPYTHON)
27 # Build the shared modules
28 sharedmods: $(BUILDPYTHON)
29 @case $$MAKEFLAGS in \
30- *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
31- *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
32+ *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(HOSTPYTHON) -E $(srcdir)/setup.py -q build;; \
33+ *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(HOSTPYTHON) -E $(srcdir)/setup.py build;; \
34 esac
35
36 # Build static library
37@@ -513,7 +514,7 @@ Modules/python.o: $(srcdir)/Modules/pyth
38
39 $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
40 -@$(INSTALL) -d Include
41- -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
42+ -$(HOSTPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
43
44 $(PGEN): $(PGENOBJS)
45 $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
46@@ -879,23 +880,23 @@ libinstall: build_all $(srcdir)/Lib/$(PL
47 done
48 $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
49 PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
50- ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
51+ $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
52 -d $(LIBDEST) -f \
53 -x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
54 PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
55- ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
56+ $(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
57 -d $(LIBDEST) -f \
58 -x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
59 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
60- ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
61+ $(HOSTPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
62 -d $(LIBDEST)/site-packages -f \
63 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
64 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
65- ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
66+ $(HOSTPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
67 -d $(LIBDEST)/site-packages -f \
68 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
69 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
70- ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
71+ $(HOSTPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
72
73 # Create the PLATDIR source directory, if one wasn't distributed..
74 $(srcdir)/Lib/$(PLATDIR):
75@@ -993,7 +994,7 @@ libainstall: all
76 # Install the dynamically loadable modules
77 # This goes into $(exec_prefix)
78 sharedinstall:
79- $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
80+ $(RUNSHARED) $(HOSTPYTHON) -E $(srcdir)/setup.py install \
81 --prefix=$(prefix) \
82 --install-scripts=$(BINDIR) \
83 --install-platlib=$(DESTSHARED) \
84Index: Python-2.6.1/setup.py
85===================================================================
86--- Python-2.6.1.orig/setup.py
87+++ Python-2.6.1/setup.py
88@@ -276,6 +276,7 @@ class PyBuildExt(build_ext):
89 self.failed.append(ext.name)
90 self.announce('*** WARNING: renaming "%s" since importing it'
91 ' failed: %s' % (ext.name, why), level=3)
92+ return
93 assert not self.inplace
94 basename, tail = os.path.splitext(ext_filename)
95 newname = basename + "_failed" + tail
96@@ -310,8 +311,8 @@ class PyBuildExt(build_ext):
97
98 def detect_modules(self):
99 # Ensure that /usr/local is always used
100- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
101- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
102+ # add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
103+ # add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
104
105 # Add paths specified in the environment variables LDFLAGS and
106 # CPPFLAGS for header and library files.
107@@ -410,6 +411,9 @@ class PyBuildExt(build_ext):
108
109 # XXX Omitted modules: gl, pure, dl, SGI-specific modules
110
111+ lib_dirs = [ os.getenv( "STAGING_LIBDIR" ) ]
112+ inc_dirs = [ os.getenv( "STAGING_INCDIR" ) ]
113+
114 #
115 # The following modules are all pretty straightforward, and compile
116 # on pretty much any POSIXish platform.
diff --git a/meta/recipes-devtools/python/python/02-remove-test-for-cross.patch b/meta/recipes-devtools/python/python/02-remove-test-for-cross.patch
new file mode 100644
index 0000000000..b1c0bfb859
--- /dev/null
+++ b/meta/recipes-devtools/python/python/02-remove-test-for-cross.patch
@@ -0,0 +1,106 @@
1# OpenEmbedded prepopulates the autotools site cache, so if this
2# would be using AC_TRY_CACHE, we could patch it in a more sane way
3# Alas, I don't have enough autotalent to do that.
4#
5# Signed-Off: Michael 'Mickey' Lauer <mickey@vanille-media.de>
6Index: Python-2.6.1/configure.in
7===================================================================
8--- Python-2.6.5.orig/configure.in 2010-07-06 04:37:09.000000000 -0700
9+++ Python-2.6.5/configure.in 2010-07-06 04:40:18.000000000 -0700
10@@ -2697,50 +2697,6 @@
11 AC_CHECK_LIB(resolv, inet_aton)
12 )
13
14-# On Tru64, chflags seems to be present, but calling it will
15-# exit Python
16-AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
17-AC_TRY_RUN([[
18-#include <sys/stat.h>
19-#include <unistd.h>
20-int main(int argc, char*argv[])
21-{
22- if(chflags(argv[0], 0) != 0)
23- return 1;
24- return 0;
25-}
26-]], ac_cv_have_chflags=yes,
27- ac_cv_have_chflags=no,
28- ac_cv_have_chflags=cross)
29-])
30-if test "$ac_cv_have_chflags" = cross ; then
31- AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
32-fi
33-if test "$ac_cv_have_chflags" = yes ; then
34- AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
35-fi
36-
37-AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
38-AC_TRY_RUN([[
39-#include <sys/stat.h>
40-#include <unistd.h>
41-int main(int argc, char*argv[])
42-{
43- if(lchflags(argv[0], 0) != 0)
44- return 1;
45- return 0;
46-}
47-]], ac_cv_have_lchflags=yes,
48- ac_cv_have_lchflags=no,
49- ac_cv_have_lchflags=cross)
50-])
51-if test "$ac_cv_have_lchflags" = cross ; then
52- AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
53-fi
54-if test "$ac_cv_have_lchflags" = yes ; then
55- AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
56-fi
57-
58 dnl Check if system zlib has *Copy() functions
59 dnl
60 dnl On MacOSX the linker will search for dylibs on the entire linker path
61@@ -3844,45 +3800,6 @@
62 AC_MSG_RESULT(no)
63 fi
64
65-AC_MSG_CHECKING(for %zd printf() format support)
66-AC_TRY_RUN([#include <stdio.h>
67-#include <stddef.h>
68-#include <string.h>
69-
70-#ifdef HAVE_SYS_TYPES_H
71-#include <sys/types.h>
72-#endif
73-
74-#ifdef HAVE_SSIZE_T
75-typedef ssize_t Py_ssize_t;
76-#elif SIZEOF_VOID_P == SIZEOF_LONG
77-typedef long Py_ssize_t;
78-#else
79-typedef int Py_ssize_t;
80-#endif
81-
82-int main()
83-{
84- char buffer[256];
85-
86- if(sprintf(buffer, "%zd", (size_t)123) < 0)
87- return 1;
88-
89- if (strcmp(buffer, "123"))
90- return 1;
91-
92- if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
93- return 1;
94-
95- if (strcmp(buffer, "-123"))
96- return 1;
97-
98- return 0;
99-}],
100-[AC_MSG_RESULT(yes)
101- AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
102- AC_MSG_RESULT(no))
103-
104 AC_CHECK_TYPE(socklen_t,,
105 AC_DEFINE(socklen_t,int,
106 Define to `int' if <sys/socket.h> does not define.),[
diff --git a/meta/recipes-devtools/python/python/03-fix-tkinter-detection.patch b/meta/recipes-devtools/python/python/03-fix-tkinter-detection.patch
new file mode 100644
index 0000000000..a1a385a07c
--- /dev/null
+++ b/meta/recipes-devtools/python/python/03-fix-tkinter-detection.patch
@@ -0,0 +1,40 @@
1# We need to supply STAGING_INCDIR here, otherwise the Tk headers
2# will not be found.
3# Signed-Off: Michael 'Mickey' Lauer <mickey@vanille.de>
4
5Index: Python-2.6.1/setup.py
6===================================================================
7--- Python-2.6.1.orig/setup.py
8+++ Python-2.6.1/setup.py
9@@ -1543,7 +1543,7 @@ class PyBuildExt(build_ext):
10 dotversion = dotversion[:-1] + '.' + dotversion[-1]
11 tcl_include_sub = []
12 tk_include_sub = []
13- for dir in inc_dirs:
14+ for dir in [os.getenv("STAGING_INCDIR")]:
15 tcl_include_sub += [dir + os.sep + "tcl" + dotversion]
16 tk_include_sub += [dir + os.sep + "tk" + dotversion]
17 tk_include_sub += tcl_include_sub
18@@ -1562,22 +1562,6 @@ class PyBuildExt(build_ext):
19 if dir not in include_dirs:
20 include_dirs.append(dir)
21
22- # Check for various platform-specific directories
23- if platform == 'sunos5':
24- include_dirs.append('/usr/openwin/include')
25- added_lib_dirs.append('/usr/openwin/lib')
26- elif os.path.exists('/usr/X11R6/include'):
27- include_dirs.append('/usr/X11R6/include')
28- added_lib_dirs.append('/usr/X11R6/lib64')
29- added_lib_dirs.append('/usr/X11R6/lib')
30- elif os.path.exists('/usr/X11R5/include'):
31- include_dirs.append('/usr/X11R5/include')
32- added_lib_dirs.append('/usr/X11R5/lib')
33- else:
34- # Assume default location for X11
35- include_dirs.append('/usr/X11/include')
36- added_lib_dirs.append('/usr/X11/lib')
37-
38 # If Cygwin, then verify that X is installed before proceeding
39 if platform == 'cygwin':
40 x11_inc = find_file('X11/Xlib.h', [], include_dirs)
diff --git a/meta/recipes-devtools/python/python/04-default-is-optimized.patch b/meta/recipes-devtools/python/python/04-default-is-optimized.patch
new file mode 100644
index 0000000000..805f4f696c
--- /dev/null
+++ b/meta/recipes-devtools/python/python/04-default-is-optimized.patch
@@ -0,0 +1,52 @@
1# when compiling for an embedded system, we need every bit of
2# performance we can get. default to optimized with the option
3# of opt-out.
4# Signed-Off: Michael 'Mickey' Lauer <mickey@vanille-media.de>
5
6Index: Python-2.6.1/Python/compile.c
7===================================================================
8--- Python-2.6.1.orig/Python/compile.c
9+++ Python-2.6.1/Python/compile.c
10@@ -32,7 +32,7 @@
11 #include "symtable.h"
12 #include "opcode.h"
13
14-int Py_OptimizeFlag = 0;
15+int Py_OptimizeFlag = 1;
16
17 #define DEFAULT_BLOCK_SIZE 16
18 #define DEFAULT_BLOCKS 8
19Index: Python-2.6.1/Modules/main.c
20===================================================================
21--- Python-2.6.1.orig/Modules/main.c
22+++ Python-2.6.1/Modules/main.c
23@@ -40,7 +40,7 @@ static char **orig_argv;
24 static int orig_argc;
25
26 /* command line options */
27-#define BASE_OPTS "3bBc:dEhiJm:OQ:sStuUvVW:xX?"
28+#define BASE_OPTS "3bBc:dEhiJm:NOQ:sStuUvVW:xX?"
29
30 #ifndef RISCOS
31 #define PROGRAM_OPTS BASE_OPTS
32@@ -69,8 +69,7 @@ Options and arguments (and corresponding
33 static char *usage_2 = "\
34 if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\
35 -m mod : run library module as a script (terminates option list)\n\
36--O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\
37--OO : remove doc-strings in addition to the -O optimizations\n\
38+-N : do NOT optimize generated bytecode\n\
39 -Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\
40 -s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\
41 -S : don't imply 'import site' on initialization\n\
42@@ -353,8 +352,8 @@ Py_Main(int argc, char **argv)
43
44 /* case 'J': reserved for Jython */
45
46- case 'O':
47- Py_OptimizeFlag++;
48+ case 'N':
49+ Py_OptimizeFlag=0;
50 break;
51
52 case 'B':
diff --git a/meta/recipes-devtools/python/python/05-enable-ctypes-cross-build.patch b/meta/recipes-devtools/python/python/05-enable-ctypes-cross-build.patch
new file mode 100644
index 0000000000..58b8078068
--- /dev/null
+++ b/meta/recipes-devtools/python/python/05-enable-ctypes-cross-build.patch
@@ -0,0 +1,28 @@
1# CTypes need to know the actual host we are building on.
2# Signed-Off: Michael Dietrich <mdt@emdete.de>
3
4Index: Python-2.6.1/setup.py
5===================================================================
6--- Python-2.6.1.orig/setup.py
7+++ Python-2.6.1/setup.py
8@@ -1656,16 +1656,16 @@ class PyBuildExt(build_ext):
9 ffi_configfile):
10 from distutils.dir_util import mkpath
11 mkpath(ffi_builddir)
12- config_args = []
13+ config_args = ['--host=%s' % os.environ["HOST_SYS"], ]
14
15 # Pass empty CFLAGS because we'll just append the resulting
16 # CFLAGS to Python's; -g or -O2 is to be avoided.
17- cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
18- % (ffi_builddir, ffi_srcdir, " ".join(config_args))
19+ cmd = "(cd %s && autoconf -W cross) && (cd %s && env CFLAGS='' '%s/configure' %s)" \
20+ % (ffi_srcdir, ffi_builddir, ffi_srcdir, " ".join(config_args))
21
22 res = os.system(cmd)
23 if res or not os.path.exists(ffi_configfile):
24- print "Failed to configure _ctypes module"
25+ print "Failed to configure _ctypes module (res=%d) or missing conffile=%s" % ( res, ffi_configfile )
26 return False
27
28 fficonfig = {}
diff --git a/meta/recipes-devtools/python/python/99-ignore-optimization-flag.patch b/meta/recipes-devtools/python/python/99-ignore-optimization-flag.patch
new file mode 100644
index 0000000000..02dc44c847
--- /dev/null
+++ b/meta/recipes-devtools/python/python/99-ignore-optimization-flag.patch
@@ -0,0 +1,19 @@
1# Reinstate the empty -O option to fix weird mixing of native and target
2# binaries and libraries with LD_LIBRARY_PATH when host==target
3#
4# Signed-off-by: Denys Dmytriyenko <denis@denix.org>
5
6Index: Python-2.6.1/Modules/main.c
7===================================================================
8--- Python-2.6.1-orig/Modules/main.c
9+++ Python-2.6.1/Modules/main.c
10@@ -352,6 +352,9 @@ Py_Main(int argc, char **argv)
11
12 /* case 'J': reserved for Jython */
13
14+ case 'O': /* ignore it */
15+ break;
16+
17 case 'N':
18 Py_OptimizeFlag=0;
19 break;
diff --git a/meta/recipes-devtools/python/python/sitecustomize.py b/meta/recipes-devtools/python/python/sitecustomize.py
new file mode 100644
index 0000000000..273901898a
--- /dev/null
+++ b/meta/recipes-devtools/python/python/sitecustomize.py
@@ -0,0 +1,45 @@
1# OpenEmbedded sitecustomize.py (C) 2002-2008 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
2# GPLv2 or later
3# Version: 20081123
4# Features:
5# * set proper default encoding
6# * enable readline completion in the interactive interpreter
7# * load command line history on startup
8# * save command line history on exit
9
10import os
11
12def __exithandler():
13 try:
14 readline.write_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) )
15 except IOError:
16 pass
17
18def __registerExitHandler():
19 import atexit
20 atexit.register( __exithandler )
21
22def __enableReadlineSupport():
23 readline.set_history_length( 1000 )
24 readline.parse_and_bind( "tab: complete" )
25 try:
26 readline.read_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) )
27 except IOError:
28 pass
29
30def __enableDefaultEncoding():
31 import sys
32 try:
33 sys.setdefaultencoding( "utf8" )
34 except LookupError:
35 pass
36
37import sys
38try:
39 import rlcompleter, readline
40except ImportError:
41 pass
42else:
43 __enableDefaultEncoding()
44 __registerExitHandler()
45 __enableReadlineSupport()