Pillow-SIMD: use as default PIL provider (#18097)

* Pillow-SIMD: use as default PIL provider

* Fix concretization of pil

* Fix build of older versions of pillow
This commit is contained in:
Adam J. Stewart 2020-09-03 12:39:35 -05:00 committed by GitHub
parent 8c264a9f26
commit 098beee295
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 83 additions and 48 deletions

View File

@ -38,7 +38,7 @@ packages:
mpi: [openmpi, mpich]
mysql-client: [mysql, mariadb-c-client]
opencl: [pocl]
pil: [py-pillow]
pil: [py-pillow-simd]
pkgconfig: [pkgconf, pkg-config]
rpc: [libtirpc]
scalapack: [netlib-scalapack]

View File

@ -115,7 +115,7 @@ class Paraview(CMakePackage, CudaPackage):
# Can't contretize with python2 and py-setuptools@45.0.0:
depends_on('py-setuptools@:44.99.99', when='+python')
# Can't contretize with python2 and py-pillow@7.0.0:
depends_on('py-pillow@:6', when='+python')
depends_on('pil@:6', when='+python')
patch('stl-reader-pv440.patch', when='@4.4.0')

View File

@ -18,7 +18,7 @@ class PyBokeh(PythonPackage):
depends_on('python@2.6:', type=('build', 'run'), when='@0.12.2')
depends_on('python@2.7:', type=('build', 'run'), when='@1.3.4:')
depends_on('py-requests@1.2.3:', type=('build', 'run'), when='@0.12.2')
depends_on('py-pillow@4.0:', type=('build', 'run'), when='@1.3.4:')
depends_on('pil@4.0:', type=('build', 'run'), when='@1.3.4:')
depends_on('py-packaging@16.8:', type=('build', 'run'), when='@1.3.4:')
depends_on('py-six@1.5.2:', type=('build', 'run'))
depends_on('py-pyyaml@3.10:', type=('build', 'run'))

View File

@ -42,10 +42,10 @@ class PyCartopy(PythonPackage):
# Optional dependecies
depends_on('py-pyepsg@0.4.0:', type=('build', 'run'), when='+epsg')
depends_on('py-owslib@0.8.11:', type=('build', 'run'), when='+ows')
depends_on('py-pillow@1.7.8:', type=('build', 'run'), when='+ows')
depends_on('pil@1.7.8:', type=('build', 'run'), when='+ows')
depends_on('py-matplotlib@1.5.1:', type=('build', 'run'), when='+plotting')
depends_on('gdal@1.10.0:+python', type=('build', 'run'), when='+plotting')
depends_on('py-pillow@1.7.8:', type=('build', 'run'), when='+plotting')
depends_on('pil@1.7.8:', type=('build', 'run'), when='+plotting')
depends_on('py-scipy@0.10:', type=('build', 'run'), when='+plotting')
# Testing dependencies

View File

@ -24,7 +24,7 @@ class PyGluoncv(PythonPackage):
depends_on('py-requests', type=('build', 'run'))
depends_on('py-matplotlib', type=('build', 'run'))
depends_on('py-portalocker', type=('build', 'run'))
depends_on('py-pillow', type=('build', 'run'))
depends_on('pil', type=('build', 'run'))
depends_on('py-scipy', type=('build', 'run'))
depends_on('py-cython', type='build')

View File

@ -20,4 +20,4 @@ class PyGuiqwt(PythonPackage):
depends_on('py-scipy@0.7:', type=('build', 'run'))
depends_on('py-guidata@1.7.0:', type=('build', 'run'))
depends_on('py-pythonqwt@0.5.0:', type=('build', 'run'))
depends_on('py-pillow', type=('build', 'run'))
depends_on('pil', type=('build', 'run'))

View File

@ -23,7 +23,7 @@ class PyImageio(PythonPackage):
# Fix for python 2 if needed.
depends_on('py-numpy', type=('build', 'run'))
depends_on('py-pillow', type=('build', 'run'))
depends_on('pil', type=('build', 'run'))
depends_on('python@2.7:2.8,3.4:', type=('build', 'run'))
depends_on('py-setuptools', type='build')
depends_on('ffmpeg', type='run')

View File

@ -93,7 +93,7 @@ class PyMatplotlib(PythonPackage):
depends_on('py-python-dateutil@2.1:', type=('build', 'run'))
depends_on('py-kiwisolver@1.0.1:', type=('build', 'run'), when='@2.2.0:')
depends_on('py-pyparsing@2.0.3,2.0.5:2.1.1,2.1.3:2.1.5,2.1.7:', type=('build', 'run'))
depends_on('py-pillow@6.2.0:', when='@3.3:', type=('build', 'run'))
depends_on('pil@6.2.0:', when='@3.3:', type=('build', 'run'))
depends_on('py-pytz', type=('build', 'run'), when='@:2')
depends_on('py-subprocess32', type=('build', 'run'), when='^python@:2.7')
depends_on('py-functools32', type=('build', 'run'), when='@:2.0.999 ^python@:2.7')
@ -127,7 +127,7 @@ class PyMatplotlib(PythonPackage):
# Optional dependencies
depends_on('ffmpeg', when='+movies')
depends_on('imagemagick', when='+animation')
depends_on('py-pillow@3.4:', when='+image', type=('build', 'run'))
depends_on('pil@3.4:', when='+image', type=('build', 'run'))
depends_on('texlive', when='+latex', type='run')
depends_on('ghostscript@0.9:', when='+latex', type='run')
depends_on('fontconfig@2.7:', when='+fonts')

View File

@ -19,4 +19,4 @@ class PyOpenslidePython(PythonPackage):
depends_on('openslide@3.4.0:')
depends_on('python@2.6:2.8,3.3:')
depends_on('py-setuptools', type='build')
depends_on('py-pillow+jpeg+jpeg2000+tiff', type=('build', 'run'))
depends_on('py-pillow-simd+jpeg+jpeg2000+tiff', type=('build', 'run'))

View File

@ -18,4 +18,4 @@ class PyPauvre(PythonPackage):
depends_on('py-matplotlib', type=('build', 'run'))
depends_on('py-biopython', type=('build', 'run'))
depends_on('py-pandas', type=('build', 'run'))
depends_on('py-pillow', type=('build', 'run'))
depends_on('pil', type=('build', 'run'))

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class PyPil(PythonPackage):
"""The Python Imaging Library (PIL) adds image processing capabilities
@ -17,7 +15,8 @@ class PyPil(PythonPackage):
version('1.1.7', sha256='895bc7c2498c8e1f9b99938f1a40dc86b3f149741f105cf7c7bd2e0725405211')
provides('pil')
provides('pil@1.1.7', when='@1.1.7')
# py-pil currently only works with Python2.
# If you are using Python 3, try using py-pillow instead.
depends_on('python@1.5.2:2.8')
depends_on('python@1.5.2:2.8', type=('build', 'run'))

View File

@ -0,0 +1,21 @@
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.pkg.builtin.py_pillow import PyPillowBase
class PyPillowSimd(PyPillowBase):
"""Pillow-SIMD is a SIMD-enabled fork of Pillow. It is usually 4-6x
faster than the original Pillow in image processing benchmarks."""
# See https://github.com/spack/spack/pull/15566
_name = 'py-pillow-simd'
homepage = "https://github.com/uploadcare/pillow-simd"
url = "https://pypi.io/packages/source/P/Pillow-SIMD/Pillow-SIMD-7.0.0.post3.tar.gz"
version('7.0.0.post3', sha256='c27907af0e7ede1ceed281719e722e7dbf3e1dbfe561373978654a6b64896cb7')
for ver in ['7.0.0.post3']:
provides('pil@' + ver, when='@' + str(Version(ver).up_to(3)))

View File

@ -3,32 +3,12 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class PyPillow(PythonPackage):
"""Pillow is a fork of the Python Imaging Library (PIL). It adds image
processing capabilities to your Python interpreter. This library supports
many file formats, and provides powerful image processing and graphics
capabilities."""
homepage = "https://python-pillow.org/"
url = "https://pypi.io/packages/source/P/Pillow/Pillow-7.2.0.tar.gz"
class PyPillowBase(PythonPackage):
"""Base class for Pillow and its fork Pillow-SIMD."""
maintainers = ['adamjstewart']
import_modules = ['PIL']
version('7.2.0', sha256='97f9e7953a77d5a70f49b9a48da7776dc51e9b738151b22dacf101641594a626')
version('7.0.0', sha256='4d9ed9a64095e031435af120d3c910148067087541131e82b3e8db302f4c8946')
version('6.2.2', sha256='db9ff0c251ed066d367f53b64827cc9e18ccea001b986d08c265e53625dab950')
version('6.2.1', sha256='bf4e972a88f8841d8fdc6db1a75e0f8d763e66e3754b03006cbc3854d89f1cb1')
version('6.2.0', sha256='4548236844327a718ce3bb182ab32a16fa2050c61e334e959f554cac052fb0df')
version('6.0.0', sha256='809c0a2ce9032cbcd7b5313f71af4bdc5c8c771cb86eb7559afd954cab82ebb5')
version('5.4.1', sha256='5233664eadfa342c639b9b9977190d64ad7aca4edc51a966394d7e08e7f38a9f')
version('5.1.0', sha256='cee9bc75bff455d317b6947081df0824a8f118de2786dc3d74a3503fd631f4ef')
version('3.2.0', sha256='64b0a057210c480aea99406c9391180cd866fc0fd8f0b53367e3af21b195784a')
version('3.0.0', sha256='ad50bef540fe5518a4653c3820452a881b6a042cb0f8bb7657c491c6bd3654bb')
provides('pil')
# These defaults correspond to Pillow defaults
@ -73,6 +53,8 @@ class PyPillow(PythonPackage):
depends_on('libxcb', when='+xcb')
conflicts('+webpmux', when='~webp', msg='Webpmux relies on WebP support')
conflicts('+imagequant', when='@:3.2', msg='imagequant support was added in 3.3')
conflicts('+xcb', when='@:7.0', msg='XCB support was added in 7.1')
phases = ['build_ext', 'install']
@ -93,15 +75,21 @@ def patch(self):
setup.filter('include_dirs = []',
'include_dirs = {0}'.format(include_dirs), string=True)
def variant_to_cfg(setup):
def variant_to_cfg(variant):
able = 'enable' if '+' + variant in self.spec else 'disable'
return '{0}-{1}=1\n'.format(able, variant)
with open('setup.cfg', 'a') as setup:
# Default backend
setup.write('[build_ext]\n')
for variant in self.spec.variants.keys():
setup.write(variant_to_cfg(setup))
variants = list(self.spec.variants)
if self.spec.satisfies('@:7.0'):
variants.remove('xcb')
if self.spec.satisfies('@:3.2'):
variants.remove('imagequant')
for variant in variants:
setup.write(variant_to_cfg(variant))
setup.write('rpath={0}\n'.format(':'.join(self.rpath)))
setup.write('[install]\n')
@ -115,3 +103,30 @@ def setup_build_environment(self, env):
run_after('install')(
PythonPackage._run_default_install_time_test_callbacks)
run_after('install')(PythonPackage.sanity_check_prefix)
class PyPillow(PyPillowBase):
"""Pillow is a fork of the Python Imaging Library (PIL). It adds image
processing capabilities to your Python interpreter. This library supports
many file formats, and provides powerful image processing and graphics
capabilities."""
homepage = "https://python-pillow.org/"
url = "https://pypi.io/packages/source/P/Pillow/Pillow-7.2.0.tar.gz"
version('7.2.0', sha256='97f9e7953a77d5a70f49b9a48da7776dc51e9b738151b22dacf101641594a626')
version('7.0.0', sha256='4d9ed9a64095e031435af120d3c910148067087541131e82b3e8db302f4c8946')
version('6.2.2', sha256='db9ff0c251ed066d367f53b64827cc9e18ccea001b986d08c265e53625dab950')
version('6.2.1', sha256='bf4e972a88f8841d8fdc6db1a75e0f8d763e66e3754b03006cbc3854d89f1cb1')
version('6.2.0', sha256='4548236844327a718ce3bb182ab32a16fa2050c61e334e959f554cac052fb0df')
version('6.0.0', sha256='809c0a2ce9032cbcd7b5313f71af4bdc5c8c771cb86eb7559afd954cab82ebb5')
version('5.4.1', sha256='5233664eadfa342c639b9b9977190d64ad7aca4edc51a966394d7e08e7f38a9f')
version('5.1.0', sha256='cee9bc75bff455d317b6947081df0824a8f118de2786dc3d74a3503fd631f4ef')
version('3.2.0', sha256='64b0a057210c480aea99406c9391180cd866fc0fd8f0b53367e3af21b195784a')
version('3.0.0', sha256='ad50bef540fe5518a4653c3820452a881b6a042cb0f8bb7657c491c6bd3654bb')
for ver in [
'7.2.0', '7.0.0', '6.2.2', '6.2.1', '6.2.0', '6.0.0',
'5.4.1', '5.1.0', '3.2.0', '3.0.0'
]:
provides('pil@' + ver, when='@' + ver)

View File

@ -26,7 +26,7 @@ class PyPycbc(PythonPackage):
depends_on('py-decorator@3.4.2:', type=('build', 'run'))
depends_on('py-scipy@0.16.0:', type=('build', 'run'))
depends_on('py-matplotlib@1.5.1:', type=('build', 'run'))
depends_on('py-pillow', type=('build', 'run'))
depends_on('pil', type=('build', 'run'))
depends_on('py-h5py@2.5:', type=('build', 'run'))
depends_on('py-jinja2', type=('build', 'run'))
depends_on('py-astropy@2.0.3:', type=('build', 'run'))

View File

@ -19,7 +19,7 @@ class PyScikitImage(PythonPackage):
extends('python', ignore=r'bin/.*\.py$')
depends_on('py-dask', type=('build', 'run'))
depends_on('py-pillow', type=('build', 'run'))
depends_on('pil', type=('build', 'run'))
depends_on('py-networkx', type=('build', 'run'))
depends_on('py-six', type=('build', 'run'))
depends_on('py-numpy', type=('build', 'run'))

View File

@ -19,5 +19,5 @@ class PySphinxGallery(PythonPackage):
depends_on('py-setuptools')
depends_on('py-matplotlib')
depends_on('py-pillow')
depends_on('pil')
depends_on('py-sphinx')

View File

@ -60,8 +60,8 @@ class PyTorchvision(PythonPackage):
# * libjpeg
# https://github.com/pytorch/vision/issues/1712
depends_on('py-pillow@4.1.1:6', when='@:0.4', type=('build', 'run'))
depends_on('py-pillow@4.1.1:', when='@0.5:', type=('build', 'run'))
depends_on('pil@4.1.1:6', when='@:0.4', type=('build', 'run'))
depends_on('pil@4.1.1:', when='@0.5:', type=('build', 'run'))
# Many of the datasets require additional dependencies to use.
# These can be installed after the fact.

View File

@ -34,5 +34,5 @@ class PyWxpython(PythonPackage):
# Needed at runtime
depends_on('py-numpy', type='run')
depends_on('py-pillow', type='run')
depends_on('pil', type='run')
depends_on('py-six', type='run')

View File

@ -93,7 +93,7 @@ class Timemory(CMakePackage):
extends('python', when='+python')
depends_on('python@3:', when='+python', type=('build', 'run'))
depends_on('py-numpy', when='+python', type=('run'))
depends_on('py-pillow', when='+python', type=('run'))
depends_on('pil', when='+python', type=('run'))
depends_on('py-matplotlib', when='+python', type=('run'))
depends_on('py-mpi4py', when='+python+mpi', type=('run'))
depends_on('py-cython', when='+python', type=('build'))