Overhaul py-pillow package (#14385)
* Overhaul py-pillow package * Fix bug where zlib and jpeg were always disabled
This commit is contained in:
parent
f0532e27da
commit
f7f4d1a02e
1 changed files with 54 additions and 51 deletions
|
@ -4,7 +4,6 @@
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
|
||||||
from spack import *
|
from spack import *
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
class PyPillow(PythonPackage):
|
class PyPillow(PythonPackage):
|
||||||
|
@ -14,8 +13,14 @@ class PyPillow(PythonPackage):
|
||||||
capabilities."""
|
capabilities."""
|
||||||
|
|
||||||
homepage = "https://python-pillow.org/"
|
homepage = "https://python-pillow.org/"
|
||||||
url = "https://pypi.io/packages/source/P/Pillow/Pillow-6.2.0.tar.gz"
|
url = "https://pypi.io/packages/source/P/Pillow/Pillow-7.0.0.tar.gz"
|
||||||
|
|
||||||
|
maintainers = ['adamjstewart']
|
||||||
|
import_modules = ['PIL']
|
||||||
|
|
||||||
|
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.2.0', sha256='4548236844327a718ce3bb182ab32a16fa2050c61e334e959f554cac052fb0df')
|
||||||
version('5.4.1', sha256='5233664eadfa342c639b9b9977190d64ad7aca4edc51a966394d7e08e7f38a9f')
|
version('5.4.1', sha256='5233664eadfa342c639b9b9977190d64ad7aca4edc51a966394d7e08e7f38a9f')
|
||||||
version('5.1.0', sha256='cee9bc75bff455d317b6947081df0824a8f118de2786dc3d74a3503fd631f4ef')
|
version('5.1.0', sha256='cee9bc75bff455d317b6947081df0824a8f118de2786dc3d74a3503fd631f4ef')
|
||||||
|
@ -25,81 +30,79 @@ class PyPillow(PythonPackage):
|
||||||
provides('pil')
|
provides('pil')
|
||||||
|
|
||||||
# These defaults correspond to Pillow defaults
|
# These defaults correspond to Pillow defaults
|
||||||
variant('tiff', default=False, description='Access to TIFF files')
|
# https://pillow.readthedocs.io/en/stable/installation.html#external-libraries
|
||||||
variant('freetype', default=False, description='Font related services')
|
variant('tiff', default=False, description='Compressed TIFF functionality')
|
||||||
|
variant('freetype', default=False, description='Type related services')
|
||||||
variant('lcms', default=False, description='Color management')
|
variant('lcms', default=False, description='Color management')
|
||||||
variant('jpeg2000', default=False, description='Provide JPEG 2000 functionality')
|
variant('webp', default=False, description='WebP format')
|
||||||
|
variant('webpmux', default=False, description='WebP metadata')
|
||||||
|
variant('jpeg2000', default=False, description='JPEG 2000 functionality')
|
||||||
|
|
||||||
# Spack does not (yet) support these modes of building
|
# Spack does not (yet) support these modes of building
|
||||||
# variant('webp', default=False, description='Provide the WebP format')
|
|
||||||
# variant('webpmux', default=False,
|
|
||||||
# description='WebP metadata, relies on WebP support')
|
|
||||||
# variant('imagequant', default=False,
|
# variant('imagequant', default=False,
|
||||||
# description='Provide improved color quantization')
|
# description='Improved color quantization')
|
||||||
|
|
||||||
# Required dependencies
|
# Required dependencies
|
||||||
depends_on('binutils', type='build', when=sys.platform != 'darwin')
|
depends_on('python@2.6:2.8,3.2:', when='@3:', type=('build', 'run'))
|
||||||
depends_on('python@2.7:2.8,3.4:', when='@:5.4.1', type=('build', 'run'))
|
depends_on('python@2.7:2.8,3.3:', when='@4:', type=('build', 'run'))
|
||||||
|
depends_on('python@2.7:2.8,3.4:', when='@5:', type=('build', 'run'))
|
||||||
depends_on('python@2.7:2.8,3.5:', when='@6:', type=('build', 'run'))
|
depends_on('python@2.7:2.8,3.5:', when='@6:', type=('build', 'run'))
|
||||||
|
depends_on('python@3.5:', when='@7:', type=('build', 'run'))
|
||||||
depends_on('py-setuptools', type='build')
|
depends_on('py-setuptools', type='build')
|
||||||
depends_on('jpeg')
|
|
||||||
depends_on('zlib')
|
depends_on('zlib')
|
||||||
|
depends_on('jpeg')
|
||||||
|
depends_on('py-pytest', type='test')
|
||||||
|
depends_on('py-pytest-runner', type='test')
|
||||||
|
|
||||||
# Optional dependencies
|
# Optional dependencies
|
||||||
depends_on('libtiff', when='+tiff')
|
depends_on('libtiff', when='+tiff')
|
||||||
depends_on('freetype', when='+freetype')
|
depends_on('freetype', when='+freetype')
|
||||||
depends_on('lcms', when='+lcms')
|
depends_on('lcms@2:', when='+lcms')
|
||||||
|
depends_on('libwebp', when='+webp')
|
||||||
|
depends_on('libwebp+libwebpmux+libwebpdemux', when='+webpmux')
|
||||||
depends_on('openjpeg', when='+jpeg2000')
|
depends_on('openjpeg', when='+jpeg2000')
|
||||||
|
|
||||||
# Spack does not (yet) support these modes of building
|
# Spack does not (yet) support these modes of building
|
||||||
# depends_on('webp', when='+webp')
|
# depends_on('libimagequant', when='+imagequant')
|
||||||
# depends_on('webpmux', when='+webpmux')
|
|
||||||
# depends_on('imagequant', when='+imagequant')
|
conflicts('+webpmux', when='~webp', msg='Webpmux relies on WebP support')
|
||||||
|
|
||||||
phases = ['build_ext', 'install']
|
phases = ['build_ext', 'install']
|
||||||
|
|
||||||
def patch(self):
|
def patch(self):
|
||||||
"""Patch setup.py to provide lib and include directories
|
"""Patch setup.py to provide library and include directories
|
||||||
for dependencies."""
|
for dependencies."""
|
||||||
|
|
||||||
spec = self.spec
|
library_dirs = []
|
||||||
setup = FileFilter('setup.py')
|
include_dirs = []
|
||||||
|
for dep in self.spec.dependencies(deptype='link'):
|
||||||
|
query = self.spec[dep.name]
|
||||||
|
library_dirs.extend(query.libs.directories)
|
||||||
|
include_dirs.extend(query.headers.directories)
|
||||||
|
|
||||||
setup.filter('JPEG_ROOT = None',
|
setup = FileFilter('setup.py')
|
||||||
'JPEG_ROOT=("{0}","{1}")'.format(
|
setup.filter('library_dirs = []',
|
||||||
spec['jpeg'].libs.directories[0],
|
'library_dirs = {0}'.format(library_dirs), string=True)
|
||||||
spec['jpeg'].prefix.include))
|
setup.filter('include_dirs = []',
|
||||||
setup.filter('ZLIB_ROOT = None',
|
'include_dirs = {0}'.format(include_dirs), string=True)
|
||||||
'ZLIB_ROOT = ("{0}", "{1}")'.format(
|
|
||||||
spec['zlib'].prefix.lib,
|
|
||||||
spec['zlib'].prefix.include))
|
|
||||||
if '+tiff' in spec:
|
|
||||||
setup.filter('TIFF_ROOT = None',
|
|
||||||
'TIFF_ROOT = ("{0}", "{1}")'.format(
|
|
||||||
spec['libtiff'].prefix.lib,
|
|
||||||
spec['libtiff'].prefix.include))
|
|
||||||
if '+freetype' in spec:
|
|
||||||
setup.filter('FREETYPE_ROOT = None',
|
|
||||||
'FREETYPE_ROOT = ("{0}", "{1}")'.format(
|
|
||||||
spec['freetype'].prefix.lib,
|
|
||||||
spec['freetype'].prefix.include))
|
|
||||||
if '+lcms' in spec:
|
|
||||||
setup.filter('LCMS_ROOT = None',
|
|
||||||
'LCMS_ROOT = ("{0}", "{1}")'.format(
|
|
||||||
spec['lcms'].prefix.lib,
|
|
||||||
spec['lcms'].prefix.include))
|
|
||||||
if '+jpeg2000' in spec:
|
|
||||||
setup.filter('JPEG2K_ROOT = None',
|
|
||||||
'JPEG2K_ROOT = ("{0}", "{1}")'.format(
|
|
||||||
spec['openjpeg'].prefix.lib,
|
|
||||||
spec['openjpeg'].prefix.include))
|
|
||||||
|
|
||||||
def build_ext_args(self, spec, prefix):
|
def build_ext_args(self, spec, prefix):
|
||||||
def variant_to_flag(variant):
|
def variant_to_flag(variant):
|
||||||
able = 'enable' if '+{0}'.format(variant) in spec else 'disable'
|
able = 'enable' if '+' + variant in spec else 'disable'
|
||||||
return '--{0}-{1}'.format(able, variant)
|
return '--{0}-{1}'.format(able, variant)
|
||||||
|
|
||||||
variants = ['jpeg', 'zlib', 'tiff', 'freetype', 'lcms', 'jpeg2000']
|
args = ['--enable-zlib', '--enable-jpeg']
|
||||||
args = list(map(variant_to_flag, variants))
|
|
||||||
args.extend(['--rpath=%s' % ":".join(self.rpath)])
|
variants = ['tiff', 'freetype', 'lcms', 'webp', 'webpmux', 'jpeg2000']
|
||||||
|
args.extend(list(map(variant_to_flag, variants)))
|
||||||
|
|
||||||
|
# Spack does not (yet) support these modes of building
|
||||||
|
args.append('--disable-imagequant')
|
||||||
|
|
||||||
|
args.append('--rpath={0}'.format(':'.join(self.rpath)))
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
# Tests need to be re-added since `phases` was overridden
|
||||||
|
run_after('build_ext')(PythonPackage.test)
|
||||||
|
run_after('install')(PythonPackage.import_module_test)
|
||||||
|
run_after('install')(PythonPackage.sanity_check_prefix)
|
||||||
|
|
Loading…
Reference in a new issue