diff options
Diffstat (limited to 'meta-extras/packages/python/python-2.5.2')
8 files changed, 405 insertions, 0 deletions
diff --git a/meta-extras/packages/python/python-2.5.2/autohell.patch b/meta-extras/packages/python/python-2.5.2/autohell.patch new file mode 100644 index 0000000000..32977955d4 --- /dev/null +++ b/meta-extras/packages/python/python-2.5.2/autohell.patch | |||
@@ -0,0 +1,50 @@ | |||
1 | Index: Python-2.5.2/configure.in | ||
2 | =================================================================== | ||
3 | --- Python-2.5.2.orig/configure.in | ||
4 | +++ Python-2.5.2/configure.in | ||
5 | @@ -3410,45 +3410,6 @@ esac | ||
6 | |||
7 | |||
8 | |||
9 | -AC_MSG_CHECKING(for %zd printf() format support) | ||
10 | -AC_TRY_RUN([#include <stdio.h> | ||
11 | -#include <stddef.h> | ||
12 | -#include <string.h> | ||
13 | - | ||
14 | -#ifdef HAVE_SYS_TYPES_H | ||
15 | -#include <sys/types.h> | ||
16 | -#endif | ||
17 | - | ||
18 | -#ifdef HAVE_SSIZE_T | ||
19 | -typedef ssize_t Py_ssize_t; | ||
20 | -#elif SIZEOF_VOID_P == SIZEOF_LONG | ||
21 | -typedef long Py_ssize_t; | ||
22 | -#else | ||
23 | -typedef int Py_ssize_t; | ||
24 | -#endif | ||
25 | - | ||
26 | -int main() | ||
27 | -{ | ||
28 | - char buffer[256]; | ||
29 | - | ||
30 | - if(sprintf(buffer, "%zd", (size_t)123) < 0) | ||
31 | - return 1; | ||
32 | - | ||
33 | - if (strcmp(buffer, "123")) | ||
34 | - return 1; | ||
35 | - | ||
36 | - if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) | ||
37 | - return 1; | ||
38 | - | ||
39 | - if (strcmp(buffer, "-123")) | ||
40 | - return 1; | ||
41 | - | ||
42 | - return 0; | ||
43 | -}], | ||
44 | -[AC_MSG_RESULT(yes) | ||
45 | - AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])], | ||
46 | - AC_MSG_RESULT(no)) | ||
47 | - | ||
48 | AC_CHECK_TYPE(socklen_t,, | ||
49 | AC_DEFINE(socklen_t,int, | ||
50 | Define to `int' if <sys/socket.h> does not define.),[ | ||
diff --git a/meta-extras/packages/python/python-2.5.2/bindir-libdir.patch b/meta-extras/packages/python/python-2.5.2/bindir-libdir.patch new file mode 100644 index 0000000000..047c358a55 --- /dev/null +++ b/meta-extras/packages/python/python-2.5.2/bindir-libdir.patch | |||
@@ -0,0 +1,20 @@ | |||
1 | |||
2 | # | ||
3 | # Patch managed by http://www.holgerschurig.de/patcher.html | ||
4 | # | ||
5 | |||
6 | Index: Python-2.5.1/Makefile.pre.in | ||
7 | =================================================================== | ||
8 | --- Python-2.5.1.orig/Makefile.pre.in | ||
9 | +++ Python-2.5.1/Makefile.pre.in | ||
10 | @@ -83,8 +83,8 @@ prefix= @prefix@ | ||
11 | exec_prefix= @exec_prefix@ | ||
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-extras/packages/python/python-2.5.2/crosscompile.patch b/meta-extras/packages/python/python-2.5.2/crosscompile.patch new file mode 100644 index 0000000000..f1b1c6f3e0 --- /dev/null +++ b/meta-extras/packages/python/python-2.5.2/crosscompile.patch | |||
@@ -0,0 +1,110 @@ | |||
1 | # | ||
2 | # Patch (C) by Michael 'Mickey' Lauer <mlauer@vanille-media.de> | ||
3 | # | ||
4 | Index: Python-2.5.2/Makefile.pre.in | ||
5 | =================================================================== | ||
6 | --- Python-2.5.2.orig/Makefile.pre.in | ||
7 | +++ Python-2.5.2/Makefile.pre.in | ||
8 | @@ -173,6 +173,7 @@ UNICODE_OBJS= @UNICODE_OBJS@ | ||
9 | |||
10 | PYTHON= python$(EXE) | ||
11 | BUILDPYTHON= python$(BUILDEXE) | ||
12 | +HOSTPYTHON= $(BUILDPYTHON) | ||
13 | |||
14 | # === Definitions added by makesetup === | ||
15 | |||
16 | @@ -199,7 +200,7 @@ GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar | ||
17 | ########################################################################## | ||
18 | # Parser | ||
19 | PGEN= Parser/pgen$(EXE) | ||
20 | - | ||
21 | +HOSTPGEN= $(PGEN)$(EXE) | ||
22 | POBJS= \ | ||
23 | Parser/acceler.o \ | ||
24 | Parser/grammar1.o \ | ||
25 | @@ -348,8 +349,8 @@ platform: $(BUILDPYTHON) | ||
26 | # Build the shared modules | ||
27 | sharedmods: $(BUILDPYTHON) | ||
28 | case $$MAKEFLAGS in \ | ||
29 | - *-s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \ | ||
30 | - *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \ | ||
31 | + *-s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(HOSTPYTHON) -E $(srcdir)/setup.py -q build;; \ | ||
32 | + *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(HOSTPYTHON) -E $(srcdir)/setup.py build;; \ | ||
33 | esac | ||
34 | |||
35 | # Build static library | ||
36 | @@ -474,7 +475,7 @@ Modules/python.o: $(srcdir)/Modules/pyth | ||
37 | |||
38 | $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT) | ||
39 | -@ mkdir Include | ||
40 | - -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) | ||
41 | + -$(HOSTPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) | ||
42 | |||
43 | $(PGEN): $(PGENOBJS) | ||
44 | $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN) | ||
45 | @@ -782,19 +783,19 @@ libinstall: $(BUILDPYTHON) $(srcdir)/Lib | ||
46 | done | ||
47 | $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt | ||
48 | PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ | ||
49 | - ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ | ||
50 | + $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ | ||
51 | -d $(LIBDEST) -f \ | ||
52 | -x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST) | ||
53 | PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ | ||
54 | - ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \ | ||
55 | + $(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \ | ||
56 | -d $(LIBDEST) -f \ | ||
57 | -x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST) | ||
58 | -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ | ||
59 | - ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ | ||
60 | + $(HOSTPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ | ||
61 | -d $(LIBDEST)/site-packages -f \ | ||
62 | -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages | ||
63 | -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ | ||
64 | - ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ | ||
65 | + $(HOSTPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ | ||
66 | -d $(LIBDEST)/site-packages -f \ | ||
67 | -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages | ||
68 | |||
69 | @@ -894,7 +895,7 @@ libainstall: all | ||
70 | # Install the dynamically loadable modules | ||
71 | # This goes into $(exec_prefix) | ||
72 | sharedinstall: | ||
73 | - $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \ | ||
74 | + $(RUNSHARED) $(HOSTPYTHON) -E $(srcdir)/setup.py install \ | ||
75 | --prefix=$(prefix) \ | ||
76 | --install-scripts=$(BINDIR) \ | ||
77 | --install-platlib=$(DESTSHARED) \ | ||
78 | Index: Python-2.5.2/setup.py | ||
79 | =================================================================== | ||
80 | --- Python-2.5.2.orig/setup.py | ||
81 | +++ Python-2.5.2/setup.py | ||
82 | @@ -211,6 +211,7 @@ class PyBuildExt(build_ext): | ||
83 | except ImportError, why: | ||
84 | self.announce('*** WARNING: renaming "%s" since importing it' | ||
85 | ' failed: %s' % (ext.name, why), level=3) | ||
86 | + return | ||
87 | assert not self.inplace | ||
88 | basename, tail = os.path.splitext(ext_filename) | ||
89 | newname = basename + "_failed" + tail | ||
90 | @@ -244,8 +245,8 @@ class PyBuildExt(build_ext): | ||
91 | |||
92 | def detect_modules(self): | ||
93 | # Ensure that /usr/local is always used | ||
94 | - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') | ||
95 | - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') | ||
96 | + # add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') | ||
97 | + # add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') | ||
98 | |||
99 | # Add paths specified in the environment variables LDFLAGS and | ||
100 | # CPPFLAGS for header and library files. | ||
101 | @@ -342,6 +343,9 @@ class PyBuildExt(build_ext): | ||
102 | |||
103 | # XXX Omitted modules: gl, pure, dl, SGI-specific modules | ||
104 | |||
105 | + lib_dirs = [ os.getenv( "STAGING_LIBDIR" ) ] | ||
106 | + inc_dirs = [ os.getenv( "STAGING_INCDIR" ) ] | ||
107 | + | ||
108 | # | ||
109 | # The following modules are all pretty straightforward, and compile | ||
110 | # on pretty much any POSIXish platform. | ||
diff --git a/meta-extras/packages/python/python-2.5.2/default-is-optimized.patch b/meta-extras/packages/python/python-2.5.2/default-is-optimized.patch new file mode 100644 index 0000000000..6beeb6e022 --- /dev/null +++ b/meta-extras/packages/python/python-2.5.2/default-is-optimized.patch | |||
@@ -0,0 +1,13 @@ | |||
1 | Index: Python-2.5.1/Python/compile.c | ||
2 | =================================================================== | ||
3 | --- Python-2.5.1.orig/Python/compile.c | ||
4 | +++ Python-2.5.1/Python/compile.c | ||
5 | @@ -30,7 +30,7 @@ | ||
6 | #include "symtable.h" | ||
7 | #include "opcode.h" | ||
8 | |||
9 | -int Py_OptimizeFlag = 0; | ||
10 | +int Py_OptimizeFlag = 1; | ||
11 | |||
12 | /* | ||
13 | ISSUES: | ||
diff --git a/meta-extras/packages/python/python-2.5.2/enable-ctypes-module.patch b/meta-extras/packages/python/python-2.5.2/enable-ctypes-module.patch new file mode 100644 index 0000000000..dd5adaf0e7 --- /dev/null +++ b/meta-extras/packages/python/python-2.5.2/enable-ctypes-module.patch | |||
@@ -0,0 +1,106 @@ | |||
1 | diff -Naur Python-2.5.1.orig/setup.py Python-2.5.1/setup.py | ||
2 | --- Python-2.5.orig/setup.py 2006-08-10 01:42:18.000000000 +0200 | ||
3 | +++ Python-2.5/setup.py 2007-11-21 18:00:43.000000000 +0100 | ||
4 | @@ -1321,16 +1329,16 @@ | ||
5 | ffi_configfile): | ||
6 | from distutils.dir_util import mkpath | ||
7 | mkpath(ffi_builddir) | ||
8 | - config_args = [] | ||
9 | + config_args = ['--host=%s' % os.environ["HOST_SYS"], ] | ||
10 | |||
11 | # Pass empty CFLAGS because we'll just append the resulting | ||
12 | # CFLAGS to Python's; -g or -O2 is to be avoided. | ||
13 | - cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ | ||
14 | - % (ffi_builddir, ffi_srcdir, " ".join(config_args)) | ||
15 | + cmd = "(cd %s && autoconf -W cross) && (cd %s && env CFLAGS='' '%s/configure' %s)" \ | ||
16 | + % (ffi_srcdir, ffi_builddir, ffi_srcdir, " ".join(config_args)) | ||
17 | |||
18 | res = os.system(cmd) | ||
19 | if res or not os.path.exists(ffi_configfile): | ||
20 | - print "Failed to configure _ctypes module" | ||
21 | + print "Failed to configure _ctypes module, ret %d or missing %s"% (res, ffi_configfile, ) | ||
22 | return False | ||
23 | |||
24 | fficonfig = {} | ||
25 | diff -Naur Python-2.5.1.orig/Modules/_ctypes/callbacks.c Python-2.5.1/Modules/_ctypes/callbacks.c | ||
26 | --- Python-2.5.1.orig/Modules/_ctypes/callbacks.c 2006-10-17 21:41:10.000000000 +0200 | ||
27 | +++ Python-2.5.1/Modules/_ctypes/callbacks.c 2007-11-22 10:29:33.000000000 +0100 | ||
28 | @@ -273,11 +273,13 @@ | ||
29 | PyErr_NoMemory(); | ||
30 | return NULL; | ||
31 | } | ||
32 | +#if FFI_CLOSURES | ||
33 | p->pcl = MallocClosure(); | ||
34 | if (p->pcl == NULL) { | ||
35 | PyErr_NoMemory(); | ||
36 | goto error; | ||
37 | } | ||
38 | +#endif | ||
39 | |||
40 | for (i = 0; i < nArgs; ++i) { | ||
41 | PyObject *cnv = PySequence_GetItem(converters, i); | ||
42 | @@ -315,12 +317,14 @@ | ||
43 | "ffi_prep_cif failed with %d", result); | ||
44 | goto error; | ||
45 | } | ||
46 | +#if FFI_CLOSURES | ||
47 | result = ffi_prep_closure(p->pcl, &p->cif, closure_fcn, p); | ||
48 | if (result != FFI_OK) { | ||
49 | PyErr_Format(PyExc_RuntimeError, | ||
50 | "ffi_prep_closure failed with %d", result); | ||
51 | goto error; | ||
52 | } | ||
53 | +#endif | ||
54 | |||
55 | p->converters = converters; | ||
56 | p->callable = callable; | ||
57 | @@ -328,8 +332,10 @@ | ||
58 | |||
59 | error: | ||
60 | if (p) { | ||
61 | +#if FFI_CLOSURES | ||
62 | if (p->pcl) | ||
63 | FreeClosure(p->pcl); | ||
64 | +#endif | ||
65 | PyMem_Free(p); | ||
66 | } | ||
67 | return NULL; | ||
68 | diff -Naur Python-2.5.1.orig/Modules/_ctypes/_ctypes.c Python-2.5.1/Modules/_ctypes/_ctypes.c | ||
69 | --- Python-2.5.1.orig/Modules/_ctypes/_ctypes.c 2007-03-23 20:56:45.000000000 +0100 | ||
70 | +++ Python-2.5.1/Modules/_ctypes/_ctypes.c 2007-11-22 10:29:01.000000000 +0100 | ||
71 | @@ -3419,7 +3419,9 @@ | ||
72 | Py_CLEAR(self->paramflags); | ||
73 | |||
74 | if (self->thunk) { | ||
75 | +#if FFI_CLOSURES | ||
76 | FreeClosure(self->thunk->pcl); | ||
77 | +#endif | ||
78 | PyMem_Free(self->thunk); | ||
79 | self->thunk = NULL; | ||
80 | } | ||
81 | diff -Naur Python-2.5.1.orig/Modules/_ctypes/ctypes.h Python-2.5.1/Modules/_ctypes/ctypes.h | ||
82 | --- Python-2.5.1.orig/Modules/_ctypes/ctypes.h 2006-08-14 13:17:48.000000000 +0200 | ||
83 | +++ Python-2.5.1/Modules/_ctypes/ctypes.h 2007-11-22 10:29:44.000000000 +0100 | ||
84 | @@ -68,7 +68,9 @@ | ||
85 | }; | ||
86 | |||
87 | typedef struct { | ||
88 | +#if FFI_CLOSURES | ||
89 | ffi_closure *pcl; /* the C callable */ | ||
90 | +#endif | ||
91 | ffi_cif cif; | ||
92 | PyObject *converters; | ||
93 | PyObject *callable; | ||
94 | diff -Naur Python-2.5.1.orig/Modules/_ctypes/malloc_closure.c Python-2.5.1/Modules/_ctypes/malloc_closure.c | ||
95 | --- Python-2.5.1.orig/Modules/_ctypes/malloc_closure.c 2006-06-12 22:56:48.000000000 +0200 | ||
96 | +++ Python-2.5.1/Modules/_ctypes/malloc_closure.c 2007-11-22 10:30:17.000000000 +0100 | ||
97 | @@ -27,7 +27,9 @@ | ||
98 | /******************************************************************/ | ||
99 | |||
100 | typedef union _tagITEM { | ||
101 | +#if FFI_CLOSURES | ||
102 | ffi_closure closure; | ||
103 | +#endif | ||
104 | union _tagITEM *next; | ||
105 | } ITEM; | ||
106 | |||
diff --git a/meta-extras/packages/python/python-2.5.2/fix-tkinter-detection.patch b/meta-extras/packages/python/python-2.5.2/fix-tkinter-detection.patch new file mode 100644 index 0000000000..93bd343381 --- /dev/null +++ b/meta-extras/packages/python/python-2.5.2/fix-tkinter-detection.patch | |||
@@ -0,0 +1,41 @@ | |||
1 | |||
2 | # | ||
3 | # Patch managed by http://www.holgerschurig.de/patcher.html | ||
4 | # | ||
5 | |||
6 | Index: Python-2.5.1/setup.py | ||
7 | =================================================================== | ||
8 | --- Python-2.5.1.orig/setup.py | ||
9 | +++ Python-2.5.1/setup.py | ||
10 | @@ -1227,7 +1227,7 @@ class PyBuildExt(build_ext): | ||
11 | dotversion = dotversion[:-1] + '.' + dotversion[-1] | ||
12 | tcl_include_sub = [] | ||
13 | tk_include_sub = [] | ||
14 | - for dir in inc_dirs: | ||
15 | + for dir in [os.getenv("STAGING_INCDIR")]: | ||
16 | tcl_include_sub += [dir + os.sep + "tcl" + dotversion] | ||
17 | tk_include_sub += [dir + os.sep + "tk" + dotversion] | ||
18 | tk_include_sub += tcl_include_sub | ||
19 | @@ -1246,22 +1246,6 @@ class PyBuildExt(build_ext): | ||
20 | if dir not in include_dirs: | ||
21 | include_dirs.append(dir) | ||
22 | |||
23 | - # Check for various platform-specific directories | ||
24 | - if platform == 'sunos5': | ||
25 | - include_dirs.append('/usr/openwin/include') | ||
26 | - added_lib_dirs.append('/usr/openwin/lib') | ||
27 | - elif os.path.exists('/usr/X11R6/include'): | ||
28 | - include_dirs.append('/usr/X11R6/include') | ||
29 | - added_lib_dirs.append('/usr/X11R6/lib64') | ||
30 | - added_lib_dirs.append('/usr/X11R6/lib') | ||
31 | - elif os.path.exists('/usr/X11R5/include'): | ||
32 | - include_dirs.append('/usr/X11R5/include') | ||
33 | - added_lib_dirs.append('/usr/X11R5/lib') | ||
34 | - else: | ||
35 | - # Assume default location for X11 | ||
36 | - include_dirs.append('/usr/X11/include') | ||
37 | - added_lib_dirs.append('/usr/X11/lib') | ||
38 | - | ||
39 | # If Cygwin, then verify that X is installed before proceeding | ||
40 | if platform == 'cygwin': | ||
41 | x11_inc = find_file('X11/Xlib.h', [], include_dirs) | ||
diff --git a/meta-extras/packages/python/python-2.5.2/sitebranding.patch b/meta-extras/packages/python/python-2.5.2/sitebranding.patch new file mode 100644 index 0000000000..c6e486ae97 --- /dev/null +++ b/meta-extras/packages/python/python-2.5.2/sitebranding.patch | |||
@@ -0,0 +1,21 @@ | |||
1 | |||
2 | # | ||
3 | # Patch managed by http://www.holgerschurig.de/patcher.html | ||
4 | # | ||
5 | |||
6 | Index: Python-2.5.1/Lib/site.py | ||
7 | =================================================================== | ||
8 | --- Python-2.5.1.orig/Lib/site.py | ||
9 | +++ Python-2.5.1/Lib/site.py | ||
10 | @@ -323,8 +323,9 @@ def setcopyright(): | ||
11 | "Jython is maintained by the Jython developers (www.jython.org).") | ||
12 | else: | ||
13 | __builtin__.credits = _Printer("credits", """\ | ||
14 | - Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands | ||
15 | - for supporting Python development. See www.python.org for more information.""") | ||
16 | + This version of Python has been built by the OpenEmbedded buildsystem (http://openembedded.org). | ||
17 | + It is a part of the Python-For-Embedded-Systems initiative which is maintained by | ||
18 | + Michael 'Mickey' Lauer (http://www.Vanille.de/projects/python.spy).""") | ||
19 | here = os.path.dirname(os.__file__) | ||
20 | __builtin__.license = _Printer( | ||
21 | "license", "See http://www.python.org/%.3s/license.html" % sys.version, | ||
diff --git a/meta-extras/packages/python/python-2.5.2/sitecustomize.py b/meta-extras/packages/python/python-2.5.2/sitecustomize.py new file mode 100644 index 0000000000..ec626b4b63 --- /dev/null +++ b/meta-extras/packages/python/python-2.5.2/sitecustomize.py | |||
@@ -0,0 +1,44 @@ | |||
1 | # OpenEmbedded sitecustomize.py (C) 2002-2008 Michael 'Mickey' Lauer <mlauer@vanille-media.de> | ||
2 | # GPLv2 or later | ||
3 | # Version: 20082201 | ||
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 | |||
10 | import os | ||
11 | |||
12 | def __exithandler(): | ||
13 | try: | ||
14 | readline.write_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) ) | ||
15 | except IOError: | ||
16 | pass | ||
17 | |||
18 | def __registerExitHandler(): | ||
19 | import atexit | ||
20 | atexit.register( __exithandler ) | ||
21 | |||
22 | def __enableReadlineSupport(): | ||
23 | readline.parse_and_bind("tab: complete") | ||
24 | try: | ||
25 | readline.read_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) ) | ||
26 | except IOError: | ||
27 | pass | ||
28 | |||
29 | def __enableDefaultEncoding(): | ||
30 | import sys | ||
31 | try: | ||
32 | sys.setdefaultencoding('utf8') | ||
33 | except LookupError: | ||
34 | pass | ||
35 | |||
36 | import sys | ||
37 | try: | ||
38 | import rlcompleter, readline | ||
39 | except ImportError: | ||
40 | pass | ||
41 | else: | ||
42 | __enableDefaultEncoding() | ||
43 | __registerExitHandler() | ||
44 | __enableReadlineSupport() | ||