Skip to content

Commit e41d67e

Browse files
authored
Merge pull request #1078 from adamjstewart/features/pillow
Allow py-pillow to link to Spack-built libraries
2 parents 8b5467e + a7ffb2c commit e41d67e

File tree

5 files changed

+95
-52
lines changed

5 files changed

+95
-52
lines changed

var/spack/repos/builtin/packages/openjpeg/package.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
##############################################################################
2525
from spack import *
2626

27+
2728
class Openjpeg(Package):
2829
"""
2930
OpenJPEG is an open-source JPEG 2000 codec written in C language.
@@ -36,12 +37,13 @@ class Openjpeg(Package):
3637
homepage = "https://github.com/uclouvain/openjpeg"
3738
url = "https://github.com/uclouvain/openjpeg/archive/version.2.1.tar.gz"
3839

39-
version('2.1' , '3e1c451c087f8462955426da38aa3b3d')
40+
version('2.1', '3e1c451c087f8462955426da38aa3b3d')
4041
version('2.0.1', '105876ed43ff7dbb2f90b41b5a43cfa5')
41-
version('2.0' , 'cdf266530fee8af87454f15feb619609')
42+
version('2.0', 'cdf266530fee8af87454f15feb619609')
4243
version('1.5.2', '545f98923430369a6b046ef3632ef95c')
4344
version('1.5.1', 'd774e4b5a0db5f0f171c4fc0aabfa14e')
4445

46+
depends_on('cmake')
4547

4648
def install(self, spec, prefix):
4749
cmake('.', *std_cmake_args)

var/spack/repos/builtin/packages/py-basemap/package.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2424
##############################################################################
2525
from spack import *
26-
import os
26+
2727

2828
class PyBasemap(Package):
29-
"""The matplotlib basemap toolkit is a library for plotting 2D data on maps in Python."""
29+
"""The matplotlib basemap toolkit is a library for plotting
30+
2D data on maps in Python."""
31+
3032
homepage = "http://matplotlib.org/basemap/"
3133
url = "https://downloads.sourceforge.net/project/matplotlib/matplotlib-toolkits/basemap-1.0.7/basemap-1.0.7.tar.gz"
3234

@@ -36,7 +38,7 @@ class PyBasemap(Package):
3638
depends_on('py-setuptools')
3739
depends_on('py-numpy')
3840
depends_on('py-matplotlib+gui')
39-
depends_on('py-pillow')
41+
depends_on('pil')
4042
depends_on("geos")
4143

4244
def install(self, spec, prefix):

var/spack/repos/builtin/packages/py-pil/package.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@
2424
##############################################################################
2525
from spack import *
2626

27+
2728
class PyPil(Package):
28-
"""The Python Imaging Library (PIL) adds image processing capabilities to your Python interpreter. This library supports many file formats, and provides powerful image processing and graphics capabilities."""
29+
"""The Python Imaging Library (PIL) adds image processing capabilities
30+
to your Python interpreter. This library supports many file formats,
31+
and provides powerful image processing and graphics capabilities."""
2932

3033
homepage = "http://www.pythonware.com/products/pil/"
3134
url = "http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz"
3235

3336
version('1.1.7', 'fc14a54e1ce02a0225be8854bfba478e')
3437

38+
provides('pil')
39+
3540
extends('python')
3641

3742
def install(self, spec, prefix):

var/spack/repos/builtin/packages/py-pillow/package.py

Lines changed: 75 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,77 +23,108 @@
2323
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2424
##############################################################################
2525
from spack import *
26-
import os
26+
2727

2828
class PyPillow(Package):
29-
"""Pillow is the friendly PIL fork by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lundh and Contributors. The Python Imaging Library (PIL) adds image processing capabilities to your Python interpreter. This library supports many file formats, and provides powerful image processing and graphics capabilities."""
29+
"""Pillow is a fork of the Python Imaging Library (PIL). It adds image
30+
processing capabilities to your Python interpreter. This library supports
31+
many file formats, and provides powerful image processing and graphics
32+
capabilities."""
3033

31-
homepage = "https://python-pillow.github.io/"
34+
homepage = "https://python-pillow.org/"
3235
url = "https://pypi.python.org/packages/source/P/Pillow/Pillow-3.0.0.tar.gz"
3336

37+
# TODO: This version should be deleted once the next release comes out.
38+
# TODO: It fixes a bug that prevented us from linking to Tk/Tcl.
39+
# TODO: Tk/Tcl support is necessary for tkinter bitmap and photo images.
40+
# TODO: If you require this support, run the following command:
41+
# TODO: `spack install [email protected] ^python+tk`
42+
version('3.3.0.dev0', git='https://github.com/python-pillow/Pillow.git',
43+
commit='30eced62868141a6c859a4370efd40b9434a7c3f')
44+
45+
version('3.2.0', '7cfd093c11205d9e2ebe3c51dfcad510', preferred=True)
3446
version('3.0.0', 'fc8ac44e93da09678eac7e30c9b7377d')
35-
provides('PIL')
47+
48+
provides('pil')
3649

3750
# These defaults correspond to Pillow defaults
3851
variant('jpeg', default=True, description='Provide JPEG functionality')
3952
variant('zlib', default=True, description='Access to compressed PNGs')
4053
variant('tiff', default=False, description='Access to TIFF files')
4154
variant('freetype', default=False, description='Font related services')
42-
variant('tk', default=False, description='Support for tkinter bitmap and photo images')
4355
variant('lcms', default=False, description='Color management')
56+
variant('jpeg2000', default=False, description='Provide JPEG 2000 functionality')
4457

4558
# Spack does not (yet) support these modes of building
46-
# variant('webp', default=False, description='')
47-
# variant('webpmux', default=False, description='')
48-
# variant('jpeg2000', default=False, description='')
59+
# variant('webp', default=False, description='Provide the WebP format')
60+
# variant('webpmux', default=False, description='WebP metadata, relies on WebP support') # NOQA: ignore=E501
61+
# variant('imagequant', default=False, description='Provide improved color quantization') # NOQA: ignore=E501
4962

63+
# Required dependencies
5064
extends('python')
5165
depends_on('binutils')
5266
depends_on('py-setuptools')
5367

54-
depends_on('jpeg', when='+jpeg') # BUG: It will use the system libjpeg anyway
68+
# Recommended dependencies
69+
depends_on('jpeg', when='+jpeg')
5570
depends_on('zlib', when='+zlib')
56-
depends_on('tiff', when='+tiff')
71+
72+
# Optional dependencies
73+
depends_on('libtiff', when='+tiff')
5774
depends_on('freetype', when='+freetype')
5875
depends_on('lcms', when='+lcms')
59-
depends_on('tcl', when='+tk')
60-
depends_on('tk', when='+tk')
76+
depends_on('openjpeg', when='+jpeg2000')
6177

62-
def install(self, spec, prefix):
63-
libpath=[]
78+
# Spack does not (yet) support these modes of building
79+
# depends_on('webp', when='+webp')
80+
# depends_on('webpmux', when='+webpmux')
81+
# depends_on('imagequant', when='+imagequant')
82+
83+
def patch(self):
84+
"""Patch setup.py to provide lib and include directories
85+
for dependencies."""
86+
87+
spec = self.spec
88+
setup = FileFilter('setup.py')
6489

6590
if '+jpeg' in spec:
66-
libpath.append(join_path(spec['jpeg'].prefix, 'lib'))
91+
setup.filter('JPEG_ROOT = None',
92+
'JPEG_ROOT = ("{0}", "{1}")'.format(
93+
spec['jpeg'].prefix.lib,
94+
spec['jpeg'].prefix.include))
6795
if '+zlib' in spec:
68-
libpath.append(join_path(spec['zlib'].prefix, 'lib'))
96+
setup.filter('ZLIB_ROOT = None',
97+
'ZLIB_ROOT = ("{0}", "{1}")'.format(
98+
spec['zlib'].prefix.lib,
99+
spec['zlib'].prefix.include))
69100
if '+tiff' in spec:
70-
libpath.append(join_path(spec['tiff'].prefix, 'lib'))
101+
setup.filter('TIFF_ROOT = None',
102+
'TIFF_ROOT = ("{0}", "{1}")'.format(
103+
spec['libtiff'].prefix.lib,
104+
spec['libtiff'].prefix.include))
71105
if '+freetype' in spec:
72-
libpath.append(join_path(spec['freetype'].prefix, 'lib'))
106+
setup.filter('FREETYPE_ROOT = None',
107+
'FREETYPE_ROOT = ("{0}", "{1}")'.format(
108+
spec['freetype'].prefix.lib,
109+
spec['freetype'].prefix.include))
73110
if '+lcms' in spec:
74-
libpath.append(join_path(spec['lcms'].prefix, 'lib'))
75-
76-
# This has not been tested, and likely needs some other treatment.
77-
#if '+tk' in spec:
78-
# libpath.append(join_path(spec['tcl'].prefix, 'lib'))
79-
# libpath.append(join_path(spec['tk'].prefix, 'lib'))
80-
81-
# -------- Building
82-
cmd = ['build_ext',
83-
'--%s-jpeg' % ('enable' if '+jpeg' in spec else 'disable'),
84-
'--%s-zlib' % ('enable' if '+zlib' in spec else 'disable'),
85-
'--%s-tiff' % ('enable' if '+tiff' in spec else 'disable'),
86-
'--%s-freetype' % ('enable' if '+freetype' in spec else 'disable'),
87-
'--%s-lcms' % ('enable' if '+lcms' in spec else 'disable'),
88-
'-L'+':'.join(libpath) # NOTE: This does not make it find libjpeg
89-
]
90-
91-
#if '+tk' in spec:
92-
# cmd.extend(['--enable-tcl', '--enable-tk'])
93-
#else:
94-
# cmd.extend(['--disable-tcl', '--disable-tk'])
95-
96-
# --------- Installation
97-
cmd.extend(['install', '--prefix=%s' % prefix])
98-
99-
python('setup.py', *cmd)
111+
setup.filter('LCMS_ROOT = None',
112+
'LCMS_ROOT = ("{0}", "{1}")'.format(
113+
spec['lcms'].prefix.lib,
114+
spec['lcms'].prefix.include))
115+
if '+jpeg2000' in spec:
116+
setup.filter('JPEG2K_ROOT = None',
117+
'JPEG2K_ROOT = ("{0}", "{1}")'.format(
118+
spec['openjpeg'].prefix.lib,
119+
spec['openjpeg'].prefix.include))
120+
121+
def install(self, spec, prefix):
122+
def variant_to_flag(variant):
123+
able = 'enable' if '+{0}'.format(variant) in spec else 'disable'
124+
return '--{0}-{1}'.format(able, variant)
125+
126+
variants = ['jpeg', 'zlib', 'tiff', 'freetype', 'lcms', 'jpeg2000']
127+
build_args = list(map(variant_to_flag, variants))
128+
129+
python('setup.py', 'build_ext', *build_args)
130+
python('setup.py', 'install', '--prefix={0}'.format(prefix))

var/spack/repos/builtin/packages/py-scikit-image/package.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@
2424
##############################################################################
2525
from spack import *
2626

27+
2728
class PyScikitImage(Package):
28-
"""Image processing algorithms for SciPy, including IO, morphology, filtering, warping, color manipulation, object detection, etc."""
29+
"""Image processing algorithms for SciPy, including IO, morphology,
30+
filtering, warping, color manipulation, object detection, etc."""
31+
2932
homepage = "http://scikit-image.org/"
3033
url = "https://pypi.python.org/packages/source/s/scikit-image/scikit-image-0.12.3.tar.gz"
3134

@@ -34,7 +37,7 @@ class PyScikitImage(Package):
3437
extends('python', ignore=r'bin/.*\.py$')
3538

3639
depends_on('py-dask')
37-
depends_on('py-pillow')
40+
depends_on('pil')
3841
depends_on('py-networkx')
3942
depends_on('py-six')
4043
depends_on('py-scipy')

0 commit comments

Comments
 (0)