diff --git a/packages/lang/Python/package.mk b/packages/lang/Python/package.mk index 6079488f00..55f1d1cb50 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 0000000000..1266f3d3af --- /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 84b6e9c519..0000000000 --- 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