2022-04-09 20:58:53 +01:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
buildPythonPackage,
|
|
|
|
pythonOlder,
|
2024-10-24 02:05:57 +01:00
|
|
|
fetchFromGitHub,
|
|
|
|
|
|
|
|
# build-system
|
|
|
|
setuptools,
|
|
|
|
pkg-config,
|
|
|
|
|
|
|
|
# native dependencies
|
2022-10-07 02:55:32 +01:00
|
|
|
freetype,
|
2024-10-24 02:05:57 +01:00
|
|
|
lcms2,
|
|
|
|
libimagequant,
|
2022-10-07 02:55:32 +01:00
|
|
|
libjpeg,
|
2024-10-24 02:05:57 +01:00
|
|
|
libraqm,
|
2022-10-07 02:55:32 +01:00
|
|
|
libtiff,
|
|
|
|
libwebp,
|
2023-12-05 01:12:39 +00:00
|
|
|
libxcb,
|
|
|
|
openjpeg,
|
2024-10-24 02:05:57 +01:00
|
|
|
tkinter,
|
|
|
|
zlib,
|
|
|
|
|
|
|
|
# optional dependencies
|
|
|
|
defusedxml,
|
|
|
|
olefile,
|
|
|
|
typing-extensions,
|
|
|
|
|
|
|
|
# tests
|
2023-12-05 01:12:39 +00:00
|
|
|
numpy,
|
2024-10-24 02:05:57 +01:00
|
|
|
pytest-cov-stub,
|
2023-12-05 01:12:39 +00:00
|
|
|
pytestCheckHook,
|
2024-10-24 02:05:57 +01:00
|
|
|
|
2022-02-12 19:42:34 +00:00
|
|
|
# for passthru.tests
|
2024-05-06 13:13:20 +01:00
|
|
|
imageio,
|
|
|
|
matplotlib,
|
|
|
|
pilkit,
|
|
|
|
pydicom,
|
|
|
|
reportlab,
|
|
|
|
sage,
|
2024-10-24 02:05:57 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pillow";
|
|
|
|
version = "11.0.0";
|
|
|
|
pyproject = true;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "python-pillow";
|
|
|
|
repo = "pillow";
|
|
|
|
rev = "refs/tags/${version}";
|
|
|
|
hash = "sha256-vWNqzA2ZfJcWexXw790RgyYtP8WDtahoQIX16otCRnk=";
|
|
|
|
};
|
|
|
|
|
|
|
|
build-system = [ setuptools ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ pkg-config ];
|
|
|
|
|
|
|
|
# https://pillow.readthedocs.io/en/latest/installation/building-from-source.html#building-from-source
|
|
|
|
buildInputs = [
|
|
|
|
freetype
|
|
|
|
lcms2
|
|
|
|
libimagequant
|
|
|
|
libjpeg
|
|
|
|
libraqm
|
|
|
|
libtiff
|
|
|
|
libwebp
|
|
|
|
libxcb
|
|
|
|
openjpeg
|
|
|
|
tkinter
|
|
|
|
zlib
|
|
|
|
];
|
|
|
|
|
|
|
|
pypaBuildFlags = [
|
|
|
|
# Disable platform guessing, which tries various FHS paths
|
|
|
|
"--config=setting=--disable-platform-guessing"
|
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure =
|
|
|
|
let
|
|
|
|
getLibAndInclude = pkg: ''"${pkg.out}/lib", "${lib.getDev pkg}/include"'';
|
|
|
|
in
|
|
|
|
''
|
|
|
|
# The build process fails to find the pkg-config files for these dependencies
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace-fail 'IMAGEQUANT_ROOT = None' 'IMAGEQUANT_ROOT = ${getLibAndInclude libimagequant}' \
|
|
|
|
--replace-fail 'JPEG2K_ROOT = None' 'JPEG2K_ROOT = ${getLibAndInclude openjpeg}'
|
|
|
|
|
|
|
|
# Build with X11 support
|
|
|
|
export LDFLAGS="$LDFLAGS -L${libxcb}/lib"
|
|
|
|
export CFLAGS="$CFLAGS -I${libxcb.dev}/include"
|
|
|
|
'';
|
|
|
|
|
|
|
|
optional-dependencies = {
|
|
|
|
fpx = [ olefile ];
|
|
|
|
mic = [ olefile ];
|
|
|
|
typing = lib.optionals (pythonOlder "3.10") [ typing-extensions ];
|
|
|
|
xmp = [ defusedxml ];
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeCheckInputs = [
|
|
|
|
pytest-cov-stub
|
|
|
|
pytestCheckHook
|
|
|
|
numpy
|
|
|
|
] ++ lib.flatten (lib.attrValues optional-dependencies);
|
|
|
|
|
|
|
|
disabledTests =
|
|
|
|
[
|
|
|
|
# Code quality mismathch 9 vs 10
|
|
|
|
"test_pyroma"
|
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
|
|
|
# Disable darwin tests which require executables: `iconutil` and `screencapture`
|
|
|
|
"test_grab"
|
|
|
|
"test_grabclipboard"
|
|
|
|
"test_save"
|
|
|
|
];
|
|
|
|
|
2024-11-17 10:41:54 +00:00
|
|
|
disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
|
2024-10-24 02:05:57 +01:00
|
|
|
# Crashes the interpreter
|
|
|
|
"Tests/test_imagetk.py"
|
|
|
|
];
|
|
|
|
|
|
|
|
passthru.tests = {
|
|
|
|
inherit
|
|
|
|
imageio
|
|
|
|
matplotlib
|
|
|
|
pilkit
|
|
|
|
pydicom
|
|
|
|
reportlab
|
|
|
|
sage
|
|
|
|
;
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://python-pillow.org";
|
|
|
|
changelog = "https://pillow.readthedocs.io/en/stable/releasenotes/${version}.html";
|
|
|
|
description = "Friendly PIL fork (Python Imaging Library)";
|
|
|
|
longDescription = ''
|
|
|
|
The Python Imaging Library (PIL) adds image processing
|
|
|
|
capabilities to your Python interpreter. This library
|
|
|
|
supports many file formats, and provides powerful image
|
|
|
|
processing and graphics capabilities.
|
|
|
|
'';
|
|
|
|
license = licenses.mit-cmu;
|
|
|
|
maintainers = with maintainers; [ hexa ];
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|