Magics with eccodes variant (#4320)

* magics: use filter_file to avoid using system python in all versions

* magics: add eccodes variant to switch between eccodes and grib-api
This commit is contained in:
Milton Woods
2017-05-24 01:06:59 +10:00
committed by Adam J. Stewart
parent 1469cfd0e7
commit 4553b1400c
2 changed files with 15 additions and 16 deletions

View File

@@ -1,5 +0,0 @@
--- a/tools/xml2mv.py 2016-06-27 17:49:27.000000000 +0200
+++ a/tools/xml2mv.py 2016-09-13 16:25:17.246960456 +0200
@@ -1 +1 @@
-#!/usr/bin/python
+#!/usr/bin/env python

View File

@@ -41,10 +41,6 @@ class Magics(Package):
version('2.29.4', '91c561f413316fb665b3bb563f3878d1')
version('2.29.0', 'db20a4d3c51a2da5657c31ae3de59709', preferred=True)
# The patch changes the hardcoded path to python in shebang to enable the
# usage of the first python installation that appears in $PATH
patch('no_hardcoded_python.patch', when='@:2.29.6')
# The patch reorders includes and adds namespaces where necessary to
# resolve ambiguity of invocations of isnan and isinf functions. The
# patch is not needed since the version 2.29.1
@@ -55,6 +51,7 @@ class Magics(Package):
variant('cairo', default=True, description='Enable cairo support[png/jpeg]')
variant('metview', default=False, description='Enable metview support')
variant('qt', default=False, description='Enable metview support with qt')
variant('eccodes', default=False, description='Use eccodes instead of grib-api')
depends_on('cmake', type='build')
depends_on('pkg-config', type='build')
@@ -64,8 +61,8 @@ class Magics(Package):
depends_on('python', type='build')
depends_on('perl', type='build')
depends_on('perl-xml-parser', type='build')
depends_on('eccodes', when='@2.30.0:')
depends_on('grib-api', when='@:2.29.6')
depends_on('eccodes', when='+eccodes')
depends_on('grib-api', when='~eccodes')
depends_on('proj')
depends_on('boost')
depends_on('expat')
@@ -74,9 +71,14 @@ class Magics(Package):
depends_on('libemos', when='+bufr')
depends_on('qt', when='+metview+qt')
conflicts('+eccodes', when='@:2.29.0')
# Replace system python and perl by spack versions:
def patch(self):
for plfile in glob.glob('*/*.pl'):
filter_file('#!/usr/bin/perl', '#!/usr/bin/env perl', plfile)
for pyfile in glob.glob('*/*.py'):
filter_file('#!/usr/bin/python', '#!/usr/bin/env python', pyfile)
def install(self, spec, prefix):
options = []
@@ -87,11 +89,6 @@ def install(self, spec, prefix):
options.append('-DPROJ4_PATH=%s' % spec['proj'].prefix)
options.append('-DENABLE_TESTS=OFF')
if self.version >= Version('2.30.0'):
options.append('-DECCODES_PATH=%s' % spec['eccodes'].prefix)
else:
options.append('-DGRIB_API_PATH=%s' % spec['grib-api'].prefix)
if '+bufr' in spec:
options.append('-DENABLE_BUFR=ON')
options.append('-DLIBEMOS_PATH=%s' % spec['libemos'].prefix)
@@ -119,6 +116,13 @@ def install(self, spec, prefix):
else:
options.append('-DENABLE_METVIEW=OFF')
if '+eccodes' in spec:
options.append('-DENABLE_ECCODES=ON')
options.append('-DECCODES_PATH=%s' % spec['eccodes'].prefix)
else:
options.append('-DENABLE_ECCODES=OFF')
options.append('-DGRIB_API_PATH=%s' % spec['grib-api'].prefix)
if (self.compiler.f77 is None) or (self.compiler.fc is None):
options.append('-DENABLE_FORTRAN=OFF')