summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2014-03-15 16:06:43 -0400
committerMike Gilbert <floppym@gentoo.org>2014-03-15 17:23:21 -0400
commiteadd93276d6ea2fd6b6c73fdcf4e4e285a9a8a7a (patch)
tree1176e2dec7a7e9815e768b3491573f30763c3a55
parentAdd Makefile (diff)
downloadpython-gentoo-patches-2.7.6-0.tar.gz
python-gentoo-patches-2.7.6-0.tar.bz2
python-gentoo-patches-2.7.6-0.zip
Add 2.7.6 patches2.7.6-0
-rw-r--r--patches/01_all_static_library_location.patch70
-rw-r--r--patches/02_all_disable_modules_and_ssl.patch94
-rw-r--r--patches/03_all_libdir.patch163
-rw-r--r--patches/04_all_non-zero_exit_status_on_failure.patch31
-rw-r--r--patches/05_all_loadable_sqlite_extensions.patch36
-rw-r--r--patches/06_all_regenerate_platform-specific_modules.patch123
-rw-r--r--patches/21_all_distutils_c++.patch273
-rw-r--r--patches/22_all_turkish_locale.patch24
-rw-r--r--patches/23_all_arm_OABI.patch185
-rw-r--r--patches/24_all_tests_environment.patch169
-rw-r--r--patches/61_all_process_data.patch128
-rw-r--r--patches/62_all_xml.use_pyxml.patch41
12 files changed, 1337 insertions, 0 deletions
diff --git a/patches/01_all_static_library_location.patch b/patches/01_all_static_library_location.patch
new file mode 100644
index 0000000..5c9c3ed
--- /dev/null
+++ b/patches/01_all_static_library_location.patch
@@ -0,0 +1,70 @@
+Install libpythonX.Y.a in /usr/lib instead of /usr/lib/pythonX.Y/config.
+https://bugs.gentoo.org/show_bug.cgi?id=252372
+http://bugs.python.org/issue6103
+
+--- Makefile.pre.in
++++ Makefile.pre.in
+@@ -891,6 +891,19 @@
+ fi; \
+ else true; \
+ fi
++ @if test -f $(LIBRARY) && test $(LIBRARY) != $(LDLIBRARY); then \
++ if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
++ if test "$(SO)" = .dll; then \
++ $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBDIR); \
++ else \
++ $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBDIR); \
++ $(RANLIB) $(DESTDIR)$(LIBDIR)/$(LIBRARY); \
++ fi; \
++ else \
++ echo "Skipped install of $(LIBRARY) - use make frameworkinstall"; \
++ fi; \
++ else true; \
++ fi
+
+ # Install the versioned manual page
+ altmaninstall:
+@@ -1084,18 +1097,6 @@
+ else true; \
+ fi; \
+ done
+- @if test -d $(LIBRARY); then :; else \
+- if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
+- if test "$(SO)" = .dll; then \
+- $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
+- else \
+- $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
+- $(RANLIB) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
+- fi; \
+- else \
+- echo Skip install of $(LIBRARY) - use make frameworkinstall; \
+- fi; \
+- fi
+ $(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
+ $(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
+ $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
+--- Misc/python-config.in
++++ Misc/python-config.in
+@@ -46,11 +46,7 @@
+ elif opt in ('--libs', '--ldflags'):
+ libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
+ libs.append('-lpython'+pyver)
+- # add the prefix/lib/pythonX.Y/config dir, but only if there is no
+- # shared library in prefix/lib/.
+ if opt == '--ldflags':
+- if not getvar('Py_ENABLE_SHARED'):
+- libs.insert(0, '-L' + getvar('LIBPL'))
+ if not getvar('PYTHONFRAMEWORK'):
+ libs.extend(getvar('LINKFORSHARED').split())
+ print ' '.join(libs)
+--- Modules/makesetup
++++ Modules/makesetup
+@@ -89,7 +89,7 @@
+ then
+ ExtraLibDir=.
+ else
+- ExtraLibDir='$(LIBPL)'
++ ExtraLibDir='$(LIBDIR)'
+ fi
+ ExtraLibs="-L$ExtraLibDir -lpython\$(VERSION)";;
+ esac
diff --git a/patches/02_all_disable_modules_and_ssl.patch b/patches/02_all_disable_modules_and_ssl.patch
new file mode 100644
index 0000000..e8e58e0
--- /dev/null
+++ b/patches/02_all_disable_modules_and_ssl.patch
@@ -0,0 +1,94 @@
+--- setup.py
++++ setup.py
+@@ -33,7 +33,18 @@
+ COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
+
+ # This global variable is used to hold the list of modules to be disabled.
+-disabled_module_list = []
++pdm_env = "PYTHON_DISABLE_MODULES"
++if pdm_env in os.environ:
++ disabled_module_list = os.environ[pdm_env].split()
++else:
++ disabled_module_list = []
++
++pds_env = "PYTHON_DISABLE_SSL"
++if pds_env in os.environ:
++ disable_ssl = os.environ[pds_env]
++else:
++ disable_ssl = 0
++
+
+ def add_dir_to_list(dirlist, dir):
+ """Add the directory 'dir' to the list 'dirlist' (at the front) if
+@@ -436,6 +447,7 @@
+ os.unlink(tmpfile)
+
+ def detect_modules(self):
++ global disable_ssl
+ # Ensure that /usr/local is always used
+ if not cross_compiling:
+ add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
+@@ -791,7 +803,7 @@
+ ssl_incs = find_file('openssl/ssl.h', inc_dirs,
+ search_for_ssl_incs_in
+ )
+- if ssl_incs is not None:
++ if ssl_incs is not None and not disable_ssl:
+ krb5_h = find_file('krb5.h', inc_dirs,
+ ['/usr/kerberos/include'])
+ if krb5_h:
+@@ -802,7 +814,8 @@
+ ] )
+
+ if (ssl_incs is not None and
+- ssl_libs is not None):
++ ssl_libs is not None and
++ not disable_ssl):
+ exts.append( Extension('_ssl', ['_ssl.c'],
+ include_dirs = ssl_incs,
+ library_dirs = ssl_libs,
+@@ -834,7 +847,7 @@
+ pass
+
+ min_openssl_ver = 0x00907000
+- have_any_openssl = ssl_incs is not None and ssl_libs is not None
++ have_any_openssl = ssl_incs is not None and ssl_libs is not None and not disable_ssl
+ have_usable_openssl = (have_any_openssl and
+ openssl_ver >= min_openssl_ver)
+
+@@ -850,21 +863,20 @@
+ print ("warning: openssl 0x%08x is too old for _hashlib" %
+ openssl_ver)
+ missing.append('_hashlib')
+- if COMPILED_WITH_PYDEBUG or not have_usable_openssl:
+- # The _sha module implements the SHA1 hash algorithm.
+- exts.append( Extension('_sha', ['shamodule.c']) )
+- # The _md5 module implements the RSA Data Security, Inc. MD5
+- # Message-Digest Algorithm, described in RFC 1321. The
+- # necessary files md5.c and md5.h are included here.
+- exts.append( Extension('_md5',
+- sources = ['md5module.c', 'md5.c'],
+- depends = ['md5.h']) )
+-
+- min_sha2_openssl_ver = 0x00908000
+- if COMPILED_WITH_PYDEBUG or openssl_ver < min_sha2_openssl_ver:
+- # OpenSSL doesn't do these until 0.9.8 so we'll bring our own hash
+- exts.append( Extension('_sha256', ['sha256module.c']) )
+- exts.append( Extension('_sha512', ['sha512module.c']) )
++
++ ### Build these unconditionally so emerge won't fail
++ ### when openssl is dropped/broken etc.
++ # The _sha module implements the SHA1 hash algorithm.
++ exts.append( Extension('_sha', ['shamodule.c']) )
++ # The _md5 module implements the RSA Data Security, Inc. MD5
++ # Message-Digest Algorithm, described in RFC 1321. The
++ # necessary files md5.c and md5.h are included here.
++ exts.append( Extension('_md5',
++ sources = ['md5module.c', 'md5.c'],
++ depends = ['md5.h']) )
++
++ exts.append( Extension('_sha256', ['sha256module.c']) )
++ exts.append( Extension('_sha512', ['sha512module.c']) )
+
+ # Modules that provide persistent dictionary-like semantics. You will
+ # probably want to arrange for at least one of them to be available on
diff --git a/patches/03_all_libdir.patch b/patches/03_all_libdir.patch
new file mode 100644
index 0000000..d8209b2
--- /dev/null
+++ b/patches/03_all_libdir.patch
@@ -0,0 +1,163 @@
+--- Lib/distutils/command/install.py
++++ Lib/distutils/command/install.py
+@@ -41,8 +41,8 @@
+
+ INSTALL_SCHEMES = {
+ 'unix_prefix': {
+- 'purelib': '$base/lib/python$py_version_short/site-packages',
+- 'platlib': '$platbase/lib/python$py_version_short/site-packages',
++ 'purelib': '$base/@@GENTOO_LIBDIR@@/python$py_version_short/site-packages',
++ 'platlib': '$platbase/@@GENTOO_LIBDIR@@/python$py_version_short/site-packages',
+ 'headers': '$base/include/python$py_version_short/$dist_name',
+ 'scripts': '$base/bin',
+ 'data' : '$base',
+--- Lib/distutils/sysconfig.py
++++ Lib/distutils/sysconfig.py
+@@ -120,7 +120,7 @@
+
+ if os.name == "posix":
+ libpython = os.path.join(prefix,
+- "lib", "python" + get_python_version())
++ "@@GENTOO_LIBDIR@@", "python" + get_python_version())
+ if standard_lib:
+ return libpython
+ else:
+--- Lib/site.py
++++ Lib/site.py
+@@ -288,10 +288,10 @@
+ if sys.platform in ('os2emx', 'riscos'):
+ sitepackages.append(os.path.join(prefix, "Lib", "site-packages"))
+ elif os.sep == '/':
+- sitepackages.append(os.path.join(prefix, "lib",
++ sitepackages.append(os.path.join(prefix, "@@GENTOO_LIBDIR@@",
+ "python" + sys.version[:3],
+ "site-packages"))
+- sitepackages.append(os.path.join(prefix, "lib", "site-python"))
++ sitepackages.append(os.path.join(prefix, "@@GENTOO_LIBDIR@@", "site-python"))
+ else:
+ sitepackages.append(prefix)
+ sitepackages.append(os.path.join(prefix, "lib", "site-packages"))
+--- Lib/sysconfig.py
++++ Lib/sysconfig.py
+@@ -7,10 +7,10 @@
+
+ _INSTALL_SCHEMES = {
+ 'posix_prefix': {
+- 'stdlib': '{base}/lib/python{py_version_short}',
+- 'platstdlib': '{platbase}/lib/python{py_version_short}',
+- 'purelib': '{base}/lib/python{py_version_short}/site-packages',
+- 'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
++ 'stdlib': '{base}/@@GENTOO_LIBDIR@@/python{py_version_short}',
++ 'platstdlib': '{platbase}/@@GENTOO_LIBDIR@@/python{py_version_short}',
++ 'purelib': '{base}/@@GENTOO_LIBDIR@@/python{py_version_short}/site-packages',
++ 'platlib': '{platbase}/@@GENTOO_LIBDIR@@/python{py_version_short}/site-packages',
+ 'include': '{base}/include/python{py_version_short}',
+ 'platinclude': '{platbase}/include/python{py_version_short}',
+ 'scripts': '{base}/bin',
+@@ -65,10 +65,10 @@
+ 'data' : '{userbase}',
+ },
+ 'posix_user': {
+- 'stdlib': '{userbase}/lib/python{py_version_short}',
+- 'platstdlib': '{userbase}/lib/python{py_version_short}',
+- 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
+- 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
++ 'stdlib': '{userbase}/@@GENTOO_LIBDIR@@/python{py_version_short}',
++ 'platstdlib': '{userbase}/@@GENTOO_LIBDIR@@/python{py_version_short}',
++ 'purelib': '{userbase}/@@GENTOO_LIBDIR@@/python{py_version_short}/site-packages',
++ 'platlib': '{userbase}/@@GENTOO_LIBDIR@@/python{py_version_short}/site-packages',
+ 'include': '{userbase}/include/python{py_version_short}',
+ 'scripts': '{userbase}/bin',
+ 'data' : '{userbase}',
+--- Lib/test/test_site.py
++++ Lib/test/test_site.py
+@@ -242,10 +242,10 @@
+ elif os.sep == '/':
+ # OS X non-framwework builds, Linux, FreeBSD, etc
+ self.assertEqual(len(dirs), 2)
+- wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
++ wanted = os.path.join('xoxo', '@@GENTOO_LIBDIR@@', 'python' + sys.version[:3],
+ 'site-packages')
+ self.assertEqual(dirs[0], wanted)
+- wanted = os.path.join('xoxo', 'lib', 'site-python')
++ wanted = os.path.join('xoxo', '@@GENTOO_LIBDIR@@', 'site-python')
+ self.assertEqual(dirs[1], wanted)
+ else:
+ # other platforms
+--- Makefile.pre.in
++++ Makefile.pre.in
+@@ -106,7 +106,7 @@
+ MANDIR= @mandir@
+ INCLUDEDIR= @includedir@
+ CONFINCLUDEDIR= $(exec_prefix)/include
+-SCRIPTDIR= $(prefix)/lib
++SCRIPTDIR= $(prefix)/@@GENTOO_LIBDIR@@
+
+ # Detailed destination directories
+ BINLIBDEST= $(LIBDIR)/python$(VERSION)
+--- Modules/getpath.c
++++ Modules/getpath.c
+@@ -129,7 +129,7 @@
+ static char exec_prefix[MAXPATHLEN+1];
+ static char progpath[MAXPATHLEN+1];
+ static char *module_search_path = NULL;
+-static char lib_python[] = "lib/python" VERSION;
++static char lib_python[] = "@@GENTOO_LIBDIR@@/python" VERSION;
+
+ static void
+ reduce(char *dir)
+@@ -543,7 +543,7 @@
+ }
+ else
+ strncpy(zip_path, PREFIX, MAXPATHLEN);
+- joinpath(zip_path, "lib/python00.zip");
++ joinpath(zip_path, "@@GENTOO_LIBDIR@@/python00.zip");
+ bufsz = strlen(zip_path); /* Replace "00" with version */
+ zip_path[bufsz - 6] = VERSION[0];
+ zip_path[bufsz - 5] = VERSION[2];
+@@ -553,7 +553,7 @@
+ fprintf(stderr,
+ "Could not find platform dependent libraries <exec_prefix>\n");
+ strncpy(exec_prefix, EXEC_PREFIX, MAXPATHLEN);
+- joinpath(exec_prefix, "lib/lib-dynload");
++ joinpath(exec_prefix, "@@GENTOO_LIBDIR@@/lib-dynload");
+ }
+ /* If we found EXEC_PREFIX do *not* reduce it! (Yet.) */
+
+--- Modules/Setup.dist
++++ Modules/Setup.dist
+@@ -464,7 +464,7 @@
+ # Andrew Kuchling's zlib module.
+ # This require zlib 1.1.3 (or later).
+ # See http://www.gzip.org/zlib/
+-#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
++#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/@@GENTOO_LIBDIR@@ -lz
+
+ # Interface to the Expat XML parser
+ #
+--- setup.py
++++ setup.py
+@@ -517,8 +517,7 @@
+ ):
+ add_dir_to_list(inc_dirs, d)
+ for d in (
+- '/lib64', '/usr/lib64',
+- '/lib', '/usr/lib',
++ '/@@GENTOO_LIBDIR@@', '/usr/@@GENTOO_LIBDIR@@',
+ ):
+ add_dir_to_list(lib_dirs, d)
+ exts = []
+@@ -770,11 +769,11 @@
+ elif curses_library:
+ readline_libs.append(curses_library)
+ elif self.compiler.find_library_file(lib_dirs +
+- ['/usr/lib/termcap'],
++ ['/usr/@@GENTOO_LIBDIR@@/termcap'],
+ 'termcap'):
+ readline_libs.append('termcap')
+ exts.append( Extension('readline', ['readline.c'],
+- library_dirs=['/usr/lib/termcap'],
++ library_dirs=['/usr/@@GENTOO_LIBDIR@@/termcap'],
+ extra_link_args=readline_extra_link_args,
+ libraries=readline_libs) )
+ else:
diff --git a/patches/04_all_non-zero_exit_status_on_failure.patch b/patches/04_all_non-zero_exit_status_on_failure.patch
new file mode 100644
index 0000000..3346979
--- /dev/null
+++ b/patches/04_all_non-zero_exit_status_on_failure.patch
@@ -0,0 +1,31 @@
+https://bugs.gentoo.org/show_bug.cgi?id=281968
+http://bugs.python.org/issue6731
+
+--- setup.py
++++ setup.py
+@@ -46,6 +46,8 @@
+ disable_ssl = 0
+
+
++exit_status = 0
++
+ def add_dir_to_list(dirlist, dir):
+ """Add the directory 'dir' to the list 'dirlist' (at the front) if
+ 1) 'dir' is not already in 'dirlist'
+@@ -284,6 +286,8 @@
+ print
+
+ if self.failed:
++ global exit_status
++ exit_status = 1
+ failed = self.failed[:]
+ print
+ print "Failed to build these modules:"
+@@ -2237,6 +2241,7 @@
+ 'Tools/scripts/2to3',
+ 'Lib/smtpd.py']
+ )
++ sys.exit(exit_status)
+
+ # --install-platlib
+ if __name__ == '__main__':
diff --git a/patches/05_all_loadable_sqlite_extensions.patch b/patches/05_all_loadable_sqlite_extensions.patch
new file mode 100644
index 0000000..8ad2466
--- /dev/null
+++ b/patches/05_all_loadable_sqlite_extensions.patch
@@ -0,0 +1,36 @@
+https://bugs.gentoo.org/show_bug.cgi?id=335505
+http://bugs.python.org/issue10268
+
+--- configure.ac
++++ configure.ac
+@@ -2317,6 +2317,15 @@
+ TCLTK_LIBS="$with_tcltk_libs"
+ fi
+
++# Check for support for loadable sqlite extensions
++AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions)
++AC_ARG_ENABLE(loadable-sqlite-extensions,
++ AS_HELP_STRING([--enable-loadable-sqlite-extensions], [support loadable extensions in _sqlite module]),
++ [],
++ [enable_loadable_sqlite_extensions="no"])
++
++AC_MSG_RESULT($enable_loadable_sqlite_extensions)
++
+ # Check for --with-dbmliborder
+ AC_MSG_CHECKING(for --with-dbmliborder)
+ AC_ARG_WITH(dbmliborder,
+--- setup.py
++++ setup.py
+@@ -1184,8 +1184,10 @@
+ else:
+ sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"'))
+
+- # Comment this out if you want the sqlite3 module to be able to load extensions.
+- sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))
++ # Enable support for loadable extensions in the sqlite3 module
++ # if --enable-loadable-sqlite-extensions configure option is used.
++ if '--enable-loadable-sqlite-extensions' not in sysconfig.get_config_var("CONFIG_ARGS"):
++ sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))
+
+ if host_platform == 'darwin':
+ # In every directory on the search path search for a dynamic
diff --git a/patches/06_all_regenerate_platform-specific_modules.patch b/patches/06_all_regenerate_platform-specific_modules.patch
new file mode 100644
index 0000000..d4333f1
--- /dev/null
+++ b/patches/06_all_regenerate_platform-specific_modules.patch
@@ -0,0 +1,123 @@
+http://bugs.python.org/issue12619
+
+--- Lib/plat-aix4/regen
++++ Lib/plat-aix4/regen
+@@ -5,4 +5,4 @@
+ exit 1;;
+ esac
+ set -v
+-h2py.py -i '(u_long)' /usr/include/netinet/in.h
++python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h
+--- Lib/plat-linux2/regen
++++ Lib/plat-linux2/regen
+@@ -5,4 +5,4 @@
+ exit 1;;
+ esac
+ set -v
+-h2py -i '(u_long)' /usr/include/sys/types.h /usr/include/netinet/in.h /usr/include/dlfcn.h
++python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/sys/types.h /usr/include/netinet/in.h /usr/include/dlfcn.h /usr/include/linux/cdrom.h
+--- Lib/plat-sunos5/regen
++++ Lib/plat-sunos5/regen
+@@ -5,5 +5,4 @@
+ exit 1;;
+ esac
+ set -v
+-h2py -i '(u_long)' /usr/include/sys/types.h /usr/include/netinet/in.h /usr/include/sys/stropts.h /usr/include/dlfcn.h
+-
++python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/sys/types.h /usr/include/netinet/in.h /usr/include/sys/stropts.h /usr/include/dlfcn.h
+--- Lib/plat-unixware7/regen
++++ Lib/plat-unixware7/regen
+@@ -5,5 +5,5 @@
+ exit 1;;
+ esac
+ set -v
+-h2py -i '(u_long)' /usr/include/netinet/in.h
+-h2py /usr/include/sys/stropts.h
++python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h
++python$EXE ../../Tools/scripts/h2py.py /usr/include/sys/stropts.h
+--- Makefile.pre.in
++++ Makefile.pre.in
+@@ -405,7 +405,7 @@
+
+ # Default target
+ all: build_all
+-build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
++build_all: $(BUILDPYTHON) oldsharedmods sharedmods platformspecificmods gdbhooks
+
+ # Compile a binary with gcc profile guided optimization.
+ profile-opt:
+@@ -463,6 +463,32 @@
+ _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
+ $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
+
++# Build the platform-specific modules
++platformspecificmods: $(BUILDPYTHON) sharedmods
++ @PLATDIR=$(PLATDIR); \
++ if test ! -f $(srcdir)/Lib/$(PLATDIR)/regen; then \
++ $(INSTALL) -d $(srcdir)/Lib/$(PLATDIR); \
++ if test -f $(srcdir)/Lib/$${PLATDIR%?}/regen; then \
++ cp $(srcdir)/Lib/$${PLATDIR%?}/regen $(srcdir)/Lib/$(PLATDIR)/regen; \
++ else \
++ cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen; \
++ fi \
++ fi
++ @EXE="$(BUILDEXE)"; export EXE; \
++ PATH="`pwd`:$$PATH"; export PATH; \
++ PYTHONPATH="$(srcdir)/Lib:$(abs_builddir)/`cat pybuilddir.txt`"; export PYTHONPATH; \
++ if [ -n "$(MULTIARCH)" ]; then MULTIARCH=$(MULTIARCH); export MULTIARCH; fi; \
++ if [ "$(build)" = "$(host)" ]; then \
++ PYTHON_FOR_BUILD="$(BUILDPYTHON)"; \
++ else \
++ PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)"; \
++ fi; export PYTHON_FOR_BUILD; \
++ cd $(srcdir)/Lib/$(PLATDIR); \
++ $(RUNSHARED) ./regen || exit 1; \
++ for module in *.py; do \
++ $(RUNSHARED) $(BUILDPYTHON) -c "with open('$$module', 'rb') as module: compile(module.read(), '$$module', 'exec')" || exit 1; \
++ done
++
+ # Build static library
+ # avoid long command lines, same as LIBRARY_OBJS
+ $(LIBRARY): $(LIBRARY_OBJS)
+@@ -958,7 +984,7 @@
+ unittest unittest/test \
+ lib-old \
+ curses pydoc_data $(MACHDEPS)
+-libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
++libinstall: build_all $(srcdir)/Modules/xxmodule.c
+ @for i in $(SCRIPTDIR) $(LIBDEST); \
+ do \
+ if test ! -d $(DESTDIR)$$i; then \
+@@ -1041,23 +1067,6 @@
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
+
+-# Create the PLATDIR source directory, if one wasn't distributed..
+-$(srcdir)/Lib/$(PLATDIR):
+- mkdir $(srcdir)/Lib/$(PLATDIR)
+- cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
+- export PATH; PATH="`pwd`:$$PATH"; \
+- export PYTHONPATH; PYTHONPATH="$(srcdir)/Lib:$(abs_builddir)/`cat pybuilddir.txt`"; \
+- export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
+- export EXE; EXE="$(BUILDEXE)"; \
+- if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \
+- export PYTHON_FOR_BUILD; \
+- if [ "$(build)" = "$(host)" ]; then \
+- PYTHON_FOR_BUILD="$(BUILDPYTHON)"; \
+- else \
+- PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)"; \
+- fi; \
+- cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
+-
+ python-config: $(srcdir)/Misc/python-config.in
+ # Substitution happens here, as the completely-expanded BINDIR
+ # is not available in configure
+@@ -1350,7 +1359,7 @@
+ Python/thread.o: @THREADHEADERS@
+
+ # Declare targets that aren't real files
+-.PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
++.PHONY: all build_all sharedmods oldsharedmods platformspecificmods test quicktest memtest
+ .PHONY: install altinstall oldsharedinstall bininstall altbininstall
+ .PHONY: maninstall libinstall inclinstall libainstall sharedinstall
+ .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
diff --git a/patches/21_all_distutils_c++.patch b/patches/21_all_distutils_c++.patch
new file mode 100644
index 0000000..c38dc47
--- /dev/null
+++ b/patches/21_all_distutils_c++.patch
@@ -0,0 +1,273 @@
+http://bugs.python.org/issue1222585
+
+--- Lib/distutils/cygwinccompiler.py
++++ Lib/distutils/cygwinccompiler.py
+@@ -117,8 +117,10 @@
+ # dllwrap 2.10.90 is buggy
+ if self.ld_version >= "2.10.90":
+ self.linker_dll = "gcc"
++ self.linker_dll_cxx = "g++"
+ else:
+ self.linker_dll = "dllwrap"
++ self.linker_dll_cxx = "dllwrap"
+
+ # ld_version >= "2.13" support -shared so use it instead of
+ # -mdll -static
+@@ -132,9 +134,13 @@
+ self.set_executables(compiler='gcc -mcygwin -O -Wall',
+ compiler_so='gcc -mcygwin -mdll -O -Wall',
+ compiler_cxx='g++ -mcygwin -O -Wall',
++ compiler_so_cxx='g++ -mcygwin -mdll -O -Wall',
+ linker_exe='gcc -mcygwin',
+ linker_so=('%s -mcygwin %s' %
+- (self.linker_dll, shared_option)))
++ (self.linker_dll, shared_option)),
++ linker_exe_cxx='g++ -mcygwin',
++ linker_so_cxx=('%s -mcygwin %s' %
++ (self.linker_dll_cxx, shared_option)))
+
+ # cygwin and mingw32 need different sets of libraries
+ if self.gcc_version == "2.91.57":
+@@ -160,8 +166,12 @@
+ raise CompileError, msg
+ else: # for other files use the C-compiler
+ try:
+- self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
+- extra_postargs)
++ if self.detect_language(src) == 'c++':
++ self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
++ extra_postargs)
++ else:
++ self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
++ extra_postargs)
+ except DistutilsExecError, msg:
+ raise CompileError, msg
+
+@@ -327,9 +337,14 @@
+ self.set_executables(compiler='gcc%s -O -Wall' % no_cygwin,
+ compiler_so='gcc%s -mdll -O -Wall' % no_cygwin,
+ compiler_cxx='g++%s -O -Wall' % no_cygwin,
++ compiler_so_cxx='g++%s -mdll -O -Wall' % no_cygwin,
+ linker_exe='gcc%s' % no_cygwin,
+ linker_so='%s%s %s %s'
+ % (self.linker_dll, no_cygwin,
++ shared_option, entry_point),
++ linker_exe_cxx='g++%s' % no_cygwin,
++ linker_so_cxx='%s%s %s %s'
++ % (self.linker_dll_cxx, no_cygwin,
+ shared_option, entry_point))
+ # Maybe we should also append -mthreads, but then the finished
+ # dlls need another dll (mingwm10.dll see Mingw32 docs)
+--- Lib/distutils/emxccompiler.py
++++ Lib/distutils/emxccompiler.py
+@@ -65,8 +65,12 @@
+ # XXX optimization, warnings etc. should be customizable.
+ self.set_executables(compiler='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
+ compiler_so='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
++ compiler_cxx='g++ -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
++ compiler_so_cxx='g++ -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
+ linker_exe='gcc -Zomf -Zmt -Zcrtdll',
+- linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll')
++ linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll',
++ linker_exe_cxx='g++ -Zomf -Zmt -Zcrtdll',
++ linker_so_cxx='g++ -Zomf -Zmt -Zcrtdll -Zdll')
+
+ # want the gcc library statically linked (so that we don't have
+ # to distribute a version dependent on the compiler we have)
+@@ -83,8 +87,12 @@
+ raise CompileError, msg
+ else: # for other files use the C-compiler
+ try:
+- self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
+- extra_postargs)
++ if self.detect_language(src) == 'c++':
++ self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
++ extra_postargs)
++ else:
++ self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
++ extra_postargs)
+ except DistutilsExecError, msg:
+ raise CompileError, msg
+
+--- Lib/distutils/sysconfig.py
++++ Lib/distutils/sysconfig.py
+@@ -170,10 +170,12 @@
+ _osx_support.customize_compiler(_config_vars)
+ _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
+
+- (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
+- get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
+- 'CCSHARED', 'LDSHARED', 'SO', 'AR',
+- 'ARFLAGS')
++ (cc, cxx, ccshared, ldshared, ldcxxshared, so_ext, ar, ar_flags) = \
++ get_config_vars('CC', 'CXX', 'CCSHARED', 'LDSHARED', 'LDCXXSHARED',
++ 'SO', 'AR', 'ARFLAGS')
++
++ cflags = ''
++ cxxflags = ''
+
+ if 'CC' in os.environ:
+ newcc = os.environ['CC']
+@@ -188,19 +190,27 @@
+ cxx = os.environ['CXX']
+ if 'LDSHARED' in os.environ:
+ ldshared = os.environ['LDSHARED']
++ if 'LDCXXSHARED' in os.environ:
++ ldcxxshared = os.environ['LDCXXSHARED']
+ if 'CPP' in os.environ:
+ cpp = os.environ['CPP']
+ else:
+ cpp = cc + " -E" # not always
+ if 'LDFLAGS' in os.environ:
+ ldshared = ldshared + ' ' + os.environ['LDFLAGS']
++ ldcxxshared = ldcxxshared + ' ' + os.environ['LDFLAGS']
+ if 'CFLAGS' in os.environ:
+- cflags = opt + ' ' + os.environ['CFLAGS']
++ cflags = os.environ['CFLAGS']
+ ldshared = ldshared + ' ' + os.environ['CFLAGS']
++ if 'CXXFLAGS' in os.environ:
++ cxxflags = os.environ['CXXFLAGS']
++ ldcxxshared = ldcxxshared + ' ' + os.environ['CXXFLAGS']
+ if 'CPPFLAGS' in os.environ:
+ cpp = cpp + ' ' + os.environ['CPPFLAGS']
+ cflags = cflags + ' ' + os.environ['CPPFLAGS']
++ cxxflags = cxxflags + ' ' + os.environ['CPPFLAGS']
+ ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
++ ldcxxshared = ldcxxshared + ' ' + os.environ['CPPFLAGS']
+ if 'AR' in os.environ:
+ ar = os.environ['AR']
+ if 'ARFLAGS' in os.environ:
+@@ -209,13 +219,17 @@
+ archiver = ar + ' ' + ar_flags
+
+ cc_cmd = cc + ' ' + cflags
++ cxx_cmd = cxx + ' ' + cxxflags
+ compiler.set_executables(
+ preprocessor=cpp,
+ compiler=cc_cmd,
+ compiler_so=cc_cmd + ' ' + ccshared,
+- compiler_cxx=cxx,
++ compiler_cxx=cxx_cmd,
++ compiler_so_cxx=cxx_cmd + ' ' + ccshared,
+ linker_so=ldshared,
+ linker_exe=cc,
++ linker_so_cxx=ldcxxshared,
++ linker_exe_cxx=cxx,
+ archiver=archiver)
+
+ compiler.shared_lib_extension = so_ext
+--- Lib/distutils/unixccompiler.py
++++ Lib/distutils/unixccompiler.py
+@@ -55,14 +55,17 @@
+ # are pretty generic; they will probably have to be set by an outsider
+ # (eg. using information discovered by the sysconfig about building
+ # Python extensions).
+- executables = {'preprocessor' : None,
+- 'compiler' : ["cc"],
+- 'compiler_so' : ["cc"],
+- 'compiler_cxx' : ["cc"],
+- 'linker_so' : ["cc", "-shared"],
+- 'linker_exe' : ["cc"],
+- 'archiver' : ["ar", "-cr"],
+- 'ranlib' : None,
++ executables = {'preprocessor' : None,
++ 'compiler' : ["cc"],
++ 'compiler_so' : ["cc"],
++ 'compiler_cxx' : ["c++"],
++ 'compiler_so_cxx' : ["c++"],
++ 'linker_so' : ["cc", "-shared"],
++ 'linker_exe' : ["cc"],
++ 'linker_so_cxx' : ["c++", "-shared"],
++ 'linker_exe_cxx' : ["c++"],
++ 'archiver' : ["ar", "-cr"],
++ 'ranlib' : None,
+ }
+
+ if sys.platform[:6] == "darwin":
+@@ -112,12 +115,19 @@
+
+ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
+ compiler_so = self.compiler_so
++ compiler_so_cxx = self.compiler_so_cxx
+ if sys.platform == 'darwin':
+ compiler_so = _osx_support.compiler_fixup(compiler_so,
+ cc_args + extra_postargs)
++ compiler_so_cxx = _osx_support.compiler_fixup(compiler_so_cxx,
++ cc_args + extra_postargs)
+ try:
+- self.spawn(compiler_so + cc_args + [src, '-o', obj] +
+- extra_postargs)
++ if self.detect_language(src) == 'c++':
++ self.spawn(compiler_so_cxx + cc_args + [src, '-o', obj] +
++ extra_postargs)
++ else:
++ self.spawn(compiler_so + cc_args + [src, '-o', obj] +
++ extra_postargs)
+ except DistutilsExecError, msg:
+ raise CompileError, msg
+
+@@ -174,23 +184,16 @@
+ ld_args.extend(extra_postargs)
+ self.mkpath(os.path.dirname(output_filename))
+ try:
+- if target_desc == CCompiler.EXECUTABLE:
+- linker = self.linker_exe[:]
++ if target_lang == "c++":
++ if target_desc == CCompiler.EXECUTABLE:
++ linker = self.linker_exe_cxx[:]
++ else:
++ linker = self.linker_so_cxx[:]
+ else:
+- linker = self.linker_so[:]
+- if target_lang == "c++" and self.compiler_cxx:
+- # skip over environment variable settings if /usr/bin/env
+- # is used to set up the linker's environment.
+- # This is needed on OSX. Note: this assumes that the
+- # normal and C++ compiler have the same environment
+- # settings.
+- i = 0
+- if os.path.basename(linker[0]) == "env":
+- i = 1
+- while '=' in linker[i]:
+- i = i + 1
+-
+- linker[i] = self.compiler_cxx[i]
++ if target_desc == CCompiler.EXECUTABLE:
++ linker = self.linker_exe[:]
++ else:
++ linker = self.linker_so[:]
+
+ if sys.platform == 'darwin':
+ linker = _osx_support.compiler_fixup(linker, ld_args)
+--- Lib/_osx_support.py
++++ Lib/_osx_support.py
+@@ -14,13 +14,13 @@
+ # configuration variables that may contain universal build flags,
+ # like "-arch" or "-isdkroot", that may need customization for
+ # the user environment
+-_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS',
+- 'BLDSHARED', 'LDSHARED', 'CC', 'CXX',
+- 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
+- 'PY_CORE_CFLAGS')
++_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'CPPFLAGS',
++ 'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'LDCXXSHARED',
++ 'CC', 'CXX', 'PY_CFLAGS', 'PY_LDFLAGS',
++ 'PY_CPPFLAGS', 'PY_CORE_CFLAGS')
+
+ # configuration variables that may contain compiler calls
+-_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX')
++_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'LDCXXSHARED', 'CC', 'CXX')
+
+ # prefix added to original configuration variable names
+ _INITPRE = '_OSX_SUPPORT_INITIAL_'
+--- Makefile.pre.in
++++ Makefile.pre.in
+@@ -459,7 +459,7 @@
+ *\ -s*|s*) quiet="-q";; \
+ *) quiet="";; \
+ esac; \
+- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
++ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' CFLAGS='$(CFLAGS)' \
+ _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
+ $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
+
diff --git a/patches/22_all_turkish_locale.patch b/patches/22_all_turkish_locale.patch
new file mode 100644
index 0000000..5d8bc6a
--- /dev/null
+++ b/patches/22_all_turkish_locale.patch
@@ -0,0 +1,24 @@
+--- Lib/email/__init__.py
++++ Lib/email/__init__.py
+@@ -109,15 +109,19 @@
+ 'Text',
+ ]
+
++import string
++lower_map = string.maketrans(string.ascii_uppercase, string.ascii_lowercase)
++
++
+ for _name in _LOWERNAMES:
+- importer = LazyImporter(_name.lower())
++ importer = LazyImporter(_name.translate(lower_map))
+ sys.modules['email.' + _name] = importer
+ setattr(sys.modules['email'], _name, importer)
+
+
+ import email.mime
+ for _name in _MIMENAMES:
+- importer = LazyImporter('mime.' + _name.lower())
++ importer = LazyImporter('mime.' + _name.translate(lower_map))
+ sys.modules['email.MIME' + _name] = importer
+ setattr(sys.modules['email'], 'MIME' + _name, importer)
+ setattr(sys.modules['email.mime'], _name, importer)
diff --git a/patches/23_all_arm_OABI.patch b/patches/23_all_arm_OABI.patch
new file mode 100644
index 0000000..1f94f78
--- /dev/null
+++ b/patches/23_all_arm_OABI.patch
@@ -0,0 +1,185 @@
+https://bugs.gentoo.org/show_bug.cgi?id=266703
+http://bugs.python.org/issue1762561
+
+--- Objects/floatobject.c
++++ Objects/floatobject.c
+@@ -1849,9 +1849,18 @@
+ /* this is for the benefit of the pack/unpack routines below */
+
+ typedef enum {
+- unknown_format, ieee_big_endian_format, ieee_little_endian_format
++ unknown_format,
++ ieee_big_endian_format,
++ ieee_little_endian_format,
++ ieee_arm_mixed_endian_format
+ } float_format_type;
+
++/* byte order of a C double for each of the recognised IEEE formats */
++
++static const unsigned char BIG_ENDIAN_BYTEORDER[8] = {7,6,5,4,3,2,1,0};
++static const unsigned char LITTLE_ENDIAN_BYTEORDER[8] = {0,1,2,3,4,5,6,7};
++static const unsigned char ARM_MIXED_ENDIAN_BYTEORDER[8] = {4,5,6,7,0,1,2,3};
++
+ static float_format_type double_format, float_format;
+ static float_format_type detected_double_format, detected_float_format;
+
+@@ -1888,6 +1897,8 @@
+ return PyString_FromString("IEEE, little-endian");
+ case ieee_big_endian_format:
+ return PyString_FromString("IEEE, big-endian");
++ case ieee_arm_mixed_endian_format:
++ return PyString_FromString("IEEE, ARM mixed-endian");
+ default:
+ Py_FatalError("insane float_format or double_format");
+ return NULL;
+@@ -1901,8 +1912,9 @@
+ "used in Python's test suite.\n"
+ "\n"
+ "typestr must be 'double' or 'float'. This function returns whichever of\n"
+-"'unknown', 'IEEE, big-endian' or 'IEEE, little-endian' best describes the\n"
+-"format of floating point numbers used by the C type named by typestr.");
++"'unknown', 'IEEE, big-endian', 'IEEE, little-endian' or\n"
++"'IEEE, ARM mixed-endian' best describes the format of floating-point\n"
++"numbers used by the C type named by typestr.");
+
+ static PyObject *
+ float_setformat(PyTypeObject *v, PyObject* args)
+@@ -1940,11 +1952,15 @@
+ else if (strcmp(format, "IEEE, big-endian") == 0) {
+ f = ieee_big_endian_format;
+ }
++ else if (strcmp(format, "IEEE, ARM mixed-endian") == 0 &&
++ p == &double_format) {
++ f = ieee_arm_mixed_endian_format;
++ }
+ else {
+ PyErr_SetString(PyExc_ValueError,
+ "__setformat__() argument 2 must be "
+- "'unknown', 'IEEE, little-endian' or "
+- "'IEEE, big-endian'");
++ "'unknown', 'IEEE, little-endian', "
++ "'IEEE, big-endian' or 'IEEE, ARM mixed-endian'");
+ return NULL;
+
+ }
+@@ -1967,8 +1983,10 @@
+ "used in Python's test suite.\n"
+ "\n"
+ "typestr must be 'double' or 'float'. fmt must be one of 'unknown',\n"
+-"'IEEE, big-endian' or 'IEEE, little-endian', and in addition can only be\n"
+-"one of the latter two if it appears to match the underlying C reality.\n"
++"'IEEE, big-endian', 'IEEE, little-endian' or 'IEEE, ARM mixed-endian'\n"
++"and in addition can only be one of the last three if it appears to\n"
++"match the underlying C reality. Note that the ARM mixed-endian\n"
++"format can only be set for the 'double' type, not for 'float'.\n"
+ "\n"
+ "Override the automatic determination of C-level floating point type.\n"
+ "This affects how floats are converted to and from binary strings.");
+@@ -2163,7 +2181,11 @@
+ Note that if we're on some whacked-out platform which uses
+ IEEE formats but isn't strictly little-endian or big-
+ endian, we will fall back to the portable shifts & masks
+- method. */
++ method.
++
++ Addendum: We also attempt to detect the mixed-endian IEEE format
++ used by the ARM old ABI (OABI) and also used by the FPA
++ floating-point unit on some older ARM processors. */
+
+ #if SIZEOF_DOUBLE == 8
+ {
+@@ -2172,6 +2194,8 @@
+ detected_double_format = ieee_big_endian_format;
+ else if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
+ detected_double_format = ieee_little_endian_format;
++ else if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
++ detected_double_format = ieee_arm_mixed_endian_format;
+ else
+ detected_double_format = unknown_format;
+ }
+@@ -2517,17 +2541,31 @@
+ }
+ else {
+ const char *s = (char*)&x;
+- int i, incr = 1;
++ int i;
++ const unsigned char *byteorder;
+
+- if ((double_format == ieee_little_endian_format && !le)
+- || (double_format == ieee_big_endian_format && le)) {
+- p += 7;
+- incr = -1;
++ switch (double_format) {
++ case ieee_little_endian_format:
++ byteorder = LITTLE_ENDIAN_BYTEORDER;
++ break;
++ case ieee_big_endian_format:
++ byteorder = BIG_ENDIAN_BYTEORDER;
++ break;
++ case ieee_arm_mixed_endian_format:
++ byteorder = ARM_MIXED_ENDIAN_BYTEORDER;
++ break;
++ default:
++ Py_FatalError("insane float_format or double_format");
++ return -1;
+ }
+
+- for (i = 0; i < 8; i++) {
+- *p = *s++;
+- p += incr;
++ if (le) {
++ for (i = 0; i < 8; i++)
++ p[byteorder[i]] = *s++;
++ }
++ else {
++ for (i = 0; i < 8; i++)
++ p[7-byteorder[i]] = *s++;
+ }
+ return 0;
+ }
+@@ -2686,22 +2724,33 @@
+ }
+ else {
+ double x;
++ char *s = (char*)&x;
++ const unsigned char *byteorder;
++ int i;
++
++ switch (double_format) {
++ case ieee_little_endian_format:
++ byteorder = LITTLE_ENDIAN_BYTEORDER;
++ break;
++ case ieee_big_endian_format:
++ byteorder = BIG_ENDIAN_BYTEORDER;
++ break;
++ case ieee_arm_mixed_endian_format:
++ byteorder = ARM_MIXED_ENDIAN_BYTEORDER;
++ break;
++ default:
++ Py_FatalError("insane float_format or double_format");
++ return -1.0;
++ }
+
+- if ((double_format == ieee_little_endian_format && !le)
+- || (double_format == ieee_big_endian_format && le)) {
+- char buf[8];
+- char *d = &buf[7];
+- int i;
+-
+- for (i = 0; i < 8; i++) {
+- *d-- = *p++;
+- }
+- memcpy(&x, buf, 8);
++ if (le) {
++ for (i=0; i<8; i++)
++ *s++ = p[byteorder[i]];
+ }
+ else {
+- memcpy(&x, p, 8);
++ for (i=0; i<8; i++)
++ *s++ = p[7-byteorder[i]];
+ }
+-
+ return x;
+ }
+ }
diff --git a/patches/24_all_tests_environment.patch b/patches/24_all_tests_environment.patch
new file mode 100644
index 0000000..85a4ec3
--- /dev/null
+++ b/patches/24_all_tests_environment.patch
@@ -0,0 +1,169 @@
+http://bugs.python.org/issue1674555
+
+--- Lib/site.py
++++ Lib/site.py
+@@ -527,8 +527,9 @@
+ known_paths = removeduppaths()
+ if ENABLE_USER_SITE is None:
+ ENABLE_USER_SITE = check_enableusersite()
+- known_paths = addusersitepackages(known_paths)
+- known_paths = addsitepackages(known_paths)
++ if os.environ.get("_PYTHONNOSITEPACKAGES") is None:
++ known_paths = addusersitepackages(known_paths)
++ known_paths = addsitepackages(known_paths)
+ if sys.platform == 'os2emx':
+ setBEGINLIBPATH()
+ setquit()
+--- Lib/test/regrtest.py
++++ Lib/test/regrtest.py
+@@ -168,6 +168,7 @@
+ import imp
+ import platform
+ import sysconfig
++from subprocess import Popen, PIPE
+
+
+ # Some times __path__ and __file__ are not absolute (e.g. while running from
+@@ -451,6 +452,49 @@
+ test_support.use_resources = use_resources
+ save_modules = sys.modules.keys()
+
++ opt_args = test_support.args_from_interpreter_flags()
++ base_cmd = [sys.executable] + opt_args + ['-m', 'test.regrtest']
++ debug_output_pat = re.compile(r"\[\d+ refs\]$")
++
++ def get_args_tuple(test, verbose, quiet, huntrleaks, use_resources):
++ return (
++ (test, verbose, quiet),
++ dict(huntrleaks=huntrleaks, use_resources=use_resources)
++ )
++
++ def _runtest(test, verbose, quiet, huntrleaks=False,
++ use_resources=None):
++ if test == "test_site":
++ args_tuple = get_args_tuple(test, verbose, quiet, huntrleaks,
++ use_resources)
++ env = os.environ.copy()
++ try:
++ del env["_PYTHONNOSITEPACKAGES"]
++ except KeyError:
++ pass
++ popen = Popen(base_cmd + ['--slaveargs', json.dumps(args_tuple)],
++ stdout=PIPE, stderr=PIPE,
++ universal_newlines=True,
++ close_fds=(os.name != 'nt'),
++ env=env)
++ stdout, stderr = popen.communicate()
++ # Strip last refcount output line if it exists, since it
++ # comes from the shutdown of the interpreter in the subcommand.
++ stderr = debug_output_pat.sub("", stderr)
++ stdout, _, result = stdout.strip().rpartition("\n")
++ result = json.loads(result)
++ if stdout:
++ print stdout
++ if stderr:
++ print >>sys.stderr, stderr
++ if result[0] == INTERRUPTED:
++ assert result[1] == 'KeyboardInterrupt'
++ raise KeyboardInterrupt
++ return result
++ else:
++ return runtest(test, verbose, quiet, huntrleaks=False,
++ use_resources=None)
++
+ def accumulate_result(test, result):
+ ok, test_time = result
+ test_times.append((test_time, test))
+@@ -485,19 +529,13 @@
+ print "Multiprocess option requires thread support"
+ sys.exit(2)
+ from Queue import Queue
+- from subprocess import Popen, PIPE
+- debug_output_pat = re.compile(r"\[\d+ refs\]$")
+ output = Queue()
+ def tests_and_args():
+ for test in tests:
+- args_tuple = (
+- (test, verbose, quiet),
+- dict(huntrleaks=huntrleaks, use_resources=use_resources)
+- )
++ args_tuple = get_args_tuple(test, verbose, quiet, huntrleaks,
++ use_resources)
+ yield (test, args_tuple)
+ pending = tests_and_args()
+- opt_args = test_support.args_from_interpreter_flags()
+- base_cmd = [sys.executable] + opt_args + ['-m', 'test.regrtest']
+ def work():
+ # A worker thread.
+ try:
+@@ -560,15 +598,15 @@
+ if trace:
+ # If we're tracing code coverage, then we don't exit with status
+ # if on a false return value from main.
+- tracer.runctx('runtest(test, verbose, quiet)',
++ tracer.runctx('_runtest(test, verbose, quiet)',
+ globals=globals(), locals=vars())
+ else:
+ try:
+- result = runtest(test, verbose, quiet, huntrleaks)
++ result = _runtest(test, verbose, quiet, huntrleaks)
+ accumulate_result(test, result)
+ if verbose3 and result[0] == FAILED:
+ print "Re-running test %r in verbose mode" % test
+- runtest(test, True, quiet, huntrleaks)
++ _runtest(test, True, quiet, huntrleaks)
+ except KeyboardInterrupt:
+ interrupted = True
+ break
+@@ -638,7 +676,7 @@
+ sys.stdout.flush()
+ try:
+ test_support.verbose = True
+- ok = runtest(test, True, quiet, huntrleaks)
++ ok = _runtest(test, True, quiet, huntrleaks)
+ except KeyboardInterrupt:
+ # print a newline separate from the ^C
+ print
+@@ -847,8 +885,9 @@
+ for name, get, restore in self.resource_info():
+ current = get()
+ original = saved_values.pop(name)
+- # Check for changes to the resource's value
+- if current != original:
++ # Check for changes to the resource's value. test_site is always run
++ # in a subprocess and is allowed to change os.environ and sys.path.
++ if current != original and self.testname != "test_site":
+ self.changed = True
+ restore(original)
+ if not self.quiet:
+--- Lib/test/test_site.py
++++ Lib/test/test_site.py
+@@ -8,6 +8,7 @@
+ from test.test_support import run_unittest, TESTFN, EnvironmentVarGuard
+ from test.test_support import captured_output
+ import __builtin__
++import imp
+ import os
+ import sys
+ import re
+@@ -21,6 +22,9 @@
+ # already.
+ if "site" in sys.modules:
+ import site
++ if "_PYTHONNOSITEPACKAGES" in os.environ:
++ del os.environ["_PYTHONNOSITEPACKAGES"]
++ imp.reload(site)
+ else:
+ raise unittest.SkipTest("importation of site.py suppressed")
+
+--- Makefile.pre.in
++++ Makefile.pre.in
+@@ -793,7 +793,7 @@
+
+ TESTOPTS= -l $(EXTRATESTOPTS)
+ TESTPROG= $(srcdir)/Lib/test/regrtest.py
+-TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -Wd -3 -E -tt $(TESTPYTHONOPTS)
++TESTPYTHON= _PYTHONNOSITEPACKAGES=1 $(RUNSHARED) ./$(BUILDPYTHON) -Wd -3 -E -tt $(TESTPYTHONOPTS)
+ test: all platform
+ -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
+ -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
diff --git a/patches/61_all_process_data.patch b/patches/61_all_process_data.patch
new file mode 100644
index 0000000..6f02c8a
--- /dev/null
+++ b/patches/61_all_process_data.patch
@@ -0,0 +1,128 @@
+GENTOO_PYTHON_PROCESS_NAME environmental variable is set by python-wrapper and wrapper scripts generated by
+python_generate_wrapper_scripts() and specifies process name.
+GENTOO_PYTHON_WRAPPER_SCRIPT_PATH environmental variable is set by wrapper scripts generated by
+python_generate_wrapper_scripts() and specifies sys.argv[0] in target executables.
+GENTOO_PYTHON_TARGET_SCRIPT_PATH environmental variable is set by wrapper scripts generated by
+python_generate_wrapper_scripts() and specifies paths to actually executed scripts.
+GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION environmental variable is used by wrapper scripts generated by
+python_generate_wrapper_scripts() to check if Python supports GENTOO_PYTHON_TARGET_SCRIPT_PATH environmental variable.
+
+--- Modules/main.c
++++ Modules/main.c
+@@ -252,6 +252,7 @@
+ int version = 0;
+ int saw_unbuffered_flag = 0;
+ PyCompilerFlags cf;
++ char *target_script_name = getenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH");
+
+ cf.cf_flags = 0;
+
+@@ -486,7 +487,10 @@
+ filename = argv[_PyOS_optind];
+
+ #else
+- filename = argv[_PyOS_optind];
++ if (target_script_name != NULL && *target_script_name != '\0')
++ filename = target_script_name;
++ else
++ filename = argv[_PyOS_optind];
+ #endif
+ }
+
+--- Modules/posixmodule.c
++++ Modules/posixmodule.c
+@@ -604,6 +604,10 @@
+ char *p = strchr(*e, '=');
+ if (p == NULL)
+ continue;
++ if ((strlen("GENTOO_PYTHON_PROCESS_NAME") == (int)(p-*e) && strncmp("GENTOO_PYTHON_PROCESS_NAME", *e, (int)(p-*e)) == 0) ||
++ (strlen("GENTOO_PYTHON_TARGET_SCRIPT_PATH") == (int)(p-*e) && strncmp("GENTOO_PYTHON_TARGET_SCRIPT_PATH", *e, (int)(p-*e)) == 0) ||
++ (strlen("GENTOO_PYTHON_WRAPPER_SCRIPT_PATH") == (int)(p-*e) && strncmp("GENTOO_PYTHON_WRAPPER_SCRIPT_PATH", *e, (int)(p-*e)) == 0))
++ continue;
+ k = PyString_FromStringAndSize(*e, (int)(p-*e));
+ if (k == NULL) {
+ PyErr_Clear();
+--- Modules/python.c
++++ Modules/python.c
+@@ -6,9 +6,22 @@
+ #include <floatingpoint.h>
+ #endif
+
++#ifdef __linux__
++#include <linux/prctl.h>
++#include <sys/prctl.h>
++#ifndef PR_SET_NAME
++#define PR_SET_NAME 15
++#endif
++#endif
++
+ int
+ main(int argc, char **argv)
+ {
++ if (getenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION")) {
++ printf("GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n");
++ return 0;
++ }
++
+ /* 754 requires that FP exceptions run in "no stop" mode by default,
+ * and until C vendors implement C99's ways to control FP exceptions,
+ * Python requires non-stop mode. Alas, some platforms enable FP
+@@ -20,5 +33,15 @@
+ m = fpgetmask();
+ fpsetmask(m & ~FP_X_OFL);
+ #endif
++
++#ifdef __linux__
++ char *process_name = getenv("GENTOO_PYTHON_PROCESS_NAME");
++#ifdef HAVE_UNSETENV
++ unsetenv("GENTOO_PYTHON_PROCESS_NAME");
++#endif
++ if (process_name != NULL && *process_name != '\0')
++ prctl(PR_SET_NAME, process_name);
++#endif
++
+ return Py_Main(argc, argv);
+ }
+--- Python/sysmodule.c
++++ Python/sysmodule.c
+@@ -1560,6 +1560,10 @@
+ makeargvobject(int argc, char **argv)
+ {
+ PyObject *av;
++ char *wrapper_script_name = getenv("GENTOO_PYTHON_WRAPPER_SCRIPT_PATH");
++#ifdef HAVE_UNSETENV
++ unsetenv("GENTOO_PYTHON_WRAPPER_SCRIPT_PATH");
++#endif
+ if (argc <= 0 || argv == NULL) {
+ /* Ensure at least one (empty) argument is seen */
+ static char *empty_argv[1] = {""};
+@@ -1584,7 +1588,11 @@
+ } else
+ v = PyString_FromString(argv[i]);
+ #else
+- PyObject *v = PyString_FromString(argv[i]);
++ PyObject *v;
++ if (i == 0 && wrapper_script_name != NULL && *wrapper_script_name != '\0')
++ v = PyString_FromString(wrapper_script_name);
++ else
++ v = PyString_FromString(argv[i]);
+ #endif
+ if (v == NULL) {
+ Py_DECREF(av);
+@@ -1612,7 +1620,15 @@
+ if (PySys_SetObject("argv", av) != 0)
+ Py_FatalError("can't assign sys.argv");
+ if (updatepath && path != NULL) {
+- char *argv0 = argv[0];
++ char *target_script_name = getenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH");
++#ifdef HAVE_UNSETENV
++ unsetenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH");
++#endif
++ char *argv0;
++ if (target_script_name != NULL && *target_script_name != '\0')
++ argv0 = target_script_name;
++ else
++ argv0 = argv[0];
+ char *p = NULL;
+ Py_ssize_t n = 0;
+ PyObject *a;
diff --git a/patches/62_all_xml.use_pyxml.patch b/patches/62_all_xml.use_pyxml.patch
new file mode 100644
index 0000000..064fd9a
--- /dev/null
+++ b/patches/62_all_xml.use_pyxml.patch
@@ -0,0 +1,41 @@
+--- Lib/xml/__init__.py
++++ Lib/xml/__init__.py
+@@ -22,20 +22,23 @@
+ _MINIMUM_XMLPLUS_VERSION = (0, 8, 4)
+
+
+-try:
++def use_pyxml():
+ import _xmlplus
+-except ImportError:
+- pass
+-else:
+- try:
+- v = _xmlplus.version_info
+- except AttributeError:
+- # _xmlplus is too old; ignore it
+- pass
++ v = _xmlplus.version_info
++ if v >= _MINIMUM_XMLPLUS_VERSION:
++ import sys
++ _xmlplus.__path__.extend(__path__)
++ sys.modules[__name__] = _xmlplus
++ cleared_modules = []
++ redefined_modules = []
++ for module in sys.modules:
++ if module.startswith("xml.") and not module.startswith(("xml.marshal", "xml.schema", "xml.utils", "xml.xpath", "xml.xslt")):
++ cleared_modules.append(module)
++ if module.startswith(("xml.__init__", "xml.dom", "xml.parsers", "xml.sax")) and sys.modules[module] is not None:
++ redefined_modules.append(module)
++ for module in cleared_modules:
++ del sys.modules[module]
++ for module in sorted(redefined_modules):
++ __import__(module)
+ else:
+- if v >= _MINIMUM_XMLPLUS_VERSION:
+- import sys
+- _xmlplus.__path__.extend(__path__)
+- sys.modules[__name__] = _xmlplus
+- else:
+- del v
++ raise ImportError("PyXML too old: %s" % ".".join(str(x) for x in v))