summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2014-03-27 21:13:25 -0400
committerMike Gilbert <floppym@gentoo.org>2014-03-27 21:13:25 -0400
commit0776087bb18dbad9f83374751ef895e8122e5e15 (patch)
treeb868bcfd2b10201c065d7b857a6de8d1f5a0d98e
parentAdd Makefile (diff)
downloadpython-gentoo-patches-3.3.4.tar.gz
python-gentoo-patches-3.3.4.tar.bz2
python-gentoo-patches-3.3.4.zip
Add 3.3.43.3.4-03.3.4
-rw-r--r--patches/01_all_static_library_location.patch70
-rw-r--r--patches/02_all_disable_modules_and_ssl.patch57
-rw-r--r--patches/03_all_libdir.patch174
-rw-r--r--patches/04_all_non-zero_exit_status_on_failure.patch31
-rw-r--r--patches/05_all_regenerate_platform-specific_modules.patch123
-rw-r--r--patches/21_all_distutils_c++.patch271
-rw-r--r--patches/22_all_tests_environment.patch192
-rw-r--r--patches/23_all_h2py_encoding.patch173
-rw-r--r--patches/61_all_process_data.patch166
9 files changed, 1257 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..fb33aa0
--- /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
+@@ -965,6 +965,19 @@
+ fi; \
+ else true; \
+ fi
++ @if test -f $(LIBRARY) && test $(LIBRARY) != $(LDLIBRARY); then \
++ if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
++ if test "$(SHLIB_SUFFIX)" = .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
+
+ bininstall: altbininstall
+ -if test -f $(DESTDIR)$(BINDIR)/python3$(EXE) -o -h $(DESTDIR)$(BINDIR)/python3$(EXE); \
+@@ -1199,18 +1212,6 @@
+ else true; \
+ fi; \
+ done
+- @if test -d $(LIBRARY); then :; else \
+- if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
+- if test "$(SHLIB_SUFFIX)" = .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
+@@ -47,11 +47,7 @@
+ elif opt in ('--libs', '--ldflags'):
+ libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
+ libs.append('-lpython' + pyver + sys.abiflags)
+- # 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..af735be
--- /dev/null
+++ b/patches/02_all_disable_modules_and_ssl.patch
@@ -0,0 +1,57 @@
+--- setup.py
++++ setup.py
+@@ -31,7 +31,17 @@
+ 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' (after any relative
+@@ -435,6 +445,7 @@
+ os.unlink(tmpfile)
+
+ def detect_modules(self):
++ global disable_ssl
+ # Ensure that /usr/local is always used, but the local build
+ # directories (i.e. '.' and 'Include') must be first. See issue
+ # 10520.
+@@ -747,7 +758,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:
+@@ -758,7 +769,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,
+@@ -791,7 +803,7 @@
+
+ #print('openssl_ver = 0x%08x' % openssl_ver)
+ 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)
+
diff --git a/patches/03_all_libdir.patch b/patches/03_all_libdir.patch
new file mode 100644
index 0000000..052c51d
--- /dev/null
+++ b/patches/03_all_libdir.patch
@@ -0,0 +1,174 @@
+--- Lib/distutils/command/install.py
++++ Lib/distutils/command/install.py
+@@ -44,8 +44,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$abiflags/$dist_name',
+ 'scripts': '$base/bin',
+ 'data' : '$base',
+--- Lib/distutils/sysconfig.py
++++ Lib/distutils/sysconfig.py
+@@ -144,7 +144,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
+@@ -303,10 +303,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
+@@ -21,10 +21,10 @@
+
+ _INSTALL_SCHEMES = {
+ 'posix_prefix': {
+- 'stdlib': '{installed_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': '{installed_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':
+ '{installed_base}/include/python{py_version_short}{abiflags}',
+ 'platinclude':
+@@ -81,10 +81,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
+@@ -248,10 +248,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
+@@ -115,7 +115,7 @@
+ MANDIR= @mandir@
+ INCLUDEDIR= @includedir@
+ CONFINCLUDEDIR= $(exec_prefix)/include
+-SCRIPTDIR= $(prefix)/lib
++SCRIPTDIR= $(prefix)/@@GENTOO_LIBDIR@@
+ ABIFLAGS= @ABIFLAGS@
+
+ # Detailed destination directories
+--- Modules/getpath.c
++++ Modules/getpath.c
+@@ -122,8 +122,8 @@
+ #endif
+
+ #ifndef PYTHONPATH
+-#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \
+- EXEC_PREFIX "/lib/python" VERSION "/lib-dynload"
++#define PYTHONPATH PREFIX "/@@GENTOO_LIBDIR@@/python" VERSION ":" \
++ EXEC_PREFIX "/@@GENTOO_LIBDIR@@/python" VERSION "/lib-dynload"
+ #endif
+
+ #ifndef LANDMARK
+@@ -135,7 +135,7 @@
+ static wchar_t progpath[MAXPATHLEN+1];
+ static wchar_t *module_search_path = NULL;
+ static int module_search_path_malloced = 0;
+-static wchar_t *lib_python = L"lib/python" VERSION;
++static wchar_t *lib_python = L"@@GENTOO_LIBDIR@@/python" VERSION;
+
+ static void
+ reduce(wchar_t *dir)
+@@ -685,7 +685,7 @@
+ }
+ else
+ wcsncpy(zip_path, _prefix, MAXPATHLEN);
+- joinpath(zip_path, L"lib/python00.zip");
++ joinpath(zip_path, L"@@GENTOO_LIBDIR@@/python00.zip");
+ bufsz = wcslen(zip_path); /* Replace "00" with version */
+ zip_path[bufsz - 6] = VERSION[0];
+ zip_path[bufsz - 5] = VERSION[2];
+@@ -695,7 +695,7 @@
+ fprintf(stderr,
+ "Could not find platform dependent libraries <exec_prefix>\n");
+ wcsncpy(exec_prefix, _exec_prefix, MAXPATHLEN);
+- joinpath(exec_prefix, L"lib/lib-dynload");
++ joinpath(exec_prefix, L"@@GENTOO_LIBDIR@@/lib-dynload");
+ }
+ /* If we found EXEC_PREFIX do *not* reduce it! (Yet.) */
+
+--- Modules/Setup.dist
++++ Modules/Setup.dist
+@@ -354,7 +354,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
+@@ -507,8 +507,7 @@
+ # be assumed that no additional -I,-L directives are needed.
+ if not cross_compiling:
+ lib_dirs = self.compiler.library_dirs + [
+- '/lib64', '/usr/lib64',
+- '/lib', '/usr/lib',
++ '/@@GENTOO_LIBDIR@@', '/usr/@@GENTOO_LIBDIR@@',
+ ]
+ inc_dirs = self.compiler.include_dirs + ['/usr/include']
+ else:
+@@ -723,11 +722,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..58b839f
--- /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
+@@ -43,6 +43,8 @@
+ else:
+ disable_ssl = 0
+
++exit_status = 0
++
+ def add_dir_to_list(dirlist, dir):
+ """Add the directory 'dir' to the list 'dirlist' (after any relative
+ directories) if:
+@@ -277,6 +279,8 @@
+ print()
+
+ if self.failed:
++ global exit_status
++ exit_status = 1
+ failed = self.failed[:]
+ print()
+ print("Failed to build these modules:")
+@@ -2213,6 +2217,7 @@
+ scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
+ "Tools/scripts/2to3", "Tools/scripts/pyvenv"]
+ )
++ sys.exit(exit_status)
+
+ # --install-platlib
+ if __name__ == '__main__':
diff --git a/patches/05_all_regenerate_platform-specific_modules.patch b/patches/05_all_regenerate_platform-specific_modules.patch
new file mode 100644
index 0000000..5e2a74f
--- /dev/null
+++ b/patches/05_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-linux/regen
++++ Lib/plat-linux/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
+@@ -444,7 +444,7 @@
+
+ # Default target
+ all: build_all
+-build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Modules/_testembed
++build_all: $(BUILDPYTHON) oldsharedmods sharedmods platformspecificmods gdbhooks Modules/_testembed
+
+ # Compile a binary with gcc profile guided optimization.
+ profile-opt:
+@@ -500,6 +500,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="`pwd`/Lib"; export PYTHONPATH; \
++ if [ -n "$(MULTIARCH)" ]; then MULTIARCH=$(MULTIARCH); export MULTIARCH; fi; \
++ if [ "$(BUILD_GNU_TYPE)" = "$(HOST_GNU_TYPE)" ]; 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)
+@@ -1073,7 +1099,7 @@
+ unittest unittest/test unittest/test/testmock \
+ venv venv/scripts venv/scripts/posix \
+ 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 \
+@@ -1156,23 +1182,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="`pwd`/Lib"; \
+- 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_GNU_TYPE)" = "$(HOST_GNU_TYPE)" ]; 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
+@@ -1475,7 +1484,7 @@
+ Python/thread.o: @THREADHEADERS@
+
+ # Declare targets that aren't real files
+-.PHONY: all build_all sharedmods oldsharedmods test quicktest
++.PHONY: all build_all sharedmods oldsharedmods platformspecificmods test quicktest
+ .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..1f6c19a
--- /dev/null
+++ b/patches/21_all_distutils_c++.patch
@@ -0,0 +1,271 @@
+http://bugs.python.org/issue1222585
+
+--- Lib/distutils/cygwinccompiler.py
++++ Lib/distutils/cygwinccompiler.py
+@@ -124,8 +124,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
+@@ -139,9 +141,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":
+@@ -165,8 +171,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 as msg:
+ raise CompileError(msg)
+
+@@ -302,9 +312,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
+@@ -63,8 +63,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)
+@@ -81,8 +85,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 as msg:
+ raise CompileError(msg)
+
+--- Lib/distutils/sysconfig.py
++++ Lib/distutils/sysconfig.py
+@@ -191,9 +191,12 @@
+ _osx_support.customize_compiler(_config_vars)
+ _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
+
+- (cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
+- get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
+- 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
++ (cc, cxx, ccshared, ldshared, ldcxxshared, shlib_suffix, ar, ar_flags) = \
++ get_config_vars('CC', 'CXX', 'CCSHARED', 'LDSHARED', 'LDCXXSHARED',
++ 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
++
++ cflags = ''
++ cxxflags = ''
+
+ if 'CC' in os.environ:
+ newcc = os.environ['CC']
+@@ -208,19 +211,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:
+@@ -229,13 +240,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 = shlib_suffix
+--- Lib/distutils/unixccompiler.py
++++ Lib/distutils/unixccompiler.py
+@@ -52,14 +52,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":
+@@ -108,12 +111,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 as msg:
+ raise CompileError(msg)
+
+@@ -171,22 +181,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 += 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
+@@ -496,7 +496,7 @@
+ *\ -s*|s*) quiet="-q";; \
+ *) quiet="";; \
+ esac; \
+- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
++ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' CFLAGS='$(PY_CFLAGS)' \
+ _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
+ $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
+
diff --git a/patches/22_all_tests_environment.patch b/patches/22_all_tests_environment.patch
new file mode 100644
index 0000000..edb3351
--- /dev/null
+++ b/patches/22_all_tests_environment.patch
@@ -0,0 +1,192 @@
+http://bugs.python.org/issue1674555
+
+--- Lib/site.py
++++ Lib/site.py
+@@ -587,8 +587,9 @@
+ known_paths = venv(known_paths)
+ 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
+@@ -188,6 +188,7 @@
+ import unittest
+ import warnings
+ from inspect import isabstract
++from subprocess import Popen, PIPE
+
+ try:
+ import threading
+@@ -578,6 +579,62 @@
+ support.use_resources = use_resources
+ save_modules = sys.modules.keys()
+
++ opt_args = 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, debug, use_resources,
++ output_on_failure, failfast, match_tests, timeout):
++ return (
++ (test, verbose, quiet),
++ dict(huntrleaks=huntrleaks, debug=debug,
++ use_resources=use_resources,
++ output_on_failure=output_on_failure, failfast=failfast,
++ match_tests=match_tests, timeout=timeout)
++ )
++
++ def _runtest(test, verbose, quiet, huntrleaks=False, debug=False,
++ use_resources=None, output_on_failure=False, failfast=False,
++ match_tests=None, timeout=None):
++ if test == "test_site":
++ args_tuple = get_args_tuple(test, verbose, quiet, huntrleaks, debug,
++ use_resources, output_on_failure,
++ failfast, match_tests, timeout)
++ 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()
++ retcode = popen.wait()
++ # 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")
++ if retcode != 0:
++ result = (CHILD_ERROR, "Exit code %s" % retcode)
++ else:
++ result = json.loads(result)
++ if stdout:
++ print(stdout)
++ if stderr:
++ print(stderr, file=sys.stderr)
++ if result[0] == INTERRUPTED:
++ assert result[1] == 'KeyboardInterrupt'
++ raise KeyboardInterrupt
++ return result
++ else:
++ return runtest(test, verbose, quiet, huntrleaks=huntrleaks,
++ debug=debug, use_resources=use_resources,
++ output_on_failure=output_on_failure,
++ failfast=failfast, match_tests=match_tests,
++ timeout=timeout)
++
+ def accumulate_result(test, result):
+ ok, test_time = result
+ test_times.append((test_time, test))
+@@ -615,12 +672,8 @@
+ 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()
+ pending = MultiprocessTests(tests)
+- opt_args = support.args_from_interpreter_flags()
+- base_cmd = [sys.executable] + opt_args + ['-m', 'test.regrtest']
+ def work():
+ # A worker thread.
+ try:
+@@ -630,13 +683,9 @@
+ except StopIteration:
+ output.put((None, None, None, None))
+ return
+- args_tuple = (
+- (test, verbose, quiet),
+- dict(huntrleaks=huntrleaks, use_resources=use_resources,
+- debug=debug, output_on_failure=verbose3,
+- timeout=timeout, failfast=failfast,
+- match_tests=match_tests)
+- )
++ args_tuple = get_args_tuple(test, verbose, quiet, huntrleaks,
++ debug, use_resources, verbose3,
++ failfast, match_tests, timeout)
+ # -E is needed by some tests, e.g. test_import
+ # Running the child from the same working directory ensures
+ # that TEMPDIR for the child is the same when
+@@ -707,14 +756,14 @@
+ 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, timeout=timeout)',
++ tracer.runctx('_runtest(test, verbose, quiet, timeout=timeout)',
+ globals=globals(), locals=vars())
+ else:
+ try:
+- result = runtest(test, verbose, quiet, huntrleaks, debug,
+- output_on_failure=verbose3,
+- timeout=timeout, failfast=failfast,
+- match_tests=match_tests)
++ result = _runtest(test, verbose, quiet, huntrleaks, debug,
++ output_on_failure=verbose3,
++ timeout=timeout, failfast=failfast,
++ match_tests=match_tests)
+ accumulate_result(test, result)
+ except KeyboardInterrupt:
+ interrupted = True
+@@ -785,7 +834,7 @@
+ sys.stdout.flush()
+ try:
+ verbose = True
+- ok = runtest(test, True, quiet, huntrleaks, debug, timeout=timeout)
++ ok = _runtest(test, True, quiet, huntrleaks, debug, timeout=timeout)
+ except KeyboardInterrupt:
+ # print a newline separate from the ^C
+ print()
+@@ -1182,8 +1231,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 @@
+ import test.support
+ from test.support import captured_stderr, TESTFN, EnvironmentVarGuard
+ import builtins
++import imp
+ import os
+ import sys
+ import re
+@@ -26,6 +27,10 @@
+
+ import site
+
++if "_PYTHONNOSITEPACKAGES" in os.environ:
++ del os.environ["_PYTHONNOSITEPACKAGES"]
++ imp.reload(site)
++
+ if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE):
+ # need to add user site directory for tests
+ os.makedirs(site.USER_SITE)
+--- Makefile.pre.in
++++ Makefile.pre.in
+@@ -883,7 +883,7 @@
+ ######################################################################
+
+ TESTOPTS= $(EXTRATESTOPTS)
+-TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) $(TESTPYTHONOPTS)
++TESTPYTHON= _PYTHONNOSITEPACKAGES=1 $(RUNSHARED) ./$(BUILDPYTHON) $(TESTPYTHONOPTS)
+ TESTRUNNER= $(TESTPYTHON) $(srcdir)/Tools/scripts/run_tests.py
+ TESTTIMEOUT= 3600
+
diff --git a/patches/23_all_h2py_encoding.patch b/patches/23_all_h2py_encoding.patch
new file mode 100644
index 0000000..d594f56
--- /dev/null
+++ b/patches/23_all_h2py_encoding.patch
@@ -0,0 +1,173 @@
+http://bugs.python.org/issue13032
+
+--- Tools/scripts/h2py.py
++++ Tools/scripts/h2py.py
+@@ -23,36 +23,36 @@
+
+ import sys, re, getopt, os
+
+-p_define = re.compile('^[\t ]*#[\t ]*define[\t ]+([a-zA-Z0-9_]+)[\t ]+')
++p_define = re.compile(b'^[\t ]*#[\t ]*define[\t ]+([a-zA-Z0-9_]+)[\t ]+')
+
+ p_macro = re.compile(
+- '^[\t ]*#[\t ]*define[\t ]+'
+- '([a-zA-Z0-9_]+)\(([_a-zA-Z][_a-zA-Z0-9]*)\)[\t ]+')
++ b'^[\t ]*#[\t ]*define[\t ]+'
++ b'([a-zA-Z0-9_]+)\(([_a-zA-Z][_a-zA-Z0-9]*)\)[\t ]+')
+
+-p_include = re.compile('^[\t ]*#[\t ]*include[\t ]+<([a-zA-Z0-9_/\.]+)')
++p_include = re.compile(b'^[\t ]*#[\t ]*include[\t ]+<([a-zA-Z0-9_/\.]+)')
+
+-p_comment = re.compile(r'/\*([^*]+|\*+[^/])*(\*+/)?')
+-p_cpp_comment = re.compile('//.*')
++p_comment = re.compile(br'/\*([^*]+|\*+[^/])*(\*+/)?')
++p_cpp_comment = re.compile(b'//.*')
+
+ ignores = [p_comment, p_cpp_comment]
+
+-p_char = re.compile(r"'(\\.[^\\]*|[^\\])'")
++p_char = re.compile(br"'(\\.[^\\]*|[^\\])'")
+
+-p_hex = re.compile(r"0x([0-9a-fA-F]+)L?")
++p_hex = re.compile(br"0x([0-9a-fA-F]+)L?")
+
+ filedict = {}
+ importable = {}
+
+ try:
+- searchdirs=os.environ['include'].split(';')
++ searchdirs=os.environb[b'include'].split(b';')
+ except KeyError:
+ try:
+- searchdirs=os.environ['INCLUDE'].split(';')
++ searchdirs=os.environb[b'INCLUDE'].split(b';')
+ except KeyError:
+- searchdirs=['/usr/include']
++ searchdirs=[b'/usr/include']
+ try:
+- searchdirs.insert(0, os.path.join('/usr/include',
+- os.environ['MULTIARCH']))
++ searchdirs.insert(0, os.path.join(b'/usr/include',
++ os.environb[b'MULTIARCH']))
+ except KeyError:
+ pass
+
+@@ -61,22 +61,23 @@
+ opts, args = getopt.getopt(sys.argv[1:], 'i:')
+ for o, a in opts:
+ if o == '-i':
+- ignores.append(re.compile(a))
++ ignores.append(re.compile(a.encode()))
+ if not args:
+ args = ['-']
+ for filename in args:
+ if filename == '-':
+ sys.stdout.write('# Generated by h2py from stdin\n')
+- process(sys.stdin, sys.stdout)
++ process(sys.stdin.buffer, sys.stdout.buffer)
+ else:
+- fp = open(filename, 'r')
++ filename = filename.encode()
++ fp = open(filename, 'rb')
+ outfile = os.path.basename(filename)
+- i = outfile.rfind('.')
++ i = outfile.rfind(b'.')
+ if i > 0: outfile = outfile[:i]
+ modname = outfile.upper()
+- outfile = modname + '.py'
+- outfp = open(outfile, 'w')
+- outfp.write('# Generated by h2py from %s\n' % filename)
++ outfile = modname + b'.py'
++ outfp = open(outfile, 'wb')
++ outfp.write(b'# Generated by h2py from ' + filename + b'\n')
+ filedict = {}
+ for dir in searchdirs:
+ if filename[:len(dir)] == dir:
+@@ -90,9 +91,9 @@
+ def pytify(body):
+ # replace ignored patterns by spaces
+ for p in ignores:
+- body = p.sub(' ', body)
++ body = p.sub(b' ', body)
+ # replace char literals by ord(...)
+- body = p_char.sub("ord('\\1')", body)
++ body = p_char.sub(b"ord('\\1')", body)
+ # Compute negative hexadecimal constants
+ start = 0
+ UMAX = 2*(sys.maxsize+1)
+@@ -103,7 +104,7 @@
+ val = int(body[slice(*m.span(1))], 16)
+ if val > sys.maxsize:
+ val -= UMAX
+- body = body[:s] + "(" + str(val) + ")" + body[e:]
++ body = body[:s] + b"(" + str(val).encode() + b")" + body[e:]
+ start = s + 1
+ return body
+
+@@ -116,7 +117,7 @@
+ match = p_define.match(line)
+ if match:
+ # gobble up continuation lines
+- while line[-2:] == '\\\n':
++ while line[-2:] == b'\\\n':
+ nextline = fp.readline()
+ if not nextline: break
+ lineno = lineno + 1
+@@ -125,11 +126,11 @@
+ body = line[match.end():]
+ body = pytify(body)
+ ok = 0
+- stmt = '%s = %s\n' % (name, body.strip())
++ stmt = name + b' = ' + body.strip() + b'\n'
+ try:
+ exec(stmt, env)
+ except:
+- sys.stderr.write('Skipping: %s' % stmt)
++ sys.stderr.buffer.write(b'Skipping: ' + stmt)
+ else:
+ outfp.write(stmt)
+ match = p_macro.match(line)
+@@ -137,11 +138,11 @@
+ macro, arg = match.group(1, 2)
+ body = line[match.end():]
+ body = pytify(body)
+- stmt = 'def %s(%s): return %s\n' % (macro, arg, body)
++ stmt = b'def ' + macro + b'(' + arg + b'): return ' + body + b'\n'
+ try:
+ exec(stmt, env)
+ except:
+- sys.stderr.write('Skipping: %s' % stmt)
++ sys.stderr.buffer.write(b'Skipping: ' + stmt)
+ else:
+ outfp.write(stmt)
+ match = p_include.match(line)
+@@ -150,23 +151,24 @@
+ a, b = regs[1]
+ filename = line[a:b]
+ if filename in importable:
+- outfp.write('from %s import *\n' % importable[filename])
++ outfp.write(b'from ' + importable[filename] + b' import *\n')
+ elif filename not in filedict:
+ filedict[filename] = None
+ inclfp = None
+ for dir in searchdirs:
+ try:
+- inclfp = open(dir + '/' + filename)
++ inclfp = open(dir + b'/' + filename, 'rb')
+ break
+ except IOError:
+ pass
+ if inclfp:
+ outfp.write(
+- '\n# Included from %s\n' % filename)
++ b'\n# Included from ' + filename + b'\n')
+ process(inclfp, outfp, env)
++ inclfp.close()
+ else:
+- sys.stderr.write('Warning - could not find file %s\n' %
+- filename)
++ sys.stderr.buffer.write(b'Warning - could not find file ' +
++ filename + b'\n')
+
+ if __name__ == '__main__':
+ main()
diff --git a/patches/61_all_process_data.patch b/patches/61_all_process_data.patch
new file mode 100644
index 0000000..cc065c4
--- /dev/null
+++ b/patches/61_all_process_data.patch
@@ -0,0 +1,166 @@
+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
+@@ -331,6 +331,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;
+
+@@ -551,7 +552,17 @@
+ filename = argv[_PyOS_optind];
+
+ #else
+- filename = argv[_PyOS_optind];
++ if (target_script_name != NULL && *target_script_name != '\0') {
++ size_t length = strlen(target_script_name);
++ wchar_t *wcs_target_script_name = (wchar_t *) calloc(length + 1, sizeof(wchar_t));
++ char *old_locale = setlocale(LC_CTYPE, NULL);
++ setlocale(LC_CTYPE, "");
++ if (mbstowcs(wcs_target_script_name, target_script_name, length) >= 0)
++ filename = wcs_target_script_name;
++ setlocale(LC_CTYPE, old_locale);
++ }
++ if (filename == NULL)
++ filename = argv[_PyOS_optind];
+ #endif
+ }
+
+--- Modules/posixmodule.c
++++ Modules/posixmodule.c
+@@ -1158,6 +1158,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 = PyBytes_FromStringAndSize(*e, (int)(p-*e));
+ if (k == NULL) {
+ PyErr_Clear();
+--- Modules/python.c
++++ Modules/python.c
+@@ -7,6 +7,14 @@
+ #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
++
+ #ifdef MS_WINDOWS
+ int
+ wmain(int argc, wchar_t **argv)
+@@ -18,6 +26,11 @@
+ int
+ main(int argc, char **argv)
+ {
++ if (getenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION")) {
++ printf("GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n");
++ return 0;
++ }
++
+ wchar_t **argv_copy;
+ /* We need a second copy, as Python might modify the first one. */
+ wchar_t **argv_copy2;
+@@ -59,6 +72,16 @@
+
+ setlocale(LC_ALL, oldloc);
+ free(oldloc);
++
++#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
++
+ res = Py_Main(argc, argv_copy);
+ for (i = 0; i < argc; i++) {
+ PyMem_Free(argv_copy2[i]);
+--- Python/sysmodule.c
++++ Python/sysmodule.c
+@@ -1779,6 +1779,10 @@
+ makeargvobject(int argc, wchar_t **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 wchar_t *empty_argv[1] = {L""};
+@@ -1803,7 +1807,16 @@
+ } else
+ v = PyUnicode_FromString(argv[i]);
+ #else
+- PyObject *v = PyUnicode_FromWideChar(argv[i], -1);
++ PyObject *v = NULL;
++ if (i == 0 && wrapper_script_name != NULL && *wrapper_script_name != '\0') {
++ size_t length = strlen(wrapper_script_name);
++ wchar_t *wcs_wrapper_script_name = (wchar_t *) calloc(length + 1, sizeof(wchar_t));
++ if (mbstowcs(wcs_wrapper_script_name, wrapper_script_name, length) >= 0)
++ v = PyUnicode_FromWideChar(wcs_wrapper_script_name, -1);
++ free(wcs_wrapper_script_name);
++ }
++ if (v == NULL)
++ v = PyUnicode_FromWideChar(argv[i], -1);
+ #endif
+ if (v == NULL) {
+ Py_DECREF(av);
+@@ -1823,7 +1836,12 @@
+ static void
+ sys_update_path(int argc, wchar_t **argv)
+ {
+- wchar_t *argv0;
++ char *target_script_name = getenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH");
++#ifdef HAVE_UNSETENV
++ unsetenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH");
++#endif
++ wchar_t *wcs_target_script_name = NULL;
++ wchar_t *argv0 = NULL;
+ wchar_t *p = NULL;
+ Py_ssize_t n = 0;
+ PyObject *a;
+@@ -1843,7 +1861,14 @@
+ if (path == NULL)
+ return;
+
+- argv0 = argv[0];
++ if (target_script_name != NULL && *target_script_name != '\0') {
++ size_t length = strlen(target_script_name);
++ wcs_target_script_name = (wchar_t *) calloc(length + 1, sizeof(wchar_t));
++ if (mbstowcs(wcs_target_script_name, target_script_name, length) >= 0)
++ argv0 = wcs_target_script_name;
++ }
++ if (argv0 == NULL)
++ argv0 = argv[0];
+
+ #ifdef HAVE_READLINK
+ if (_HAVE_SCRIPT_ARGUMENT(argc, argv))
+@@ -1920,6 +1945,7 @@
+ if (PyList_Insert(path, 0, a) < 0)
+ Py_FatalError("sys.path.insert(0) failed");
+ Py_DECREF(a);
++ free(wcs_target_script_name);
+ }
+
+ void