Skip to contentSkip to conversation

Add python3 support

PATCH New Maxime Ripard 2 participants 5 messages Nov 7, 2012

lore
Share & tools
lore
#0 lore raw

cover Add python3 support

Hi everyone,

After some hard work during the Buildroot dev days, here is the first attempt at adding the python3 package to buildroot.

The patchset is actually smaller than for python2.7, even though we still carry most of the patches, for several reasons:
- you can now pass a path to an external python interpreter directly using the PYTHON_FOR_BUILD variable
- The building of the modules will detect if the headers and libs for a given library are present so that it will build even if the libraries are missing

Maxime

Maxime Ripard (2):
Give the path to the realdelf binary the the packages Add python3 package

 package/Config.in                                  |    1 +
 package/Makefile.in                                |    2 +
 package/python3/Config.in                          |   81 ++++++++++
 ...n3-3.3-000-generate-sysconfigdata-buildir.patch |  158 ++++++++++++++++++++
 .../python3-3.3-001-support-for-build.patch        |   68 +++++++++
 .../python3-3.3-002-no-host-headers-libs.patch     |   72 +++++++++
 .../python3-3.3-003-staging-header-libs.patch      |   41 +++++
 ...n3-3.3-004-no-import-when-cross-compiling.patch |   27 ++++
 ...python3-3.3-005-do-not-generate-pyo-files.patch |   40 +++++
 .../python3-3.3-006-reread-environment.patch       |   63 ++++++++
 ...ython3-3.3-007-change-pyconfig-h-location.patch |   76 ++++++++++
 package/python3/python3-3.3-008-no-rpath.patch     |   51 +++++++
 .../python3-3.3-009-verbose-module-build.patch     |   26 ++++
 ...3-010-distutils-cross-compilation-support.patch |   71 +++++++++
 ...python3-3.3-011-cross-compile-getaddrinfo.patch |   21 +++
 package/python3/python3.mk                         |  152 +++++++++++++++++++
 16 files changed, 950 insertions(+)
 create mode 100644 package/python3/Config.in
 create mode 100644 package/python3/python3-3.3-000-generate-sysconfigdata-buildir.patch
 create mode 100644 package/python3/python3-3.3-001-support-for-build.patch
 create mode 100644 package/python3/python3-3.3-002-no-host-headers-libs.patch
 create mode 100644 package/python3/python3-3.3-003-staging-header-libs.patch
 create mode 100644 package/python3/python3-3.3-004-no-import-when-cross-compiling.patch
 create mode 100644 package/python3/python3-3.3-005-do-not-generate-pyo-files.patch
 create mode 100644 package/python3/python3-3.3-006-reread-environment.patch
 create mode 100644 package/python3/python3-3.3-007-change-pyconfig-h-location.patch
 create mode 100644 package/python3/python3-3.3-008-no-rpath.patch
 create mode 100644 package/python3/python3-3.3-009-verbose-module-build.patch
 create mode 100644 package/python3/python3-3.3-010-distutils-cross-compilation-support.patch
 create mode 100644 package/python3/python3-3.3-011-cross-compile-getaddrinfo.patch
 create mode 100644 package/python3/python3.mk
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/2 Give the path to the realdelf binary the the packages

---
 package/Makefile.in |    2 ++
 1 file changed, 2 insertions(+)
package/Makefile.in +2 -0
index a939882..9fdc745 100644
@@ -113,6 +113,7 @@ TARGET_FC       = $(TARGET_CROSS)gfortran
 TARGET_LD       = $(TARGET_CROSS)ld
 TARGET_NM       = $(TARGET_CROSS)nm
 TARGET_RANLIB   = $(TARGET_CROSS)ranlib
+TARGET_READELF  = $(TARGET_CROSS)readelf
 TARGET_OBJCOPY  = $(TARGET_CROSS)objcopy
 TARGET_OBJDUMP  = $(TARGET_CROSS)objdump
 
@@ -170,6 +171,7 @@ TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \
 		CXX="$(TARGET_CXX)" \
 		FC="$(TARGET_FC)" \
 		RANLIB="$(TARGET_RANLIB)" \
+		READELF="$(TARGET_READELF)" \
 		STRIP="$(TARGET_STRIP)" \
 		OBJCOPY="$(TARGET_OBJCOPY)" \
 		OBJDUMP="$(TARGET_OBJDUMP)" \
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 1/2 Give the path to the realdelf binary the the packages

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Maxime" == Maxime Ripard <[email protected]> writes:

Committed with the commit message reworded, thanks.

Maxime> Signed-off-by: Maxime Ripard <[email protected]>

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH 2/2 Add python3 package

In reply to Maxime Ripard
---
 package/Config.in                                  |    1 +
 package/python3/Config.in                          |   81 ++++++++++
 ...n3-3.3-000-generate-sysconfigdata-buildir.patch |  158 ++++++++++++++++++++
 .../python3-3.3-001-support-for-build.patch        |   68 +++++++++
 .../python3-3.3-002-no-host-headers-libs.patch     |   72 +++++++++
 .../python3-3.3-003-staging-header-libs.patch      |   41 +++++
 ...n3-3.3-004-no-import-when-cross-compiling.patch |   27 ++++
 ...python3-3.3-005-do-not-generate-pyo-files.patch |   40 +++++
 .../python3-3.3-006-reread-environment.patch       |   63 ++++++++
 ...ython3-3.3-007-change-pyconfig-h-location.patch |   76 ++++++++++
 package/python3/python3-3.3-008-no-rpath.patch     |   51 +++++++
 .../python3-3.3-009-verbose-module-build.patch     |   26 ++++
 ...3-010-distutils-cross-compilation-support.patch |   71 +++++++++
 ...python3-3.3-011-cross-compile-getaddrinfo.patch |   21 +++
 package/python3/python3.mk                         |  152 +++++++++++++++++++
 15 files changed, 948 insertions(+)
 create mode 100644 package/python3/Config.in
 create mode 100644 package/python3/python3-3.3-000-generate-sysconfigdata-buildir.patch
 create mode 100644 package/python3/python3-3.3-001-support-for-build.patch
 create mode 100644 package/python3/python3-3.3-002-no-host-headers-libs.patch
 create mode 100644 package/python3/python3-3.3-003-staging-header-libs.patch
 create mode 100644 package/python3/python3-3.3-004-no-import-when-cross-compiling.patch
 create mode 100644 package/python3/python3-3.3-005-do-not-generate-pyo-files.patch
 create mode 100644 package/python3/python3-3.3-006-reread-environment.patch
 create mode 100644 package/python3/python3-3.3-007-change-pyconfig-h-location.patch
 create mode 100644 package/python3/python3-3.3-008-no-rpath.patch
 create mode 100644 package/python3/python3-3.3-009-verbose-module-build.patch
 create mode 100644 package/python3/python3-3.3-010-distutils-cross-compilation-support.patch
 create mode 100644 package/python3/python3-3.3-011-cross-compile-getaddrinfo.patch
 create mode 100644 package/python3/python3.mk
package/Config.in +1 -0
index 6125abc..a9c1496 100644
@@ -289,6 +289,7 @@ endif
 source "package/microperl/Config.in"
 source "package/php/Config.in"
 source "package/python/Config.in"
+source "package/python3/Config.in"
 if BR2_PACKAGE_PYTHON
 menu "external python modules"
 source "package/python-dpkt/Config.in"
package/python3/Config.in new file +81 -0

81 lines not on this page · raw message

package/python3/python3-3.3-000-generate-sysconfigdata-buildir.patch new file +158 -0

158 lines not on this page · raw message

package/python3/python3-3.3-001-support-for-build.patch new file +68 -0

68 lines not on this page · raw message

package/python3/python3-3.3-002-no-host-headers-libs.patch new file +72 -0

72 lines not on this page · raw message

package/python3/python3-3.3-003-staging-header-libs.patch new file +41 -0

41 lines not on this page · raw message

package/python3/python3-3.3-004-no-import-when-cross-compiling.patch new file +27 -0
new file mode 100644
index 0000000..cd5a437
@@ -0,0 +1,27 @@
+Disable import check when cross-compiling
+
+Once Python has compiled an extension (i.e some C code, potentially
+linked to a library), it tries to import it. This cannot work in
+cross-compilation mode, so we just disable this check.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+Signed-off-by: Maxime Ripard <[email protected]>
+---
+ setup.py |    4 ++++
+ 1 file changed, 4 insertions(+)
+
+Index: Python-3.3.0/setup.py
+===================================================================
+--- Python-3.3.0.orig/setup.py
++++ Python-3.3.0/setup.py
+@@ -318,6 +318,10 @@
+             self.announce('WARNING: skipping import check for Cygwin-based "%s"'
+                 % ext.name)
+             return
++        if os.environ.get('CROSS_COMPILING') == 'yes':
++            self.announce('WARNING: skipping import check for cross compiled "%s"'
++                          % ext.name)
++            return
+         ext_filename = os.path.join(
+             self.build_lib,
+             self.get_ext_filename(self.get_ext_fullname(ext.name)))
package/python3/python3-3.3-005-do-not-generate-pyo-files.patch new file +40 -0
new file mode 100644
index 0000000..983d546
@@ -0,0 +1,40 @@
+Do not generate .pyo files
+
+By default, the Python installation byte-compiles all modules in two
+forms: the normal bytecode (.pyc) and an optimized bytecode (.pyo).
+
+According to
+http://www.network-theory.co.uk/docs/pytut/CompiledPythonfiles.html,
+the optimization do not do anything useful, and generating both the
+"non-optimized" and "optimized" bytecode variants takes time.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ Makefile.pre.in |    9 ---------
+ 1 file changed, 9 deletions(-)
+
+Index: Python-3.3.0/Makefile.pre.in
+===================================================================
+--- Python-3.3.0.orig/Makefile.pre.in
++++ Python-3.3.0/Makefile.pre.in
+@@ -1082,20 +1082,11 @@
+ 		-d $(LIBDEST) -f \
+ 		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
+ 		$(DESTDIR)$(LIBDEST)
+-	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+-		$(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
+-		-d $(LIBDEST) -f \
+-		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
+-		$(DESTDIR)$(LIBDEST)
+ 	-PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
+ 		$(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
+ 		-d $(LIBDEST)/site-packages -f \
+ 		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
+ 	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+-		$(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
+-		-d $(LIBDEST)/site-packages -f \
+-		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
+-	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ 		$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
+ 	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ 		$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
package/python3/python3-3.3-006-reread-environment.patch new file +63 -0

63 lines not on this page · raw message

package/python3/python3-3.3-007-change-pyconfig-h-location.patch new file +76 -0

76 lines not on this page · raw message

package/python3/python3-3.3-008-no-rpath.patch new file +51 -0

51 lines not on this page · raw message

package/python3/python3-3.3-009-verbose-module-build.patch new file +26 -0
new file mode 100644
index 0000000..60b6d79
@@ -0,0 +1,26 @@
+Enables verbose output when building modules
+
+Patch borrowed from OpenBricks.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+
+---
+ Makefile.pre.in |    3 +--
+ 1 file changed, 1 insertion(+), 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
+@@ -476,10 +476,9 @@
+ 
+ # Build the shared modules
+ sharedmods: $(BUILDPYTHON) pybuilddir.txt
+-	case $$MAKEFLAGS in *s*) quiet=-q; esac; \
+ 	$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
+ 		CONFIG_ARGS="$(CONFIG_ARGS)" \
+-		$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
++		$(PYTHON_FOR_BUILD) $(srcdir)/setup.py build
+ 
+ # Build static library
+ # avoid long command lines, same as LIBRARY_OBJS
package/python3/python3-3.3-010-distutils-cross-compilation-support.patch new file +71 -0

71 lines not on this page · raw message

package/python3/python3-3.3-011-cross-compile-getaddrinfo.patch new file +21 -0
new file mode 100644
index 0000000..33286ce
@@ -0,0 +1,21 @@
+Disable buggy_getaddrinfo configure test when cross-compiling with IPv6 support
+
+Signed-off-by: Vanya Sergeev <[email protected]>
+
+---
+ configure.ac |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: Python-3.3.0/configure.ac
+===================================================================
+--- Python-3.3.0.orig/configure.ac
++++ Python-3.3.0/configure.ac
+@@ -3204,7 +3204,7 @@
+ 
+ AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
+ 
+-if test $have_getaddrinfo = no || test "$ac_cv_buggy_getaddrinfo" = yes
++if test $have_getaddrinfo = no || test "$cross_compiling" != "yes" -a "$ac_cv_buggy_getaddrinfo" = yes
+ then
+ 	if test $ipv6 = yes
+ 	then
package/python3/python3.mk new file +152 -0

152 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 2/2 Add python3 package

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Maxime" == Maxime Ripard <[email protected]> writes:

Maxime> Signed-off-by: Maxime Ripard <[email protected]>

Maxime> +comment "python requires a toolchain with WCHAR support"

s/python/python3/

Maxime> +#
Maxime> +# Development files removal
Maxime> +#
Maxime> +define PYTHON3_REMOVE_DEVFILES
Maxime> + rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)-config
Maxime> + rm -f $(TARGET_DIR)/usr/bin/python-config

As far as I can see it doesn't install python-config.

Committed with these minor fixes, thanks!

Signature · 1 line
Bye, Peter Korsgaard