From b072caadeced9ed1eda97825d9242849294f7362 Mon Sep 17 00:00:00 2001 From: Andrew W Elble Date: Thu, 30 Jan 2020 15:42:48 -0500 Subject: fix: py-pillow build_ext vs. install (#14666) Previously, the install stage would compile in things that were disabled during the build_ext phase. This would also result in the build pulling in locally installed versions of libraries that were disabled. The install process doesn't honor the same command-line flags that build_ext does, but does call build_ext again. Avoid the whole issue by just writing the options to setup.cfg Also, add the Imagemagick dependency for tests. --- .../repos/builtin/packages/py-pillow/package.py | 35 ++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/var/spack/repos/builtin/packages/py-pillow/package.py b/var/spack/repos/builtin/packages/py-pillow/package.py index 9f537d3138..36d99f2c01 100644 --- a/var/spack/repos/builtin/packages/py-pillow/package.py +++ b/var/spack/repos/builtin/packages/py-pillow/package.py @@ -61,6 +61,7 @@ class PyPillow(PythonPackage): depends_on('libwebp', when='+webp') depends_on('libwebp+libwebpmux+libwebpdemux', when='+webpmux') depends_on('openjpeg', when='+jpeg2000') + depends_on('imagemagick', type='test') # Spack does not (yet) support these modes of building # depends_on('libimagequant', when='+imagequant') @@ -86,21 +87,25 @@ class PyPillow(PythonPackage): setup.filter('include_dirs = []', 'include_dirs = {0}'.format(include_dirs), string=True) - def build_ext_args(self, spec, prefix): - def variant_to_flag(variant): - able = 'enable' if '+' + variant in spec else 'disable' - return '--{0}-{1}'.format(able, variant) - - args = ['--enable-zlib', '--enable-jpeg'] - - 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 + def variant_to_cfg(setup): + 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') + setup.write('enable-zlib=1\n') + setup.write('enable-jpeg=1\n') + variants = ['tiff', 'freetype', 'lcms', 'webp', + 'webpmux', 'jpeg2000'] + for variant in variants: + setup.write(variant_to_cfg(setup)) + + # Spack does not (yet) support these modes of building + setup.write('disable-imagequant=1\n') + + setup.write('rpath={0}\n'.format(':'.join(self.rpath))) + setup.write('[install]\n') # Tests need to be re-added since `phases` was overridden run_after('build_ext')( -- cgit v1.2.3-70-g09d2