From 05ca39b5dc693c4e105e9afbcf556428c6e8ef3d Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Tue, 8 Jan 2019 23:00:42 +0000 Subject: [PATCH] dev-python/pillow: Fix cross-compiling of 5.4.1 Normally you shouldn't add -I/usr/include or -L/usr/lib, even if it is prepended with the SYSROOT, but Pillow's stupid build system checks for headers with Python rather than the toolchain. Luckily only minimal patching is needed. Signed-off-by: James Le Cuirot Package-Manager: Portage-2.3.49, Repoman-2.3.10 --- .../files/pillow-5.4.1-pkg-config.patch | 28 +++++++++++++++++++ .../files/pillow-5.4.1-toolchain-paths.patch | 12 ++++++++ dev-python/pillow/pillow-5.4.1.ebuild | 15 ++++++++-- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 dev-python/pillow/files/pillow-5.4.1-pkg-config.patch create mode 100644 dev-python/pillow/files/pillow-5.4.1-toolchain-paths.patch diff --git a/dev-python/pillow/files/pillow-5.4.1-pkg-config.patch b/dev-python/pillow/files/pillow-5.4.1-pkg-config.patch new file mode 100644 index 0000000000000..ec227b3f80a7d --- /dev/null +++ b/dev-python/pillow/files/pillow-5.4.1-pkg-config.patch @@ -0,0 +1,28 @@ +diff -Naur a/setup.py b/setup.py +--- a/setup.py 2019-01-06 12:12:16.000000000 +0000 ++++ b/setup.py 2019-01-08 23:04:45.574698210 +0000 +@@ -197,12 +197,13 @@ + + def _pkg_config(name): + try: ++ command = os.environ.get('PKG_CONFIG', 'pkg-config') + command_libs = [ +- 'pkg-config', ++ command, + '--libs-only-L', name, + ] + command_cflags = [ +- 'pkg-config', ++ command, + '--cflags-only-I', name, + ] + if not DEBUG: +@@ -298,7 +299,7 @@ + _add_directory(include_dirs, "src/libImaging") + + pkg_config = None +- if _cmd_exists('pkg-config'): ++ if _cmd_exists(os.environ.get('PKG_CONFIG', 'pkg-config')): + pkg_config = _pkg_config + + # diff --git a/dev-python/pillow/files/pillow-5.4.1-toolchain-paths.patch b/dev-python/pillow/files/pillow-5.4.1-toolchain-paths.patch new file mode 100644 index 0000000000000..d3e95eef51649 --- /dev/null +++ b/dev-python/pillow/files/pillow-5.4.1-toolchain-paths.patch @@ -0,0 +1,12 @@ +diff -Naur a/setup.py b/setup.py +--- a/setup.py 2019-01-08 23:06:33.082873069 +0000 ++++ b/setup.py 2019-01-08 23:06:47.707165225 +0000 +@@ -356,7 +356,7 @@ + for d in os.environ[k].split(os.path.pathsep): + _add_directory(library_dirs, d) + +- prefix = sysconfig.get_config_var("prefix") ++ prefix = None + if prefix: + _add_directory(library_dirs, os.path.join(prefix, "lib")) + _add_directory(include_dirs, os.path.join(prefix, "include")) diff --git a/dev-python/pillow/pillow-5.4.1.ebuild b/dev-python/pillow/pillow-5.4.1.ebuild index 61d35cce7f60f..75df944128fb0 100644 --- a/dev-python/pillow/pillow-5.4.1.ebuild +++ b/dev-python/pillow/pillow-5.4.1.ebuild @@ -6,7 +6,7 @@ EAPI=7 PYTHON_COMPAT=( python2_7 python3_{4,5,6,7} pypy ) PYTHON_REQ_USE='tk?,threads(+)' -inherit distutils-r1 virtualx +inherit distutils-r1 toolchain-funcs virtualx MY_PN=Pillow MY_P=${MY_PN}-${PV} @@ -47,7 +47,7 @@ DEPEND="${RDEPEND} S="${WORKDIR}/${MY_P}" PATCHES=( - "${FILESDIR}/${PN}-5.2.0-fix-lib-paths.patch" + "${FILESDIR}"/${PN}-5.4.1-{pkg-config,toolchain-paths}.patch ) python_configure_all() { @@ -66,6 +66,17 @@ python_configure_all() { $(use_enable webp webpmux) $(use_enable zlib) ) + + # setup.py sucks at adding the right toolchain paths but it does + # accept additional ones from INCLUDE and LIB so set these. You + # wouldn't normally need these at all as the toolchain should look + # here anyway but this setup.py does stupid things. + export \ + INCLUDE=${ESYSROOT}/usr/include \ + LIB=${ESYSROOT}/usr/$(get_libdir) + + # We have patched in this env var. + tc-export PKG_CONFIG } python_compile_all() {