about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/pillow
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-04-09 18:28:16 +0000
committerAlyssa Ross <hi@alyssa.is>2021-04-12 18:46:15 +0000
commitfd2e737e0678ee7d8081baef05b305146a2c0034 (patch)
treeac3e9b27576a0382335532d126f9a66d486bc638 /nixpkgs/pkgs/development/python-modules/pillow
parentcc207d720b6aa836e256c1ee9842bc739e630a8a (diff)
parent9e377a6ce42dccd9b624ae4ce8f978dc892ba0e2 (diff)
downloadnixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.tar
nixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.tar.gz
nixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.tar.bz2
nixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.tar.lz
nixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.tar.xz
nixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.tar.zst
nixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.zip
Merge remote-tracking branch 'nixpkgs/nixos-unstable'
Diffstat (limited to 'nixpkgs/pkgs/development/python-modules/pillow')
-rw-r--r--nixpkgs/pkgs/development/python-modules/pillow/6.nix75
-rw-r--r--nixpkgs/pkgs/development/python-modules/pillow/default.nix73
-rw-r--r--nixpkgs/pkgs/development/python-modules/pillow/generic.nix76
3 files changed, 97 insertions, 127 deletions
diff --git a/nixpkgs/pkgs/development/python-modules/pillow/6.nix b/nixpkgs/pkgs/development/python-modules/pillow/6.nix
index 0e3fabf1fbca..51833edfd0b0 100644
--- a/nixpkgs/pkgs/development/python-modules/pillow/6.nix
+++ b/nixpkgs/pkgs/development/python-modules/pillow/6.nix
@@ -1,75 +1,22 @@
-{ lib, stdenv, buildPythonPackage, fetchPypi, isPyPy
-, olefile
-, freetype, libjpeg, zlib, libtiff, libwebp, tcl, lcms2, tk, libX11
-, openjpeg, libimagequant
-, pytest, pytestrunner, pyroma, numpy
-}:
+{ lib, stdenv, buildPythonPackage, fetchPypi, isPyPy, isPy3k
+, olefile, freetype, libjpeg, zlib, libtiff, libwebp, tcl, lcms2, tk, libX11
+, openjpeg, libimagequant, pyroma, numpy, pytestCheckHook
+}@args:
 
-buildPythonPackage rec {
+import ./generic.nix (rec {
   pname = "Pillow";
   version = "6.2.2";
 
+  disabled = !isPy3k;
+
   src = fetchPypi {
     inherit pname version;
     sha256 = "0l5rv8jkdrb5q846v60v03mcq64yrhklidjkgwv6s1pda71g17yv";
   };
 
-  # 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
-  '';
-
-  checkPhase = ''
-    runHook preCheck
-    python -m pytest -v -x -W always${lib.optionalString stdenv.isDarwin " --deselect=Tests/test_file_icns.py::TestFileIcns::test_save --deselect=Tests/test_imagegrab.py::TestImageGrab::test_grab"}
-    runHook postCheck
-  '';
-
-  propagatedBuildInputs = [ olefile ];
-
-  checkInputs = [ pytest pytestrunner pyroma numpy ];
-
-  buildInputs = [
-    freetype libjpeg openjpeg libimagequant zlib libtiff libwebp tcl lcms2 ]
-    ++ lib.optionals (isPyPy) [ tk libX11 ];
-
-  # 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
-    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="-L${libwebp}/lib"
-    export CFLAGS="-I${libwebp}/include"
-  ''
-  # Remove impurities
-  + lib.optionalString stdenv.isDarwin ''
-    substituteInPlace setup.py \
-      --replace '"/Library/Frameworks",' "" \
-      --replace '"/System/Library/Frameworks"' ""
-  '';
-
   meta = with lib; {
-    homepage = "https://python-pillow.github.io/";
-    description = "Fork of The Python Imaging Library (PIL)";
+    homepage = "https://python-pillow.org/";
+    description = "The friendly PIL fork (Python Imaging Library)";
     longDescription = ''
       The Python Imaging Library (PIL) adds image processing
       capabilities to your Python interpreter.  This library
@@ -77,6 +24,6 @@ buildPythonPackage rec {
       processing and graphics capabilities.
     '';
     license = "http://www.pythonware.com/products/pil/license.htm";
-    maintainers = with maintainers; [ goibhniu prikhi ];
+    maintainers = with maintainers; [ goibhniu prikhi SuperSandro2000 ];
   };
-}
+} // args )
diff --git a/nixpkgs/pkgs/development/python-modules/pillow/default.nix b/nixpkgs/pkgs/development/python-modules/pillow/default.nix
index 4084df19404b..02611c5a9255 100644
--- a/nixpkgs/pkgs/development/python-modules/pillow/default.nix
+++ b/nixpkgs/pkgs/development/python-modules/pillow/default.nix
@@ -1,72 +1,19 @@
-{ lib, stdenv, buildPythonPackage, fetchPypi, isPyPy
-, olefile
-, freetype, libjpeg, zlib, libtiff, libwebp, tcl, lcms2, tk, libX11
-, openjpeg, libimagequant
-, pyroma, numpy, pytestCheckHook
-, isPy3k
-}:
+{ lib, stdenv, buildPythonPackage, fetchPypi, isPyPy, isPy3k
+, olefile, freetype, libjpeg, zlib, libtiff, libwebp, tcl, lcms2, tk, libX11
+, libxcb, openjpeg, libimagequant, pyroma, numpy, pytestCheckHook
+}@args:
 
-buildPythonPackage rec {
+import ./generic.nix (rec {
   pname = "Pillow";
-  version = "8.0.1";
+  version = "8.1.1";
 
   disabled = !isPy3k;
 
   src = fetchPypi {
     inherit pname version;
-    sha256 = "11c5c6e9b02c9dac08af04f093eb5a2f84857df70a7d4a6a6ad461aca803fb9e";
+    sha256 = "086g7nhv52wclrwnzbzs2x3nvyzs2hfq1bvgivsrp5f7r7wiiz7n";
   };
 
-  # 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
-  '';
-
-  # Disable darwin tests which require executables: `iconutil` and `screencapture`
-  disabledTests = lib.optionals stdenv.isDarwin [ "test_save" "test_grab" "test_grabclipboard" ];
-
-  propagatedBuildInputs = [ olefile ];
-
-  checkInputs = [ pytestCheckHook pyroma numpy ];
-
-  buildInputs = [
-    freetype libjpeg openjpeg libimagequant zlib libtiff libwebp tcl lcms2 ]
-    ++ lib.optionals (isPyPy) [ tk libX11 ];
-
-  # 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
-    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="-L${libwebp}/lib"
-    export CFLAGS="-I${libwebp}/include"
-  ''
-  # Remove impurities
-  + lib.optionalString stdenv.isDarwin ''
-    substituteInPlace setup.py \
-      --replace '"/Library/Frameworks",' "" \
-      --replace '"/System/Library/Frameworks"' ""
-  '';
-
   meta = with lib; {
     homepage = "https://python-pillow.org/";
     description = "The friendly PIL fork (Python Imaging Library)";
@@ -76,7 +23,7 @@ buildPythonPackage rec {
       supports many file formats, and provides powerful image
       processing and graphics capabilities.
     '';
-    license = "http://www.pythonware.com/products/pil/license.htm";
-    maintainers = with maintainers; [ goibhniu prikhi ];
+    license = licenses.hpnd;
+    maintainers = with maintainers; [ goibhniu prikhi SuperSandro2000 ];
   };
-}
+} // args )
diff --git a/nixpkgs/pkgs/development/python-modules/pillow/generic.nix b/nixpkgs/pkgs/development/python-modules/pillow/generic.nix
new file mode 100644
index 000000000000..64ae91895593
--- /dev/null
+++ b/nixpkgs/pkgs/development/python-modules/pillow/generic.nix
@@ -0,0 +1,76 @@
+{ pname
+, version
+, disabled
+, src
+, meta
+, ...
+}@args:
+
+with args;
+
+buildPythonPackage rec {
+  inherit pname version src meta;
+
+  # 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
+  '';
+
+  # Disable darwin tests which require executables: `iconutil` and `screencapture`
+  disabledTests = lib.optionals stdenv.isDarwin [
+    "test_grab"
+    "test_grabclipboard"
+    "test_save"
+
+    # pillow-simd
+    "test_roundtrip"
+    "test_basic"
+  ] ++ lib.optionals (lib.versions.major version == "6") [
+    # RuntimeError: Error setting from dictionary
+    "test_custom_metadata"
+  ];
+
+  propagatedBuildInputs = [ olefile ];
+
+  checkInputs = [ pytestCheckHook pyroma numpy ];
+
+  buildInputs = [ freetype libjpeg openjpeg libimagequant zlib libtiff libwebp tcl lcms2 ]
+    ++ lib.optionals (lib.versionAtLeast version "7.1.0") [ libxcb ]
+    ++ lib.optionals (isPyPy) [ tk libX11 ];
+
+  # 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
+    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"
+  '' + lib.optionalString stdenv.isDarwin ''
+    # Remove impurities
+    substituteInPlace setup.py \
+      --replace '"/Library/Frameworks",' "" \
+      --replace '"/System/Library/Frameworks"' ""
+  '';
+}