pillow: Fix build on non-NixOS systems

The Pillow install script will, by default, add paths like /usr/lib and
/usr/include to the search paths.  This can break things when building
on a non-NixOS system that has some libraries installed that are not
installed in Nix (for example, Arch Linux has jpeg2000 but Nix doesn't
build Pillow with this support).

We solve this by telling Pillow to knock it off 😄

Fixes #36317
This commit is contained in:
Andrew Dunham 2018-03-04 19:13:58 -08:00
parent eaed0ec08e
commit 8ad2cb1d0c

View File

@ -31,6 +31,14 @@ buildPythonPackage rec {
++ stdenv.lib.optionals (isPyPy) [ tk libX11 ]; ++ stdenv.lib.optionals (isPyPy) [ tk libX11 ];
# NOTE: we use LCMS_ROOT as WEBP root since there is not other setting for webp. # NOTE: we use LCMS_ROOT as WEBP root since there is not other setting for webp.
# NOTE: The Pillow install script will, by default, add paths like /usr/lib
# and /usr/include to the search paths. This can break things when building
# on a non-NixOS system that has some libraries installed that are not
# installed in Nix (for example, Arch Linux has jpeg2000 but Nix doesn't
# build Pillow with this support). We patch the `disable_platform_guessing`
# setting here, instead of passing the `--disable-platform-guessing`
# command-line option, since the command-line option doesn't work when we run
# tests.
preConfigure = let preConfigure = let
libinclude' = pkg: ''"${pkg.out}/lib", "${pkg.out}/include"''; libinclude' = pkg: ''"${pkg.out}/lib", "${pkg.out}/include"'';
libinclude = pkg: ''"${pkg.out}/lib", "${pkg.dev}/include"''; libinclude = pkg: ''"${pkg.out}/lib", "${pkg.dev}/include"'';
@ -41,7 +49,8 @@ buildPythonPackage rec {
s|^ZLIB_ROOT =.*$|ZLIB_ROOT = ${libinclude zlib}|g ; s|^ZLIB_ROOT =.*$|ZLIB_ROOT = ${libinclude zlib}|g ;
s|^LCMS_ROOT =.*$|LCMS_ROOT = ${libinclude lcms2}|g ; s|^LCMS_ROOT =.*$|LCMS_ROOT = ${libinclude lcms2}|g ;
s|^TIFF_ROOT =.*$|TIFF_ROOT = ${libinclude libtiff}|g ; s|^TIFF_ROOT =.*$|TIFF_ROOT = ${libinclude libtiff}|g ;
s|^TCL_ROOT=.*$|TCL_ROOT = ${libinclude' tcl}|g ;' s|^TCL_ROOT=.*$|TCL_ROOT = ${libinclude' tcl}|g ;
s|self\.disable_platform_guessing = None|self.disable_platform_guessing = True|g ;'
export LDFLAGS="-L${libwebp}/lib" export LDFLAGS="-L${libwebp}/lib"
export CFLAGS="-I${libwebp}/include" export CFLAGS="-I${libwebp}/include"
'' ''