Merge pull request #108098 from SuperSandro2000/pillow-simd

authored by Sandro and committed by GitHub 3796e38e 07060526

+129 -125
+32
pkgs/development/python-modules/pillow-simd/default.nix
··· 1 + { lib, stdenv, buildPythonPackage, fetchFromGitHub, isPyPy, isPy3k 2 + , olefile, freetype, libjpeg, zlib, libtiff, libwebp, tcl, lcms2 3 + , tk, libX11, openjpeg, libimagequant, pyroma, numpy, pytestCheckHook 4 + }@args: 5 + 6 + import ../pillow/generic.nix (rec { 7 + pname = "Pillow-SIMD"; 8 + version = "7.0.0.post3"; 9 + 10 + disabled = !isPy3k; 11 + 12 + src = fetchFromGitHub { 13 + owner = "uploadcare"; 14 + repo = "pillow-simd"; 15 + rev = "v${version}"; 16 + sha256 = "1h832xp1bzf951hr4dmjmxqfsv28sx9lr2cq96qdz1c72k40zj1h"; 17 + }; 18 + 19 + meta = with lib; { 20 + homepage = "https://python-pillow.github.io/pillow-perf/"; 21 + description = "The friendly PIL fork - SIMD version"; 22 + longDescription = '' 23 + Pillow-SIMD is "following" Pillow. Pillow-SIMD versions are 100% compatible drop-in replacements for Pillow of the same version. 24 + 25 + SIMD stands for "single instruction, multiple data" and its essence is in performing the same operation on multiple data points simultaneously by using multiple processing elements. Common CPU SIMD instruction sets are MMX, SSE-SSE4, AVX, AVX2, AVX512, NEON. 26 + 27 + Currently, Pillow-SIMD can be compiled with SSE4 (default) or AVX2 support. 28 + ''; 29 + license = "http://www.pythonware.com/products/pil/license.htm"; 30 + maintainers = with maintainers; [ SuperSandro2000 ]; 31 + }; 32 + } // args )
+11 -64
pkgs/development/python-modules/pillow/6.nix
··· 1 - { lib, stdenv, buildPythonPackage, fetchPypi, isPyPy 2 - , olefile 3 - , freetype, libjpeg, zlib, libtiff, libwebp, tcl, lcms2, tk, libX11 4 - , openjpeg, libimagequant 5 - , pytest, pytestrunner, pyroma, numpy 6 - }: 1 + { lib, stdenv, buildPythonPackage, fetchPypi, isPyPy, isPy3k 2 + , olefile, freetype, libjpeg, zlib, libtiff, libwebp, tcl, lcms2, tk, libX11 3 + , openjpeg, libimagequant, pyroma, numpy, pytestCheckHook 4 + }@args: 7 5 8 - buildPythonPackage rec { 6 + import ./generic.nix (rec { 9 7 pname = "Pillow"; 10 8 version = "6.2.2"; 9 + 10 + disabled = !isPy3k; 11 11 12 12 src = fetchPypi { 13 13 inherit pname version; 14 14 sha256 = "0l5rv8jkdrb5q846v60v03mcq64yrhklidjkgwv6s1pda71g17yv"; 15 15 }; 16 16 17 - # Disable imagefont tests, because they don't work well with infinality: 18 - # https://github.com/python-pillow/Pillow/issues/1259 19 - postPatch = '' 20 - rm Tests/test_imagefont.py 21 - ''; 22 - 23 - checkPhase = '' 24 - runHook preCheck 25 - 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"} 26 - runHook postCheck 27 - ''; 28 - 29 - propagatedBuildInputs = [ olefile ]; 30 - 31 - checkInputs = [ pytest pytestrunner pyroma numpy ]; 32 - 33 - buildInputs = [ 34 - freetype libjpeg openjpeg libimagequant zlib libtiff libwebp tcl lcms2 ] 35 - ++ lib.optionals (isPyPy) [ tk libX11 ]; 36 - 37 - # NOTE: we use LCMS_ROOT as WEBP root since there is not other setting for webp. 38 - # NOTE: The Pillow install script will, by default, add paths like /usr/lib 39 - # and /usr/include to the search paths. This can break things when building 40 - # on a non-NixOS system that has some libraries installed that are not 41 - # installed in Nix (for example, Arch Linux has jpeg2000 but Nix doesn't 42 - # build Pillow with this support). We patch the `disable_platform_guessing` 43 - # setting here, instead of passing the `--disable-platform-guessing` 44 - # command-line option, since the command-line option doesn't work when we run 45 - # tests. 46 - preConfigure = let 47 - libinclude' = pkg: ''"${pkg.out}/lib", "${pkg.out}/include"''; 48 - libinclude = pkg: ''"${pkg.out}/lib", "${pkg.dev}/include"''; 49 - in '' 50 - sed -i "setup.py" \ 51 - -e 's|^FREETYPE_ROOT =.*$|FREETYPE_ROOT = ${libinclude freetype}|g ; 52 - s|^JPEG_ROOT =.*$|JPEG_ROOT = ${libinclude libjpeg}|g ; 53 - s|^JPEG2K_ROOT =.*$|JPEG2K_ROOT = ${libinclude openjpeg}|g ; 54 - s|^IMAGEQUANT_ROOT =.*$|IMAGEQUANT_ROOT = ${libinclude' libimagequant}|g ; 55 - s|^ZLIB_ROOT =.*$|ZLIB_ROOT = ${libinclude zlib}|g ; 56 - s|^LCMS_ROOT =.*$|LCMS_ROOT = ${libinclude lcms2}|g ; 57 - s|^TIFF_ROOT =.*$|TIFF_ROOT = ${libinclude libtiff}|g ; 58 - s|^TCL_ROOT=.*$|TCL_ROOT = ${libinclude' tcl}|g ; 59 - s|self\.disable_platform_guessing = None|self.disable_platform_guessing = True|g ;' 60 - export LDFLAGS="-L${libwebp}/lib" 61 - export CFLAGS="-I${libwebp}/include" 62 - '' 63 - # Remove impurities 64 - + lib.optionalString stdenv.isDarwin '' 65 - substituteInPlace setup.py \ 66 - --replace '"/Library/Frameworks",' "" \ 67 - --replace '"/System/Library/Frameworks"' "" 68 - ''; 69 - 70 17 meta = with lib; { 71 - homepage = "https://python-pillow.github.io/"; 72 - description = "Fork of The Python Imaging Library (PIL)"; 18 + homepage = "https://python-pillow.org/"; 19 + description = "The friendly PIL fork (Python Imaging Library)"; 73 20 longDescription = '' 74 21 The Python Imaging Library (PIL) adds image processing 75 22 capabilities to your Python interpreter. This library ··· 77 24 processing and graphics capabilities. 78 25 ''; 79 26 license = "http://www.pythonware.com/products/pil/license.htm"; 80 - maintainers = with maintainers; [ goibhniu prikhi ]; 27 + maintainers = with maintainers; [ goibhniu prikhi SuperSandro2000 ]; 81 28 }; 82 - } 29 + } // args )
+7 -60
pkgs/development/python-modules/pillow/default.nix
··· 1 - { lib, stdenv, buildPythonPackage, fetchPypi, isPyPy 2 - , olefile 3 - , freetype, libjpeg, zlib, libtiff, libwebp, tcl, lcms2, tk, libX11 4 - , openjpeg, libimagequant 5 - , pyroma, numpy, pytestCheckHook 6 - , isPy3k 7 - }: 1 + { lib, stdenv, buildPythonPackage, fetchPypi, isPyPy, isPy3k 2 + , olefile, freetype, libjpeg, zlib, libtiff, libwebp, tcl, lcms2, tk, libX11 3 + , libxcb, openjpeg, libimagequant, pyroma, numpy, pytestCheckHook 4 + }@args: 8 5 9 - buildPythonPackage rec { 6 + import ./generic.nix (rec { 10 7 pname = "Pillow"; 11 8 version = "8.0.1"; 12 9 ··· 17 14 sha256 = "11c5c6e9b02c9dac08af04f093eb5a2f84857df70a7d4a6a6ad461aca803fb9e"; 18 15 }; 19 16 20 - # Disable imagefont tests, because they don't work well with infinality: 21 - # https://github.com/python-pillow/Pillow/issues/1259 22 - postPatch = '' 23 - rm Tests/test_imagefont.py 24 - ''; 25 - 26 - # Disable darwin tests which require executables: `iconutil` and `screencapture` 27 - disabledTests = lib.optionals stdenv.isDarwin [ "test_save" "test_grab" "test_grabclipboard" ]; 28 - 29 - propagatedBuildInputs = [ olefile ]; 30 - 31 - checkInputs = [ pytestCheckHook pyroma numpy ]; 32 - 33 - buildInputs = [ 34 - freetype libjpeg openjpeg libimagequant zlib libtiff libwebp tcl lcms2 ] 35 - ++ lib.optionals (isPyPy) [ tk libX11 ]; 36 - 37 - # NOTE: we use LCMS_ROOT as WEBP root since there is not other setting for webp. 38 - # NOTE: The Pillow install script will, by default, add paths like /usr/lib 39 - # and /usr/include to the search paths. This can break things when building 40 - # on a non-NixOS system that has some libraries installed that are not 41 - # installed in Nix (for example, Arch Linux has jpeg2000 but Nix doesn't 42 - # build Pillow with this support). We patch the `disable_platform_guessing` 43 - # setting here, instead of passing the `--disable-platform-guessing` 44 - # command-line option, since the command-line option doesn't work when we run 45 - # tests. 46 - preConfigure = let 47 - libinclude' = pkg: ''"${pkg.out}/lib", "${pkg.out}/include"''; 48 - libinclude = pkg: ''"${pkg.out}/lib", "${pkg.dev}/include"''; 49 - in '' 50 - sed -i "setup.py" \ 51 - -e 's|^FREETYPE_ROOT =.*$|FREETYPE_ROOT = ${libinclude freetype}|g ; 52 - s|^JPEG_ROOT =.*$|JPEG_ROOT = ${libinclude libjpeg}|g ; 53 - s|^JPEG2K_ROOT =.*$|JPEG2K_ROOT = ${libinclude openjpeg}|g ; 54 - s|^IMAGEQUANT_ROOT =.*$|IMAGEQUANT_ROOT = ${libinclude' libimagequant}|g ; 55 - s|^ZLIB_ROOT =.*$|ZLIB_ROOT = ${libinclude zlib}|g ; 56 - s|^LCMS_ROOT =.*$|LCMS_ROOT = ${libinclude lcms2}|g ; 57 - s|^TIFF_ROOT =.*$|TIFF_ROOT = ${libinclude libtiff}|g ; 58 - s|^TCL_ROOT=.*$|TCL_ROOT = ${libinclude' tcl}|g ; 59 - s|self\.disable_platform_guessing = None|self.disable_platform_guessing = True|g ;' 60 - export LDFLAGS="-L${libwebp}/lib" 61 - export CFLAGS="-I${libwebp}/include" 62 - '' 63 - # Remove impurities 64 - + lib.optionalString stdenv.isDarwin '' 65 - substituteInPlace setup.py \ 66 - --replace '"/Library/Frameworks",' "" \ 67 - --replace '"/System/Library/Frameworks"' "" 68 - ''; 69 - 70 17 meta = with lib; { 71 18 homepage = "https://python-pillow.org/"; 72 19 description = "The friendly PIL fork (Python Imaging Library)"; ··· 77 24 processing and graphics capabilities. 78 25 ''; 79 26 license = "http://www.pythonware.com/products/pil/license.htm"; 80 - maintainers = with maintainers; [ goibhniu prikhi ]; 27 + maintainers = with maintainers; [ goibhniu prikhi SuperSandro2000 ]; 81 28 }; 82 - } 29 + } // args )
+73
pkgs/development/python-modules/pillow/generic.nix
··· 1 + { pname 2 + , version 3 + , disabled 4 + , src 5 + , meta 6 + , ... 7 + }@args: 8 + 9 + with args; 10 + 11 + buildPythonPackage rec { 12 + inherit pname version src meta; 13 + 14 + # Disable imagefont tests, because they don't work well with infinality: 15 + # https://github.com/python-pillow/Pillow/issues/1259 16 + postPatch = '' 17 + rm Tests/test_imagefont.py 18 + ''; 19 + 20 + # Disable darwin tests which require executables: `iconutil` and `screencapture` 21 + disabledTests = lib.optionals stdenv.isDarwin [ 22 + "test_grab" 23 + "test_grabclipboard" 24 + "test_save" 25 + 26 + # pillow-simd 27 + "test_roundtrip" 28 + "test_basic" 29 + ]; 30 + 31 + propagatedBuildInputs = [ olefile ]; 32 + 33 + checkInputs = [ pytestCheckHook pyroma numpy ]; 34 + 35 + buildInputs = [ freetype libjpeg openjpeg libimagequant zlib libtiff libwebp tcl lcms2 ] 36 + ++ lib.optionals (lib.versionAtLeast version "7.1.0") [ libxcb ] 37 + ++ lib.optionals (isPyPy) [ tk libX11 ]; 38 + 39 + # NOTE: we use LCMS_ROOT as WEBP root since there is not other setting for webp. 40 + # NOTE: The Pillow install script will, by default, add paths like /usr/lib 41 + # and /usr/include to the search paths. This can break things when building 42 + # on a non-NixOS system that has some libraries installed that are not 43 + # installed in Nix (for example, Arch Linux has jpeg2000 but Nix doesn't 44 + # build Pillow with this support). We patch the `disable_platform_guessing` 45 + # setting here, instead of passing the `--disable-platform-guessing` 46 + # command-line option, since the command-line option doesn't work when we run 47 + # tests. 48 + preConfigure = let 49 + libinclude' = pkg: ''"${pkg.out}/lib", "${pkg.out}/include"''; 50 + libinclude = pkg: ''"${pkg.out}/lib", "${pkg.dev}/include"''; 51 + in '' 52 + sed -i "setup.py" \ 53 + -e 's|^FREETYPE_ROOT =.*$|FREETYPE_ROOT = ${libinclude freetype}|g ; 54 + s|^JPEG_ROOT =.*$|JPEG_ROOT = ${libinclude libjpeg}|g ; 55 + s|^JPEG2K_ROOT =.*$|JPEG2K_ROOT = ${libinclude openjpeg}|g ; 56 + s|^IMAGEQUANT_ROOT =.*$|IMAGEQUANT_ROOT = ${libinclude' libimagequant}|g ; 57 + s|^ZLIB_ROOT =.*$|ZLIB_ROOT = ${libinclude zlib}|g ; 58 + s|^LCMS_ROOT =.*$|LCMS_ROOT = ${libinclude lcms2}|g ; 59 + s|^TIFF_ROOT =.*$|TIFF_ROOT = ${libinclude libtiff}|g ; 60 + s|^TCL_ROOT=.*$|TCL_ROOT = ${libinclude' tcl}|g ; 61 + s|self\.disable_platform_guessing = None|self.disable_platform_guessing = True|g ;' 62 + export LDFLAGS="$LDFLAGS -L${libwebp}/lib" 63 + export CFLAGS="$CFLAGS -I${libwebp}/include" 64 + '' + lib.optionalString (lib.versionAtLeast version "7.1.0") '' 65 + export LDFLAGS="$LDFLAGS -L${libxcb}/lib" 66 + export CFLAGS="$CFLAGS -I${libxcb.dev}/include" 67 + '' + lib.optionalString stdenv.isDarwin '' 68 + # Remove impurities 69 + substituteInPlace setup.py \ 70 + --replace '"/Library/Frameworks",' "" \ 71 + --replace '"/System/Library/Frameworks"' "" 72 + ''; 73 + }
+6 -1
pkgs/top-level/python-packages.nix
··· 4850 4850 else 4851 4851 callPackage ../development/python-modules/pillow { 4852 4852 inherit (pkgs) freetype libjpeg zlib libtiff libwebp tcl lcms2 tk; 4853 + inherit (pkgs.xorg) libX11 libxcb; 4854 + }; 4855 + 4856 + pillow-simd = callPackage ../development/python-modules/pillow-simd { 4857 + inherit (pkgs) freetype libjpeg zlib libtiff libwebp tcl lcms2 tk; 4853 4858 inherit (pkgs.xorg) libX11; 4854 - }; 4859 + }; 4855 4860 4856 4861 pims = callPackage ../development/python-modules/pims { }; 4857 4862