Skip to content
Snippets Groups Projects
Commit 451bfbd1 authored by Neil Flood's avatar Neil Flood Committed by Adam J. Stewart
Browse files

py-pynio: new package (#10074)

* py-pynio: new package

* Major re-working to add some of the optional dependencies, and make it conform to the approach described in the pynio setup.py comments. Much of it turned out to be too complicated, and I have added some notes in comments to explain this to future adventurers.

* Added variants for the hdf5 and gdal dependencies, which do seem to be genuinely optional. Also added absolute dependencies for jpeg and zlib, which setup.py says it wants, but were being found as the os-installed versions.

* Added descriptions for the new variants, and moved them to above the dependencies
parent 93d9139f
No related branches found
No related tags found
No related merge requests found
# Copyright 2013-2018 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 import *
class PyPynio(PythonPackage):
"""PyNIO ("pie-nee-oh") is a Python module that allows read and/or
write access to a variety of scientific data formats popular in
climate and weather"""
homepage = "https://www.pyngl.ucar.edu/Nio.shtml"
url = "https://github.com/NCAR/pynio/archive/1.5.4.tar.gz"
version('1.5.4', sha256='e5bb57d902740d25e4781a9f89e888149f55f2ffe60f9a5ad71069f017c89e1a')
variant('hdf5', default=False, description='Include HDF5 support')
variant('gdal', default=False, description='Include GDAL support')
# The setup.py claims it requires these abolutely.
depends_on('libpng')
depends_on('jpeg')
depends_on('zlib')
# Spack does not currently have netcdf below 4.x, and 3.x is a
# fundamentally different format. So, currently this is only providing
# support for netcdf4.
depends_on('netcdf@3.6.0:')
# Turning on the hdf (i.e. hdf4) dependency causes it not to build, with
# compile errors that (weirdly) relate to the declarations of HDF5.
# Very odd, so I have put it in as a comment, for some brave soul to take
# on later.
# depends_on('hdf', when='+hdf4')
# This one works, though.
depends_on('hdf5', when='+hdf5')
# Turning on the GDAL dependency apparently forces it to link with
# -ljasper, meaning that really it depends on gdal+jasper. In my view
# it should not need this unless one were specifically using PyNio to
# use GDAL to read JPEG-2000 files, but it seems to be hard-wired
# in PyNio's setup.py.
depends_on('gdal+jasper', when='+gdal')
# I have left off a few other optional dependencies, as they are not yet
# in Spack. HDFEOS, HDFEOS5, GRIB. See the pynio setup.py for details.
depends_on('py-numpy', type=('build', 'run'))
def setup_environment(self, spack_env, run_env):
"""
These environment variables are how the setup.py knows which options
to turn on, and how to find them.
"""
spack_env.set('F2CLIBS', 'gfortran')
spack_env.set('HAS_NETCDF4', '1')
spack_env.set('NETCDF4_PREFIX', self.spec['netcdf'].prefix)
if '+hdf5' in self.spec:
spack_env.set('HAS_HDF5', '1')
spack_env.set('HDF5_PREFIX', self.spec['hdf5'].prefix)
if '+gdal' in self.spec:
spack_env.set('HAS_GDAL', '1')
spack_env.set('GDAL_PREFIX', self.spec['gdal'].prefix)
# This one is trouble - see comments above.
# if '+hdf4' in self.spec:
# spack_env.set('HAS_HDF4', '1')
# spack_env.set('HDF4_PREFIX', self.spec['hdf'].prefix)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment