Commit 0d327c26 authored by Thomas Petazzoni's avatar Thomas Petazzoni Committed by Peter Korsgaard
Browse files

python3: bump to 3.4.0rc1



This commit bumps the Python3 package to use Python 3.4.0rc1.

About the patches:

 * The patches below 100 are significantly changed, because like for
   Python 2.x, a good number of improvements have been made in the
   upstream Python for cross-compilation. Therefore, almost all of
   these patches have been modified.

 * All the patches above 100 are simply updated for Python 3.4.0, with
   a small refactoring for the handling of test modules.

The details of the python3.mk changes are:

 * --without-ensurepip to tell Python to not use PIP at build time.

 * Many environment variables are no longer passed, they were specific
   to our cross-compilation patches

 * The fixup of the LIBDIR in the Python Makefile is no longer needed
   since Python has switched to _sysconfigdata.py for distutils
   configuration instead of parsing the Makefile.

 * A new post patch hooks touches the two files generated by pgen to
   make sure they are newer than the pgen sources, which ensures pgen
   is not built/executed.

Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: default avatarPeter Korsgaard <peter@korsgaard.com>
parent 24977854
Loading
Loading
Loading
Loading
+0 −158
Original line number Diff line number Diff line
changeset:   79745:f85c3f4d9b98
parent:      79743:36b2ca7dc893
parent:      79744:24d52d3060e8
user:        Trent Nelson <trent@trent.me>
date:        Tue Oct 16 08:17:11 2012 -0400
summary:     Merge issue #15298: ensure _sysconfigdata is generated in build directory,

Taken from upstream.

---
 Lib/sysconfig.py |   11 ++++++++++-
 Makefile.pre.in  |   24 +++++++++++++-----------
 setup.py         |   14 --------------
 3 files changed, 23 insertions(+), 26 deletions(-)

Index: Python-3.3.0/Lib/sysconfig.py
===================================================================
--- Python-3.3.0.orig/Lib/sysconfig.py
+++ Python-3.3.0/Lib/sysconfig.py
@@ -390,13 +390,22 @@
     if _PYTHON_BUILD:
         vars['LDSHARED'] = vars['BLDSHARED']
 
-    destfile = os.path.join(os.path.dirname(__file__), '_sysconfigdata.py')
+    pybuilddir = 'build/lib.%s-%s' % (get_platform(), sys.version[:3])
+    if hasattr(sys, "gettotalrefcount"):
+        pybuilddir += '-pydebug'
+    os.makedirs(pybuilddir, exist_ok=True)
+    destfile = os.path.join(pybuilddir, '_sysconfigdata.py')
+
     with open(destfile, 'w', encoding='utf8') as f:
         f.write('# system configuration generated and used by'
                 ' the sysconfig module\n')
         f.write('build_time_vars = ')
         pprint.pprint(vars, stream=f)
 
+    # Create file used for sys.path fixup -- see Modules/getpath.c
+    with open('pybuilddir.txt', 'w', encoding='ascii') as f:
+        f.write(pybuilddir)
+
 def _init_posix(vars):
     """Initialize the module as appropriate for POSIX systems."""
     # _sysconfigdata is generated at build time, see _generate_posix_vars()
Index: Python-3.3.0/Makefile.pre.in
===================================================================
--- Python-3.3.0.orig/Makefile.pre.in
+++ Python-3.3.0/Makefile.pre.in
@@ -410,8 +410,6 @@
 		Objects/unicodectype.o \
 		Objects/weakrefobject.o
 
-SYSCONFIGDATA=$(srcdir)/Lib/_sysconfigdata.py
-
 ##########################################################################
 # objects that get linked into the Python library
 LIBRARY_OBJS_OMIT_FROZEN=	\
@@ -432,7 +430,7 @@
 
 # Default target
 all:		build_all
-build_all:	$(BUILDPYTHON) $(SYSCONFIGDATA) oldsharedmods sharedmods gdbhooks Modules/_testembed
+build_all:	$(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Modules/_testembed
 
 # Compile a binary with gcc profile guided optimization.
 profile-opt:
@@ -466,15 +464,17 @@
 $(BUILDPYTHON):	Modules/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY)
 	$(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ Modules/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
 
-platform: $(BUILDPYTHON) $(SYSCONFIGDATA)
+platform: $(BUILDPYTHON)
 	$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform
 
-# Generate the sysconfig build-time data
-$(SYSCONFIGDATA): $(BUILDPYTHON)
+# Create build directory and generate the sysconfig build-time data there.
+# pybuilddir.txt contains the name of the build dir and is used for
+# sys.path fixup -- see Modules/getpath.c.
+pybuilddir.txt: $(BUILDPYTHON)
 	$(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars
 
 # Build the shared modules
-sharedmods: $(BUILDPYTHON) $(SYSCONFIGDATA)
+sharedmods: $(BUILDPYTHON) pybuilddir.txt
 	case $$MAKEFLAGS in *s*) quiet=-q; esac; \
 	$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
 		$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
@@ -1036,7 +1036,7 @@
 		else	true; \
 		fi; \
 	done
-	@for i in $(srcdir)/Lib/*.py ; \
+	@for i in $(srcdir)/Lib/*.py `cat pybuilddir.txt`/_sysconfigdata.py; \
 	do \
 		if test -x $$i; then \
 			$(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
@@ -1196,6 +1196,8 @@
 		--install-scripts=$(BINDIR) \
 		--install-platlib=$(DESTSHARED) \
 		--root=$(DESTDIR)/
+	-rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata.py
+	-rm -r $(DESTDIR)$(DESTSHARED)/__pycache__
 
 # Here are a couple of targets for MacOSX again, to install a full
 # framework-based Python. frameworkinstall installs everything, the
@@ -1341,9 +1343,10 @@
 	find . -name '*.s[ol]' -exec rm -f {} ';'
 	find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
 	find build -name 'fficonfig.h' -exec rm -f {} ';' || true
-	find build -name 'fficonfig.py' -exec rm -f {} ';' || true
+	find build -name '*.py' -exec rm -f {} ';' || true
+	find build -name '*.py[co]' -exec rm -f {} ';' || true
+	-rm -f pybuilddir.txt
 	-rm -f Lib/lib2to3/*Grammar*.pickle
-	-rm -f $(SYSCONFIGDATA)
 	-rm -f Modules/_testembed Modules/_freeze_importlib
 
 profile-removal:
@@ -1367,7 +1370,6 @@
 		Modules/Setup Modules/Setup.local Modules/Setup.config \
 		Modules/ld_so_aix Modules/python.exp Misc/python.pc
 	-rm -f python*-gdb.py
-	-rm -f pybuilddir.txt
 	find $(srcdir) '(' -name '*.fdc' -o -name '*~' \
 			   -o -name '[@,#]*' -o -name '*.old' \
 			   -o -name '*.orig' -o -name '*.rej' \
Index: Python-3.3.0/setup.py
===================================================================
--- Python-3.3.0.orig/setup.py
+++ Python-3.3.0/setup.py
@@ -33,10 +33,6 @@
 # This global variable is used to hold the list of modules to be disabled.
 disabled_module_list = []
 
-# File which contains the directory for shared mods (for sys.path fixup
-# when running from the build dir, see Modules/getpath.c)
-_BUILDDIR_COOKIE = "pybuilddir.txt"
-
 def add_dir_to_list(dirlist, dir):
     """Add the directory 'dir' to the list 'dirlist' (after any relative
     directories) if:
@@ -252,16 +248,6 @@
             args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags
         self.compiler.set_executables(**args)
 
-        # Not only do we write the builddir cookie, but we manually install
-        # the shared modules directory if it isn't already in sys.path.
-        # Otherwise trying to import the extensions after building them
-        # will fail.
-        with open(_BUILDDIR_COOKIE, "wb") as f:
-            f.write(self.build_lib.encode('utf-8', 'surrogateescape'))
-        abs_build_lib = os.path.join(os.getcwd(), self.build_lib)
-        if abs_build_lib not in sys.path:
-            sys.path.append(abs_build_lib)
-
         build_ext.build_extensions(self)
 
         longest = max([len(e.name) for e in self.extensions])
+36 −0
Original line number Diff line number Diff line
setup.py: do not add invalid header locations

This piece of code incorrectly adds /usr/include to
self.compiler.include_dirs, and results in the following invalid
compilation line:

/home/thomas/projets/buildroot/output/host/usr/bin/arm-none-linux-gnueabi-gcc
  -fPIC -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g
  -O3 -Wall -Wstrict-prototypes -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  -D_FILE_OFFSET_BITS=64 -pipe -Os
  -I./Include -I/usr/include -I. -IInclude
  -I/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/include
  -I/home/thomas/projets/buildroot/output/build/python3-3.4.0b1/Include
  -I/home/thomas/projets/buildroot/output/build/python3-3.4.0b1
  -c /home/thomas/projets/buildroot/output/build/python3-3.4.0b1/Modules/_struct.c
  -o build/temp.linux-arm-3.4/home/thomas/projets/buildroot/output/build/python3-3.4.0b1/Modules/_struct.o
cc1: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories]

The -I/usr/include is wrong when cross compiling, so we disable adding
INCLUDEDIR and LIBDIR from the host when cross compiling.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Index: b/setup.py
===================================================================
--- a/setup.py
+++ b/setup.py
@@ -487,7 +487,8 @@
                         add_dir_to_list(dir_list, directory)
 
         if os.path.normpath(sys.base_prefix) != '/usr' \
-                and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
+                and not sysconfig.get_config_var('PYTHONFRAMEWORK') \
+                and not cross_compiling:
             # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
             # (PYTHONFRAMEWORK is set) to avoid # linking problems when
             # building a framework with different architectures than
+0 −68
Original line number Diff line number Diff line
Add support in Python build system to specify host pgen

Python needs a "pgen" program to build itself. Unfortunately, the
Python build system assumes that it can use the pgen program it has
just built to build itself. Obviously, this cannot work in
cross-compilation mode since the pgen program have been built for the
target.

Therefore, this patch adds support in the Python build system for the
new PGEN_FOR_BUILD variable, so that we can point Python ./configure
script to the pgen program that have been previously built for the
host.

Patch ported to python2.7 by Maxime Ripard <ripard@archos.com>, and
later significantly reworked by Thomas Petazzoni
<thomas.petazzoni@free-electrons.com>, with some inspiration taken
from the Python patches of the PTXdist project, and then ported to
python3.3 by Maxime Ripard <maxime.ripard@free-electrons.com>

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 Makefile.pre.in |    5 +++--
 configure.ac    |    5 +++++
 2 files changed, 8 insertions(+), 2 deletions(-)

Index: Python-3.3.0/Makefile.pre.in
===================================================================
--- Python-3.3.0.orig/Makefile.pre.in
+++ Python-3.3.0/Makefile.pre.in
@@ -239,6 +239,7 @@
 ##########################################################################
 # Parser
 PGEN=		Parser/pgen$(EXE)
+PGEN_FOR_BUILD=@PGEN_FOR_BUILD@
 
 PSRCS=		\
 		Parser/acceler.c \
@@ -639,8 +640,8 @@
 
 $(GRAMMAR_H): $(GRAMMAR_INPUT) $(PGENSRCS)
 		@$(MKDIR_P) Include
-		$(MAKE) $(PGEN)
-		$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
+		$(MAKE) $(PGEN_FOR_BUILD)
+		$(PGEN_FOR_BUILD) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
 $(GRAMMAR_C): $(GRAMMAR_H) $(GRAMMAR_INPUT) $(PGENSRCS)
 		$(MAKE) $(GRAMMAR_H)
 		touch $(GRAMMAR_C)
Index: Python-3.3.0/configure.ac
===================================================================
--- Python-3.3.0.orig/configure.ac
+++ Python-3.3.0/configure.ac
@@ -51,10 +51,15 @@
         AC_MSG_RESULT($interp)
 	PYTHON_FOR_BUILD="_PYTHON_PROJECT_BASE=$srcdir"' _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp
     fi
+    AC_MSG_CHECKING(pgen for build)
+    PGEN_FOR_BUILD="${PGEN_FOR_BUILD}"
+    AC_MSG_RESULT($PGEN_FOR_BUILD)
 else
     PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
+    PGEN_FOR_BUILD='./$(PGEN)'
 fi
 AC_SUBST(PYTHON_FOR_BUILD)
+AC_SUBST(PGEN_FOR_BUILD)
 
 dnl Ensure that if prefix is specified, it does not end in a slash. If
 dnl it does, we get path names containing '//' which is both ugly and
+0 −72
Original line number Diff line number Diff line
Do not look at host headers/libraries in cross-compile mode

When we are cross-compiling, setup.py should never look in /usr or
/usr/local to find headers or libraries. A later patch adds a
mechanism to tell setup.py to look in a specific directory for headers
and libraries.

Patch first written by Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> for python2.7, and then ported
to python3.3 by Maxime Ripard <maxime.ripard@free-electrons.com>

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 setup.py |   23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

Index: Python-3.3.0/setup.py
===================================================================
--- Python-3.3.0.orig/setup.py
+++ Python-3.3.0/setup.py
@@ -447,10 +447,8 @@
         if not cross_compiling:
             add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
             add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
-        # only change this for cross builds for 3.3, issues on Mageia
-        if cross_compiling:
             self.add_gcc_paths()
-        self.add_multiarch_paths()
+            self.add_multiarch_paths()
 
         # Add paths specified in the environment variables LDFLAGS and
         # CPPFLAGS for header and library files.
@@ -458,10 +456,7 @@
         # directly since an inconsistently reproducible issue comes up where
         # the environment variable is not set even though the value were passed
         # into configure and stored in the Makefile (issue found on OS X 10.3).
-        for env_var, arg_name, dir_list in (
-                ('LDFLAGS', '-R', self.compiler.runtime_library_dirs),
-                ('LDFLAGS', '-L', self.compiler.library_dirs),
-                ('CPPFLAGS', '-I', self.compiler.include_dirs)):
+        for env_var, arg_name, dir_list in ():
             env_val = sysconfig.get_config_var(env_var)
             if env_val:
                 # To prevent optparse from raising an exception about any
@@ -486,17 +481,6 @@
                     for directory in reversed(options.dirs):
                         add_dir_to_list(dir_list, directory)
 
-        if os.path.normpath(sys.base_prefix) != '/usr' \
-                and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
-            # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
-            # (PYTHONFRAMEWORK is set) to avoid # linking problems when
-            # building a framework with different architectures than
-            # the one that is currently installed (issue #7473)
-            add_dir_to_list(self.compiler.library_dirs,
-                            sysconfig.get_config_var("LIBDIR"))
-            add_dir_to_list(self.compiler.include_dirs,
-                            sysconfig.get_config_var("INCLUDEDIR"))
-
         # lib_dirs and inc_dirs are used to search for files;
         # if a file is found in one of those directories, it can
         # be assumed that no additional -I,-L directives are needed.
@@ -506,6 +490,9 @@
                 '/lib', '/usr/lib',
                 ]
             inc_dirs = self.compiler.include_dirs + ['/usr/include']
+        else:
+            lib_dirs = self.compiler.library_dirs
+            inc_dirs = self.compiler.include_dirs
         exts = []
         missing = []
 
+23 −0
Original line number Diff line number Diff line
distutils: fix build_ext check to find whether we're building Python or not

The build_ext logic uses
sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")) to
determine whether we're building a third-party Python extension, or a
built-in Python extension. However, this check is wrong in
cross-compilation mode, and instead, the sysconfig.python_build
variable should be used.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Index: b/Lib/distutils/command/build_ext.py
===================================================================
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -246,7 +246,7 @@
         # Python's library directory must be appended to library_dirs
         # See Issues: #1600860, #4366
         if (sysconfig.get_config_var('Py_ENABLE_SHARED')):
-            if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
+            if not sysconfig.python_build:
                 # building third party extensions
                 self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
             else:
Loading