2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
pname,
|
|
|
|
version,
|
|
|
|
disabled,
|
|
|
|
src,
|
|
|
|
patches ? [ ],
|
|
|
|
meta,
|
|
|
|
passthru ? { },
|
|
|
|
...
|
2021-02-19 19:06:45 +00:00
|
|
|
}@args:
|
|
|
|
|
|
|
|
with args;
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
2024-06-05 15:53:02 +00:00
|
|
|
inherit
|
|
|
|
pname
|
|
|
|
version
|
|
|
|
format
|
|
|
|
src
|
|
|
|
meta
|
|
|
|
passthru
|
|
|
|
patches
|
|
|
|
;
|
2021-02-19 19:06:45 +00:00
|
|
|
|
|
|
|
# Disable imagefont tests, because they don't work well with infinality:
|
|
|
|
# https://github.com/python-pillow/Pillow/issues/1259
|
|
|
|
postPatch = ''
|
|
|
|
rm Tests/test_imagefont.py
|
|
|
|
'';
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
disabledTests =
|
|
|
|
[
|
|
|
|
# Code quality mismathch 9 vs 10
|
|
|
|
"test_pyroma"
|
2021-02-19 19:06:45 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
# pillow-simd
|
|
|
|
"test_roundtrip"
|
|
|
|
"test_basic"
|
|
|
|
"test_custom_metadata"
|
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.isDarwin [
|
|
|
|
# Disable darwin tests which require executables: `iconutil` and `screencapture`
|
|
|
|
"test_grab"
|
|
|
|
"test_grabclipboard"
|
|
|
|
"test_save"
|
|
|
|
];
|
2021-02-19 19:06:45 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
olefile
|
|
|
|
] ++ lib.optionals (lib.versionAtLeast version "8.2.0") [ defusedxml ];
|
2021-02-19 19:06:45 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeCheckInputs = [
|
|
|
|
pytestCheckHook
|
|
|
|
numpy
|
|
|
|
];
|
2021-02-19 19:06:45 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
nativeBuildInputs = [ setuptools ];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
buildInputs =
|
|
|
|
[
|
|
|
|
freetype
|
|
|
|
libjpeg
|
|
|
|
openjpeg
|
|
|
|
libimagequant
|
|
|
|
zlib
|
|
|
|
libtiff
|
|
|
|
libwebp
|
|
|
|
libxcrypt
|
|
|
|
tcl
|
|
|
|
lcms2
|
|
|
|
]
|
2021-02-19 19:06:45 +00:00
|
|
|
++ lib.optionals (lib.versionAtLeast version "7.1.0") [ libxcb ]
|
2024-06-05 15:53:02 +00:00
|
|
|
++ lib.optionals (isPyPy) [
|
|
|
|
tk
|
|
|
|
libX11
|
|
|
|
];
|
2021-02-19 19:06:45 +00:00
|
|
|
|
|
|
|
# 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.
|
2024-06-05 15:53:02 +00:00
|
|
|
preConfigure =
|
|
|
|
let
|
|
|
|
libinclude' = pkg: ''"${pkg.out}/lib", "${pkg.out}/include"'';
|
|
|
|
libinclude = pkg: ''"${pkg.out}/lib", "${pkg.dev}/include"'';
|
|
|
|
in
|
|
|
|
''
|
|
|
|
sed -i "setup.py" \
|
|
|
|
-e 's|^FREETYPE_ROOT =.*$|FREETYPE_ROOT = ${libinclude freetype}|g ;
|
|
|
|
s|^JPEG_ROOT =.*$|JPEG_ROOT = ${libinclude libjpeg}|g ;
|
|
|
|
s|^JPEG2K_ROOT =.*$|JPEG2K_ROOT = ${libinclude openjpeg}|g ;
|
|
|
|
s|^IMAGEQUANT_ROOT =.*$|IMAGEQUANT_ROOT = ${libinclude' libimagequant}|g ;
|
|
|
|
s|^ZLIB_ROOT =.*$|ZLIB_ROOT = ${libinclude zlib}|g ;
|
|
|
|
s|^LCMS_ROOT =.*$|LCMS_ROOT = ${libinclude lcms2}|g ;
|
|
|
|
s|^TIFF_ROOT =.*$|TIFF_ROOT = ${libinclude libtiff}|g ;
|
|
|
|
s|^TCL_ROOT=.*$|TCL_ROOT = ${libinclude' tcl}|g ;
|
|
|
|
s|self\.disable_platform_guessing = None|self.disable_platform_guessing = True|g ;'
|
|
|
|
export LDFLAGS="$LDFLAGS -L${libwebp}/lib"
|
|
|
|
export CFLAGS="$CFLAGS -I${libwebp}/include"
|
|
|
|
''
|
|
|
|
+ lib.optionalString (lib.versionAtLeast version "7.1.0") ''
|
|
|
|
export LDFLAGS="$LDFLAGS -L${libxcb}/lib"
|
|
|
|
export CFLAGS="$CFLAGS -I${libxcb.dev}/include"
|
|
|
|
'';
|
2021-02-19 19:06:45 +00:00
|
|
|
}
|