From a6179a798ae057123d69c37338066ea34d66536c Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Sun, 6 Mar 2016 15:43:27 +0100 Subject: [PATCH 01/10] Python: dont build and use Parser/pgen and simplifing crosscompile patch Signed-off-by: Stephan Raue --- packages/lang/Python/package.mk | 12 +++++++----- .../patches/Python-2.7.11-001_xcompile.patch | 17 ----------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/packages/lang/Python/package.mk b/packages/lang/Python/package.mk index 7f53b01789a..cb3a88c70e6 100644 --- a/packages/lang/Python/package.mk +++ b/packages/lang/Python/package.mk @@ -64,6 +64,13 @@ PKG_CONFIGURE_OPTS_TARGET="ac_cv_file_dev_ptc=no \ --without-cxx-main \ --with-system-ffi \ --with-system-expat" +post_patch() { + # This is needed to make sure the Python build process doesn't try to + # regenerate those files with the pgen program. Otherwise, it builds + # pgen for the target, and tries to run it on the host. + touch $PKG_BUILD/Include/graminit.h + touch $PKG_BUILD/Python/graminit.c +} make_host() { make PYTHON_MODULES_INCLUDE="$HOST_INCDIR" \ @@ -82,8 +89,6 @@ makeinstall_host() { PYTHON_DISABLE_MODULES="$PY_DISABLED_MODULES" \ install - cp Parser/pgen $ROOT/$TOOLCHAIN/bin - # replace python-config to make sure python uses $SYSROOT_PREFIX mkdir -p $ROOT/$TOOLCHAIN/bin rm -rf $ROOT/$TOOLCHAIN/bin/python*-config @@ -102,7 +107,6 @@ pre_configure_target() { make_target() { make -j1 CC="$TARGET_CC" \ - HOSTPGEN=$ROOT/$TOOLCHAIN/bin/pgen \ PYTHON_DISABLE_MODULES="$PY_DISABLED_MODULES" \ PYTHON_MODULES_INCLUDE="$TARGET_INCDIR" \ PYTHON_MODULES_LIB="$TARGET_LIBDIR" @@ -111,7 +115,6 @@ make_target() { makeinstall_target() { make -j1 CC="$TARGET_CC" \ DESTDIR=$SYSROOT_PREFIX \ - HOSTPGEN=$ROOT/$TOOLCHAIN/bin/pgen \ PYTHON_DISABLE_MODULES="$PY_DISABLED_MODULES" \ PYTHON_MODULES_INCLUDE="$TARGET_INCDIR" \ PYTHON_MODULES_LIB="$TARGET_LIBDIR" \ @@ -123,7 +126,6 @@ makeinstall_target() { make -j1 CC="$TARGET_CC" \ DESTDIR=$INSTALL \ - HOSTPGEN=$ROOT/$TOOLCHAIN/bin/pgen \ PYTHON_DISABLE_MODULES="$PY_DISABLED_MODULES" \ PYTHON_MODULES_INCLUDE="$TARGET_INCDIR" \ PYTHON_MODULES_LIB="$TARGET_LIBDIR" \ diff --git a/packages/lang/Python/patches/Python-2.7.11-001_xcompile.patch b/packages/lang/Python/patches/Python-2.7.11-001_xcompile.patch index 4b4db9350aa..188c6be6d07 100644 --- a/packages/lang/Python/patches/Python-2.7.11-001_xcompile.patch +++ b/packages/lang/Python/patches/Python-2.7.11-001_xcompile.patch @@ -10,14 +10,6 @@ index bcd83bf..5e54a0d 100644 PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@ _PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@ -@@ -231,6 +232,7 @@ LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@ - ########################################################################## - # Parser - PGEN= Parser/pgen$(EXE) -+HOSTPGEN= $(PGEN) - - PSRCS= \ - Parser/acceler.c \ @@ -461,6 +463,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt esac; \ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ @@ -26,15 +18,6 @@ index bcd83bf..5e54a0d 100644 $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build # Build static library -@@ -598,7 +601,7 @@ Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c $(srcdir)/Modules/posixmodule - $(GRAMMAR_H): $(GRAMMAR_INPUT) $(PGENSRCS) - @$(MKDIR_P) Include - $(MAKE) $(PGEN) -- $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) -+ $(HOSTPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) - $(GRAMMAR_C): $(GRAMMAR_H) $(GRAMMAR_INPUT) $(PGENSRCS) - $(MAKE) $(GRAMMAR_H) - touch $(GRAMMAR_C) @@ -1142,7 +1145,9 @@ libainstall: all python-config # Install the dynamically loadable modules # This goes into $(exec_prefix) From 2c7678c41e8d67edbba1130eacf08858ae4ec25e Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Mon, 7 Mar 2016 15:44:09 +0100 Subject: [PATCH 02/10] Python: add crosscompiling patch from buildroot, dont globally change _sysconfigdata.py, enable autoreconf Signed-off-by: Stephan Raue --- config/functions | 5 ++ packages/lang/Python/package.mk | 12 ++--- ....11-008-distutils-use-python-sysroot.patch | 54 +++++++++++++++++++ 3 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 packages/lang/Python/patches/Python-2.7.11-008-distutils-use-python-sysroot.patch diff --git a/config/functions b/config/functions index fd37397c443..3449d585909 100644 --- a/config/functions +++ b/config/functions @@ -22,6 +22,11 @@ setup_toolchain() { export PKG_CONFIG_LIBDIR="$TARGET_PKG_CONFIG_LIBDIR" export PKG_CONFIG_SYSROOT_DIR="$TARGET_PKG_CONFIG_SYSROOT_DIR" + # set python defaults + export _python_sysroot="$SYSROOT_PREFIX" + export _python_prefix=/usr + export _python_exec_prefix=/usr + # set CMAKE configfile for target export CMAKE_CONF=$ROOT/$TOOLCHAIN/etc/cmake-$TARGET_NAME.conf diff --git a/packages/lang/Python/package.mk b/packages/lang/Python/package.mk index cb3a88c70e6..c8655f105a2 100644 --- a/packages/lang/Python/package.mk +++ b/packages/lang/Python/package.mk @@ -31,7 +31,7 @@ PKG_SHORTDESC="python: The Python programming language" PKG_LONGDESC="Python is an interpreted object-oriented programming language, and is often compared with Tcl, Perl, Java or Scheme." PKG_IS_ADDON="no" -PKG_AUTORECONF="no" +PKG_AUTORECONF="yes" PY_DISABLED_MODULES="readline _curses _curses_panel _tkinter nis gdbm bsddb ossaudiodev" @@ -77,10 +77,8 @@ make_host() { PYTHON_MODULES_LIB="$HOST_LIBDIR" \ PYTHON_DISABLE_MODULES="$PY_DISABLED_MODULES" - sed -e "s|$ROOT/$TOOLCHAIN/include|$SYSROOT_PREFIX/usr/include|g" \ - -e "s|$ROOT/$TOOLCHAIN/lib|$SYSROOT_PREFIX/usr/lib|g" \ - -e "s|$ROOT/$TOOLCHAIN/bin/host-gcc|${TARGET_PREFIX}gcc|g" \ - -i build/lib.linux-$(uname -m)-2.7/_sysconfigdata.py + # python distutils per default adds -L$LIBDIR when linking binary extensions + sed -e "s|^ 'LIBDIR':.*| 'LIBDIR': '/usr/lib',|g" -i $(cat pybuilddir.txt)/_sysconfigdata.py } makeinstall_host() { @@ -120,10 +118,6 @@ makeinstall_target() { PYTHON_MODULES_LIB="$TARGET_LIBDIR" \ install - # python distutils per default adds -L$LIBDIR when linking binary extensions - sed -e "s|^LIBDIR=.*|LIBDIR= $SYSROOT_PREFIX/usr/lib|" \ - -i $SYSROOT_PREFIX/usr/lib/python*/config/Makefile - make -j1 CC="$TARGET_CC" \ DESTDIR=$INSTALL \ PYTHON_DISABLE_MODULES="$PY_DISABLED_MODULES" \ diff --git a/packages/lang/Python/patches/Python-2.7.11-008-distutils-use-python-sysroot.patch b/packages/lang/Python/patches/Python-2.7.11-008-distutils-use-python-sysroot.patch new file mode 100644 index 00000000000..7cd748761a5 --- /dev/null +++ b/packages/lang/Python/patches/Python-2.7.11-008-distutils-use-python-sysroot.patch @@ -0,0 +1,54 @@ +Adjust library/header paths for cross-compilation + +When cross-compiling third-party extensions, the get_python_inc() or +get_python_lib() can be called, to return the path to headers or +libraries. However, they use the sys.prefix of the host Python, which +returns incorrect paths when cross-compiling (paths pointing to host +headers and libraries). + +In order to fix this, we introduce the _python_sysroot, _python_prefix +and _python_exec_prefix variables, that allow to override these +values, and get correct header/library paths when cross-compiling +third-party Python modules. + +The _python_sysroot variable is also used to prefix the LIBDIR value +taken from the sysconfigdata module. + +Signed-off-by: Thomas Petazzoni + +Index: b/Lib/distutils/sysconfig.py +=================================================================== +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -19,8 +19,13 @@ + from distutils.errors import DistutilsPlatformError + + # These are needed in a couple of spots, so just compute them once. +-PREFIX = os.path.normpath(sys.prefix) +-EXEC_PREFIX = os.path.normpath(sys.exec_prefix) ++if "_python_sysroot" in os.environ: ++ _sysroot=os.environ.get('_python_sysroot') ++ PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_prefix')) ++ EXEC_PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_exec_prefix')) ++else: ++ PREFIX = os.path.normpath(sys.prefix) ++ EXEC_PREFIX = os.path.normpath(sys.exec_prefix) + + # Path to the base directory of the project. On Windows the binary may + # live in project/PCBuild9. If we're dealing with an x64 Windows build, +Index: b/Lib/distutils/command/build_ext.py +=================================================================== +--- a/Lib/distutils/command/build_ext.py ++++ b/Lib/distutils/command/build_ext.py +@@ -237,7 +237,10 @@ + if (sysconfig.get_config_var('Py_ENABLE_SHARED')): + if not sysconfig.python_build: + # building third party extensions +- self.library_dirs.append(sysconfig.get_config_var('LIBDIR')) ++ libdir = sysconfig.get_config_var('LIBDIR') ++ if "_python_sysroot" in os.environ: ++ libdir = os.environ.get("_python_sysroot") + libdir ++ self.library_dirs.append(libdir) + else: + # building python standard extensions + self.library_dirs.append('.') From ebb3882752f5d02aa5cf4ea98f638fd9409b53f4 Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Mon, 7 Mar 2016 15:53:29 +0100 Subject: [PATCH 03/10] Python: add patch to abort if module fails to build Signed-off-by: Stephan Raue --- packages/lang/Python/package.mk | 7 ------- ...n-2.7.11-014-abort-on-failed-modules.patch | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 packages/lang/Python/patches/Python-2.7.11-014-abort-on-failed-modules.patch diff --git a/packages/lang/Python/package.mk b/packages/lang/Python/package.mk index c8655f105a2..01fad2912cd 100644 --- a/packages/lang/Python/package.mk +++ b/packages/lang/Python/package.mk @@ -135,13 +135,6 @@ post_makeinstall_target() { python -Wi -t -B ../Lib/compileall.py $INSTALL/usr/lib/python*/ -f rm -rf `find $INSTALL/usr/lib/python*/ -name "*.py"` - if [ ! -f $INSTALL/usr/lib/python*/lib-dynload/_socket.so ]; then - echo "sometimes Python dont build '_socket.so' for some reasons and continues without failing," - echo "let it fail here, to be sure '_socket.so' will be installed. A rebuild of Python fixes" - echo "the issue in most cases" - exit 1 - fi - rm -rf $INSTALL/usr/lib/python*/config rm -rf $INSTALL/usr/bin/2to3 rm -rf $INSTALL/usr/bin/idle diff --git a/packages/lang/Python/patches/Python-2.7.11-014-abort-on-failed-modules.patch b/packages/lang/Python/patches/Python-2.7.11-014-abort-on-failed-modules.patch new file mode 100644 index 00000000000..4bceeb62d7a --- /dev/null +++ b/packages/lang/Python/patches/Python-2.7.11-014-abort-on-failed-modules.patch @@ -0,0 +1,21 @@ +Abort on failed module build + +When building a Python module fails, the setup.py script currently +doesn't exit with an error, and simply continues. This is not a really +nice behavior, so this patch changes setup.py to abort with an error, +so that the build issue is clearly noticeable. + +Signed-off-by: Thomas Petazzoni + +Index: b/setup.py +=================================================================== +--- a/setup.py ++++ b/setup.py +@@ -283,6 +283,7 @@ + print "Failed to build these modules:" + print_three_column(failed) + print ++ sys.exit(1) + + def build_extension(self, ext): + From 9ac2b29412d3ffd63f2ee2a43bb25b3038a753bf Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Thu, 10 Mar 2016 07:43:16 +0100 Subject: [PATCH 04/10] Python: simplyfing crosscompile patch, remove unneeded hunk Signed-off-by: Stephan Raue --- .../lang/Python/patches/Python-2.7.11-001_xcompile.patch | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/lang/Python/patches/Python-2.7.11-001_xcompile.patch b/packages/lang/Python/patches/Python-2.7.11-001_xcompile.patch index 188c6be6d07..ef128ab4c07 100644 --- a/packages/lang/Python/patches/Python-2.7.11-001_xcompile.patch +++ b/packages/lang/Python/patches/Python-2.7.11-001_xcompile.patch @@ -2,14 +2,6 @@ diff --git a/Makefile.pre.in b/Makefile.pre.in index bcd83bf..5e54a0d 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in -@@ -191,6 +191,7 @@ UNICODE_OBJS= @UNICODE_OBJS@ - - PYTHON= python$(EXE) - BUILDPYTHON= python$(BUILDEXE) -+HOSTPYTHON= ./$(BUILDPYTHON) - - PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@ - _PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@ @@ -461,6 +463,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt esac; \ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ From 2c85f4739a318dd7b6ed0ac8112fbe91c7534a68 Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Thu, 10 Mar 2016 07:49:56 +0100 Subject: [PATCH 05/10] Python: while building modules we need to link against python.so from builddir. forcing this to prevent build and linking issues with adding -L. to LDFLAGS Signed-off-by: Stephan Raue --- packages/lang/Python/package.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lang/Python/package.mk b/packages/lang/Python/package.mk index 01fad2912cd..5d892d77ae6 100644 --- a/packages/lang/Python/package.mk +++ b/packages/lang/Python/package.mk @@ -104,7 +104,7 @@ pre_configure_target() { } make_target() { - make -j1 CC="$TARGET_CC" \ + make -j1 CC="$TARGET_CC" LDFLAGS="$TARGET_LDFLAGS -L." \ PYTHON_DISABLE_MODULES="$PY_DISABLED_MODULES" \ PYTHON_MODULES_INCLUDE="$TARGET_INCDIR" \ PYTHON_MODULES_LIB="$TARGET_LIBDIR" From 0e25df0a536db3e347d794961d2bc0b85c782c3d Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Thu, 10 Mar 2016 07:50:29 +0100 Subject: [PATCH 06/10] Python: cleanup unneded options Signed-off-by: Stephan Raue --- packages/lang/Python/package.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/lang/Python/package.mk b/packages/lang/Python/package.mk index 5d892d77ae6..6079488f001 100644 --- a/packages/lang/Python/package.mk +++ b/packages/lang/Python/package.mk @@ -99,8 +99,6 @@ makeinstall_host() { pre_configure_target() { export PYTHON_FOR_BUILD=$ROOT/$TOOLCHAIN/bin/python - export BLDSHARED="$CC -shared" - export RUNSHARED="LD_LIBRARY_PATH=$ROOT/$TOOLCHAIN/lib:$LD_LIBRARY_PATH" } make_target() { From dbc2e92769ab0492fa7ffacb5ef196bd8558234f Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Thu, 10 Mar 2016 08:27:04 +0100 Subject: [PATCH 07/10] Python: add upstream patch to install proper python-config Signed-off-by: Stephan Raue --- packages/lang/Python/package.mk | 9 - .../Python-2.7.11-010-fix-python-config.patch | 208 ++++++++++++++++++ packages/lang/Python/scripts/python-config | 31 --- 3 files changed, 208 insertions(+), 40 deletions(-) create mode 100644 packages/lang/Python/patches/Python-2.7.11-010-fix-python-config.patch delete mode 100755 packages/lang/Python/scripts/python-config diff --git a/packages/lang/Python/package.mk b/packages/lang/Python/package.mk index 6079488f001..55f1d1cb500 100644 --- a/packages/lang/Python/package.mk +++ b/packages/lang/Python/package.mk @@ -86,15 +86,6 @@ makeinstall_host() { PYTHON_MODULES_LIB="$HOST_LIBDIR" \ PYTHON_DISABLE_MODULES="$PY_DISABLED_MODULES" \ install - -# replace python-config to make sure python uses $SYSROOT_PREFIX - mkdir -p $ROOT/$TOOLCHAIN/bin - rm -rf $ROOT/$TOOLCHAIN/bin/python*-config - - sed -e "s:%PREFIX%:$SYSROOT_PREFIX/usr:g" -e "s:%CFLAGS%:$TARGET_CFLAGS:g" \ - $PKG_DIR/scripts/python-config > $ROOT/$TOOLCHAIN/bin/python2.7-config - chmod +x $ROOT/$TOOLCHAIN/bin/python2.7-config - ln -s python2.7-config $ROOT/$TOOLCHAIN/bin/python-config } pre_configure_target() { diff --git a/packages/lang/Python/patches/Python-2.7.11-010-fix-python-config.patch b/packages/lang/Python/patches/Python-2.7.11-010-fix-python-config.patch new file mode 100644 index 00000000000..1266f3d3af0 --- /dev/null +++ b/packages/lang/Python/patches/Python-2.7.11-010-fix-python-config.patch @@ -0,0 +1,208 @@ +Add a backport of http://bugs.python.org/issue16235 so we can use +python-config for cross builds. +This basically replaces the python version of python-config with a pure-shell +version that's already preprocessed when installed and doesn't depend +on the sysconfig import that usually leads to bad data/results. + +Signed-off-by: Gustavo Zacarias + +Index: b/configure.ac +=================================================================== +--- a/configure.ac ++++ b/configure.ac +@@ -885,6 +885,7 @@ + + # Other platforms follow + if test $enable_shared = "yes"; then ++ PY_ENABLE_SHARED=1 + AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.]) + case $ac_sys_system in + BeOS*) +@@ -945,6 +946,7 @@ + + esac + else # shared is disabled ++ PY_ENABLE_SHARED=0 + case $ac_sys_system in + CYGWIN*) + BLDLIBRARY='$(LIBRARY)' +@@ -1921,6 +1923,9 @@ + AC_SUBST(BLDSHARED) + AC_SUBST(CCSHARED) + AC_SUBST(LINKFORSHARED) ++AC_SUBST(PY_ENABLE_SHARED) ++LIBPL="${prefix}/lib/python${VERSION}/config" ++AC_SUBST(LIBPL) + # SO is the extension of shared libraries `(including the dot!) + # -- usually .so, .sl on HP-UX, .dll on Cygwin + AC_MSG_CHECKING(SO) +@@ -4588,7 +4593,7 @@ + AC_SUBST(ENSUREPIP) + + # generate output files +-AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) ++AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh) + AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) + AC_OUTPUT + +Index: b/Makefile.pre.in +=================================================================== +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -166,7 +166,7 @@ + SUBDIRSTOO= Include Lib Misc Demo + + # Files and directories to be distributed +-CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in ++CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in Misc/python-config.sh + DISTFILES= README ChangeLog $(CONFIGFILES) + DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy + DIST= $(DISTFILES) $(DISTDIRS) +@@ -410,7 +410,7 @@ + + # Default target + all: build_all +-build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks ++build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks python-config + + # Compile a binary with gcc profile guided optimization. + profile-opt: +@@ -1101,10 +1101,12 @@ + fi; \ + cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen + +-python-config: $(srcdir)/Misc/python-config.in ++python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh + # Substitution happens here, as the completely-expanded BINDIR + # is not available in configure +- sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config ++ sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py ++ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR} ++ sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' Misc/python-config.sh >python-config + + # Install the include files + INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY) +@@ -1163,7 +1165,7 @@ + $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup + $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh + $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config +- rm python-config ++ $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py + @if [ -s Modules/python.exp -a \ + "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \ + echo; echo "Installing support files for building shared extension modules on AIX:"; \ +@@ -1345,6 +1347,7 @@ + config.cache config.log pyconfig.h Modules/config.c + -rm -rf build platform + -rm -rf $(PYTHONFRAMEWORKDIR) ++ -rm -f python-config.py python-config + + # Make things extra clean, before making a distribution: + # remove all generated files, even Makefile[.pre] +Index: b/Misc/python-config.sh.in +=================================================================== +--- /dev/null ++++ b/Misc/python-config.sh.in +@@ -0,0 +1,102 @@ ++#!/bin/sh ++ ++exit_with_usage () ++{ ++ echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--configdir" ++ exit $1 ++} ++ ++if [ "$1" = "" ] ; then ++ exit_with_usage 1 ++fi ++ ++# Returns the actual prefix where this script was installed to. ++installed_prefix () ++{ ++ RESULT=$(dirname $(cd $(dirname "$1") && pwd -P)) ++ if which readlink >/dev/null 2>&1 ; then ++ RESULT=$(readlink -f "$RESULT") ++ fi ++ echo $RESULT ++} ++ ++prefix_build="@prefix@" ++prefix_real=$(installed_prefix "$0") ++ ++# Use sed to fix paths from their built to locations to their installed to locations. ++prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#") ++exec_prefix_build="@exec_prefix@" ++exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#") ++includedir=$(echo "@includedir@") ++libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#") ++CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#") ++VERSION="@VERSION@" ++LIBM="@LIBM@" ++LIBC="@LIBC@" ++SYSLIBS="$LIBM $LIBC" ++LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}" ++BASECFLAGS="@BASECFLAGS@" ++LDLIBRARY="@LDLIBRARY@" ++LINKFORSHARED="@LINKFORSHARED@" ++OPT="@OPT@" ++PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" ++LDVERSION="@LDVERSION@" ++LIBDEST=${prefix}/lib/python${VERSION} ++LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#") ++SO="@SO@" ++PYTHONFRAMEWORK="@PYTHONFRAMEWORK@" ++INCDIR="-I$includedir/python${VERSION}" ++PLATINCDIR="-I$includedir/python${VERSION}" ++ ++# Scan for --help or unknown argument. ++for ARG in $* ++do ++ case $ARG in ++ --help) ++ exit_with_usage 0 ++ ;; ++ --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir) ++ ;; ++ *) ++ exit_with_usage 1 ++ ;; ++esac ++done ++ ++for ARG in "$@" ++do ++ case "$ARG" in ++ --prefix) ++ echo "$prefix" ++ ;; ++ --exec-prefix) ++ echo "$exec_prefix" ++ ;; ++ --includes) ++ echo "$INCDIR $PLATINCDIR" ++ ;; ++ --cflags) ++ echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" ++ ;; ++ --libs) ++ echo "$LIBS" ++ ;; ++ --ldflags) ++ LINKFORSHAREDUSED= ++ if [ -z "$PYTHONFRAMEWORK" ] ; then ++ LINKFORSHAREDUSED=$LINKFORSHARED ++ fi ++ LIBPLUSED= ++ if [ "$PY_ENABLE_SHARED" = "0" ] ; then ++ LIBPLUSED="-L$LIBPL" ++ fi ++ echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED" ++ ;; ++ --extension-suffix) ++ echo "$SO" ++ ;; ++ --configdir) ++ echo "$LIBPL" ++ ;; ++esac ++done diff --git a/packages/lang/Python/scripts/python-config b/packages/lang/Python/scripts/python-config deleted file mode 100755 index 84b6e9c5199..00000000000 --- a/packages/lang/Python/scripts/python-config +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -################################################################################ -# This file is part of OpenELEC - http://www.openelec.tv -# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv) -# -# OpenELEC is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# OpenELEC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenELEC. If not, see . -################################################################################ - - -case $1 in - --prefix) echo "/usr" ;; - --exec-prefix) echo "/usr" ;; - --includes) echo "-I%PREFIX%/include/python2.7" ;; - --libs) echo "-lpthread -ldl -lutil -lm -lpython2.7" ;; - --cflags) echo "-I%PREFIX%/include/python2.7 -DNDEBUG %CFLAGS%" ;; - --ldflags) echo "-lpthread -ldl -lutil -lm -lpython2.7" ;; -esac - -exit 0 From 1106d29c5ed202edcf4999d57bbeb3ac9d629f5c Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Thu, 10 Mar 2016 12:33:46 +0100 Subject: [PATCH 08/10] pygobject: add patch to setup proper python includes Signed-off-by: Stephan Raue --- packages/python/devel/pygobject/package.mk | 6 +++- ...ct-0001-add-PYTHON_INCLUDES-override.patch | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 packages/python/devel/pygobject/patches/pygobject-0001-add-PYTHON_INCLUDES-override.patch diff --git a/packages/python/devel/pygobject/package.mk b/packages/python/devel/pygobject/package.mk index 1ba6c259659..0a00aa802d9 100644 --- a/packages/python/devel/pygobject/package.mk +++ b/packages/python/devel/pygobject/package.mk @@ -34,10 +34,14 @@ PKG_AUTORECONF="yes" PKG_CONFIGURE_OPTS_TARGET="--enable-thread --disable-introspection" +pre_configure_target() { + export PYTHON_INCLUDES="$($SYSROOT_PREFIX/usr/bin/python2-config --includes)" +} + post_makeinstall_target() { find $INSTALL/usr/lib -name "*.py" -exec rm -rf "{}" ";" find $INSTALL/usr/lib -name "*.pyc" -exec rm -rf "{}" ";" rm -rf $INSTALL/usr/bin rm -rf $INSTALL/usr/share/pygobject -} \ No newline at end of file +} diff --git a/packages/python/devel/pygobject/patches/pygobject-0001-add-PYTHON_INCLUDES-override.patch b/packages/python/devel/pygobject/patches/pygobject-0001-add-PYTHON_INCLUDES-override.patch new file mode 100644 index 00000000000..d883f60ddf5 --- /dev/null +++ b/packages/python/devel/pygobject/patches/pygobject-0001-add-PYTHON_INCLUDES-override.patch @@ -0,0 +1,32 @@ +[PATCH] m4/python.m4: add PYTHON_INCLUDES override for cross compilation + +As the configure script mixes up host/target python. Equivalent to the +similar code in dbus-python. + +Signed-off-by: Peter Korsgaard +--- + m4/python.m4 | 4 ++++ + 1 file changed, 4 insertions(+) + +Index: python-gobject-2.28.6/m4/python.m4 +=================================================================== +--- python-gobject-2.28.6.orig/m4/python.m4 ++++ python-gobject-2.28.6/m4/python.m4 +@@ -43,6 +43,9 @@ + [AC_REQUIRE([AM_PATH_PYTHON]) + AC_MSG_CHECKING(for headers required to compile python extensions) + dnl deduce PYTHON_INCLUDES ++if test "${PYTHON_INCLUDES+set}" = set; then ++ AC_MSG_NOTICE([PYTHON_INCLUDES overridden to: $PYTHON_INCLUDES]) ++else + py_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"` + py_exec_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)"` + PYTHON_CONFIG=`which $PYTHON`-config +@@ -54,6 +57,7 @@ + PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" + fi + fi ++fi + AC_SUBST(PYTHON_INCLUDES) + dnl check if the headers exist: + save_CPPFLAGS="$CPPFLAGS" From 4abe4675147d4742b6063ccad3b4bf94dbbfcb9b Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Thu, 10 Mar 2016 12:41:59 +0100 Subject: [PATCH 09/10] dbus-python: setup proper python includes and libs Signed-off-by: Stephan Raue --- packages/python/system/dbus-python/package.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/python/system/dbus-python/package.mk b/packages/python/system/dbus-python/package.mk index 4ee0c668f00..720bb63060d 100644 --- a/packages/python/system/dbus-python/package.mk +++ b/packages/python/system/dbus-python/package.mk @@ -32,6 +32,11 @@ PKG_LONGDESC="D-BUS is a message bus, used for sending messages between applicat PKG_IS_ADDON="no" PKG_AUTORECONF="yes" +pre_configure_target() { + export PYTHON_INCLUDES="$($SYSROOT_PREFIX/usr/bin/python2-config --includes)" + export PYTHON_LIBS="$($SYSROOT_PREFIX/usr/bin/python2-config --ldflags)" +} + post_makeinstall_target() { find $INSTALL/usr/lib -name "*.py" -exec rm -rf "{}" ";" find $INSTALL/usr/lib -name "*.pyc" -exec rm -rf "{}" ";" From d48de86457af7c36ebff2c8fc37a7dd8ab4a3aaf Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Thu, 10 Mar 2016 15:00:39 +0100 Subject: [PATCH 10/10] Python: fix pkgconfig script Signed-off-by: Stephan Raue --- .../Python/patches/Python-2.7.11-010-fix-python-config.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lang/Python/patches/Python-2.7.11-010-fix-python-config.patch b/packages/lang/Python/patches/Python-2.7.11-010-fix-python-config.patch index 1266f3d3af0..7654d9d9b28 100644 --- a/packages/lang/Python/patches/Python-2.7.11-010-fix-python-config.patch +++ b/packages/lang/Python/patches/Python-2.7.11-010-fix-python-config.patch @@ -134,7 +134,7 @@ Index: b/Misc/python-config.sh.in +exec_prefix_build="@exec_prefix@" +exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#") +includedir=$(echo "@includedir@") -+libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#") ++libdir=$(echo "@libdir@") +CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#") +VERSION="@VERSION@" +LIBM="@LIBM@"