summaryrefslogtreecommitdiff
path: root/var/spack/repos/tutorial/packages/hdf5
diff options
context:
space:
mode:
authorChris White <white238@llnl.gov>2021-09-17 17:34:56 -0700
committerGitHub <noreply@github.com>2021-09-17 17:34:56 -0700
commit79ac572f21b7852f012e173dd98a898018291b09 (patch)
tree6f6c8f9a29a500f116d34251763d25758266951f /var/spack/repos/tutorial/packages/hdf5
parentb847bb72f0db53f8741876d7633cc46b5f855759 (diff)
downloadspack-79ac572f21b7852f012e173dd98a898018291b09.tar.gz
spack-79ac572f21b7852f012e173dd98a898018291b09.tar.bz2
spack-79ac572f21b7852f012e173dd98a898018291b09.tar.xz
spack-79ac572f21b7852f012e173dd98a898018291b09.zip
update tutorial version of hdf5 (#25368)
Diffstat (limited to 'var/spack/repos/tutorial/packages/hdf5')
-rw-r--r--var/spack/repos/tutorial/packages/hdf5/h5public-skip-mpicxx.patch11
-rw-r--r--var/spack/repos/tutorial/packages/hdf5/hdf5_1.8_gcc10.patch12
-rw-r--r--var/spack/repos/tutorial/packages/hdf5/package.py466
-rw-r--r--var/spack/repos/tutorial/packages/hdf5/test/dump.out45
-rw-r--r--var/spack/repos/tutorial/packages/hdf5/test/spack.h5bin0 -> 8928 bytes
5 files changed, 417 insertions, 117 deletions
diff --git a/var/spack/repos/tutorial/packages/hdf5/h5public-skip-mpicxx.patch b/var/spack/repos/tutorial/packages/hdf5/h5public-skip-mpicxx.patch
new file mode 100644
index 0000000000..d609345527
--- /dev/null
+++ b/var/spack/repos/tutorial/packages/hdf5/h5public-skip-mpicxx.patch
@@ -0,0 +1,11 @@
+--- a/src/H5public.h 2019-08-28 18:51:39.393781356 -0400
++++ b/src/H5public.h 2019-08-28 20:59:50.315181711 -0400
+@@ -57,6 +57,8 @@
+ # include <stddef.h>
+ #endif
+ #ifdef H5_HAVE_PARALLEL
++# define MPICH_SKIP_MPICXX 1
++# define OMPI_SKIP_MPICXX 1
+ # include <mpi.h>
+ #ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */
+ # include <mpio.h>
diff --git a/var/spack/repos/tutorial/packages/hdf5/hdf5_1.8_gcc10.patch b/var/spack/repos/tutorial/packages/hdf5/hdf5_1.8_gcc10.patch
new file mode 100644
index 0000000000..0de8c33c09
--- /dev/null
+++ b/var/spack/repos/tutorial/packages/hdf5/hdf5_1.8_gcc10.patch
@@ -0,0 +1,12 @@
+diff -Naur hdf5.orig/fortran/test/tH5T_F03.f90 hdf5/fortran/test/tH5T_F03.f90
+--- hdf5.orig/fortran/test/tH5T_F03.f90 2021-01-19 13:23:11.298000000 +0100
++++ hdf5/fortran/test/tH5T_F03.f90 2021-01-19 13:19:17.637000000 +0100
+@@ -1541,7 +1541,7 @@
+ INTEGER :: A, B, C, D
+ INTEGER :: Aw, Bw, Cw, Dw
+ INTEGER :: i, j
+- INTEGER, PARAMETER :: hex = Z'00000003'
++ INTEGER, PARAMETER :: hex = INT(Z'00000003')
+ TYPE(C_PTR) :: f_ptr
+ INTEGER :: error ! Error flag
+ !
diff --git a/var/spack/repos/tutorial/packages/hdf5/package.py b/var/spack/repos/tutorial/packages/hdf5/package.py
index 333b0a566f..e188bb94b1 100644
--- a/var/spack/repos/tutorial/packages/hdf5/package.py
+++ b/var/spack/repos/tutorial/packages/hdf5/package.py
@@ -3,62 +3,109 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
import shutil
import sys
-from spack import *
+import llnl.util.tty as tty
-class Hdf5(AutotoolsPackage):
+class Hdf5(CMakePackage):
"""HDF5 is a data model, library, and file format for storing and managing
data. It supports an unlimited variety of datatypes, and is designed for
flexible and efficient I/O and for high volume and complex data.
"""
- homepage = "https://support.hdfgroup.org/HDF5/"
- url = "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.1/src/hdf5-1.10.1.tar.gz"
+ homepage = "https://portal.hdfgroup.org"
+ url = "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.7/src/hdf5-1.10.7.tar.gz"
list_url = "https://support.hdfgroup.org/ftp/HDF5/releases"
list_depth = 3
+ git = "https://github.com/HDFGroup/hdf5.git"
+ maintainers = ['lrknox', 'brtnfld', 'byrnHDF', 'ChristopherHogan', 'epourmal',
+ 'gheber', 'hyoklee', 'lkurz', 'soumagne']
+
+ test_requires_compiler = True
+
+ # The 'develop' version is renamed so that we could uninstall (or patch) it
+ # without affecting other develop version.
+ version('develop-1.13', branch='develop')
+ version('develop-1.12', branch='hdf5_1_12')
+ version('develop-1.10', branch='hdf5_1_10')
+ version('develop-1.8', branch='hdf5_1_8')
+
+ version('1.12.1', sha256='79c66ff67e666665369396e9c90b32e238e501f345afd2234186bfb8331081ca')
+ version('1.12.0', sha256='a62dcb276658cb78e6795dd29bf926ed7a9bc4edf6e77025cd2c689a8f97c17a')
+ # HDF5 1.12 broke API compatibility, so we currently prefer the latest
+ # 1.10 release. packages that want later versions of HDF5 should specify,
+ # e.g., depends_on("hdf5@1.12:") to get 1.12 or higher.
+ version('1.10.7', sha256='7a1a0a54371275ce2dfc5cd093775bb025c365846512961e7e5ceaecb437ef15', preferred=True)
+ version('1.10.6', sha256='5f9a3ee85db4ea1d3b1fa9159352aebc2af72732fc2f58c96a3f0768dba0e9aa')
+ version('1.10.5', sha256='6d4ce8bf902a97b050f6f491f4268634e252a63dadd6656a1a9be5b7b7726fa8')
+ version('1.10.4', sha256='8f60dc4dd6ab5fcd23c750d1dc5bca3d0453bdce5c8cdaf0a4a61a9d1122adb2')
+ version('1.10.3', sha256='b600d7c914cfa80ae127cd1a1539981213fee9994ac22ebec9e3845e951d9b39')
+ version('1.10.2', sha256='bfec1be8c366965a99812cf02ddc97e4b708c1754fccba5414d4adccdc073866')
+ version('1.10.1', sha256='048a9d149fb99aaa1680a712963f5a78e9c43b588d0e79d55e06760ec377c172')
+ version('1.10.0-patch1', sha256='6e78cfe32a10e6e0629393cdfddf6cfa536571efdaf85f08e35326e1b4e9eff0')
+ version('1.10.0', sha256='81f6201aba5c30dced5dcd62f5d5477a2790fd5850e02ac514ca8bf3e2bb375a')
+
+ version('1.8.22', sha256='8406d96d9355ef8961d2739fb8fd5474ad4cdf52f3cfac657733defd9709bfaa')
+ version('1.8.21', sha256='87d8c82eba5cf766d97cd06c054f4639c1049c4adeaa3a79f77f8bd374f80f37')
+ version('1.8.19', sha256='a4335849f19fae88c264fd0df046bc321a78c536b2548fc508627a790564dc38')
+ version('1.8.18', sha256='cdb195ad8d9e6782acf24b2488061289f615628c2ccda8457b0a0c3fb7a8a063')
+ version('1.8.17', sha256='d9cda297ee76ade9881c4208987939250d397bae6252d0ccb66fa7d24d67e263')
+ version('1.8.16', sha256='ed17178abd9928a7237f30370189ba767b9e39e0db45917c2ac4665eb9cb4771')
+ version('1.8.15', sha256='4e963216b7d32469596bc1321a8c3f6e0c278dcbbdb7be6414c63c081b34c275')
+ version('1.8.14', sha256='1dbefeeef7f591897c632b2b090db96bb8d35ad035beaa36bc39cb2bc67e0639')
+ version('1.8.13', sha256='82f6b38eec103b4fccfbf14892786e0c27a8135d3252d8601cf5bf20066d38c1')
+ version('1.8.12', sha256='b5cccea850096962b5fd9e96f22c4f47d2379224bb41130d9bc038bb6c37dfcb')
+ version('1.8.10', sha256='4813b79c5fb8701a625b9924b8203bc7154a77f9b826ad4e034144b4056a160a')
- version('1.10.4', '8f60dc4dd6ab5fcd23c750d1dc5bca3d0453bdce5c8cdaf0a4a61a9d1122adb2')
- version('1.10.3', 'b600d7c914cfa80ae127cd1a1539981213fee9994ac22ebec9e3845e951d9b39')
- version('1.10.2', '8d4eae84e533efa57496638fd0dca8c3')
- version('1.10.1', '43a2f9466702fb1db31df98ae6677f15')
- version('1.10.0-patch1', '9180ff0ef8dc2ef3f61bd37a7404f295')
- version('1.10.0', 'bdc935337ee8282579cd6bc4270ad199')
- version('1.8.19', '7f568e2464d4ab0a74d16b23956d900b')
- version('1.8.18', 'dd2148b740713ca0295442ec683d7b1c')
- version('1.8.17', '7d572f8f3b798a628b8245af0391a0ca')
- version('1.8.16', 'b8ed9a36ae142317f88b0c7ef4b9c618')
- version('1.8.15', '03cccb5b33dbe975fdcd8ae9dc021f24')
- version('1.8.14', 'a482686e733514a51cde12d6fe5c5d95')
- version('1.8.13', 'c03426e9e77d7766944654280b467289')
- version('1.8.12', 'd804802feb99b87fc668a90e6fa34411')
- version('1.8.10', '710aa9fb61a51d61a7e2c09bf0052157')
-
- variant('debug', default=False,
- description='Builds a debug version of the library')
variant('shared', default=True,
description='Builds a shared version of the library')
variant('hl', default=False, description='Enable the high-level library')
variant('cxx', default=False, description='Enable C++ support')
variant('fortran', default=False, description='Enable Fortran support')
+ variant('java', default=False, description='Enable Java support')
variant('threadsafe', default=False,
description='Enable thread-safe capabilities')
-
+ variant('tools', default=True, description='Enable building tools')
variant('mpi', default=True, description='Enable MPI support')
variant('szip', default=False, description='Enable szip support')
- variant('pic', default=True,
- description='Produce position-independent code (for shared libs)')
+ # Build HDF5 with API compatibility.
+ variant('api', default='default',
+ description='Choose api compatibility for earlier version',
+ values=('default', 'v114', 'v112', 'v110', 'v18', 'v16'),
+ multi=False)
+
+ depends_on('cmake@3.12:', type='build')
depends_on('mpi', when='+mpi')
+ depends_on('java', type=('build', 'run'), when='+java')
# numactl does not currently build on darwin
if sys.platform != 'darwin':
depends_on('numactl', when='+mpi+fortran')
depends_on('szip', when='+szip')
depends_on('zlib@1.1.2:')
+ # The compiler wrappers (h5cc, h5fc, etc.) run 'pkg-config'.
+ depends_on('pkgconfig', type='run')
+
+ conflicts('api=v114', when='@1.6:1.12.99',
+ msg='v114 is not compatible with this release')
+ conflicts('api=v112', when='@1.6:1.10.99',
+ msg='v112 is not compatible with this release')
+ conflicts('api=v110', when='@1.6:1.8.99',
+ msg='v110 is not compatible with this release')
+ conflicts('api=v18', when='@1.6:1.6.99',
+ msg='v18 is not compatible with this release')
+
+ # The Java wrappers and associated libhdf5_java library
+ # were first available in 1.10
+ conflicts('+java', when='@:1.9')
+ # The Java wrappers cannot be built without shared libs.
+ conflicts('+java', when='~shared')
+
# There are several officially unsupported combinations of the features:
# 1. Thread safety is not guaranteed via high-level C-API but in some cases
# it works.
@@ -96,14 +143,74 @@ class Hdf5(AutotoolsPackage):
# There are build errors with GCC 8, see
# https://forum.hdfgroup.org/t/1-10-2-h5detect-compile-error-gcc-8-1-0-on-centos-7-2-solved/4441
- patch('https://salsa.debian.org/debian-gis-team/hdf5/raw/bf94804af5f80f662cad80a5527535b3c6537df6/debian/patches/gcc-8.patch', sha256='57cee5ff1992b4098eda079815c36fc2da9b10e00a9056df054f2384c4fc7523', when='@1.10.2%gcc@8:')
-
- filter_compiler_wrappers('h5cc', 'h5c++', 'h5fc', relative_root='bin')
+ patch('https://salsa.debian.org/debian-gis-team/hdf5/raw/bf94804af5f80f662cad80a5527535b3c6537df6/debian/patches/gcc-8.patch',
+ sha256='57cee5ff1992b4098eda079815c36fc2da9b10e00a9056df054f2384c4fc7523',
+ when='@1.10.2%gcc@8:')
+
+ # Disable MPI C++ interface when C++ is disabled, otherwise downstream
+ # libraries fail to link; see https://github.com/spack/spack/issues/12586
+ patch('h5public-skip-mpicxx.patch', when='@1.8.10:1.8.21,1.10.0:1.10.5+mpi~cxx',
+ sha256='b61e2f058964ad85be6ee5ecea10080bf79e73f83ff88d1fa4b602d00209da9c')
+
+ # Fixes BOZ literal constant error when compiled with GCC 10.
+ # The issue is described here: https://github.com/spack/spack/issues/18625
+ patch('hdf5_1.8_gcc10.patch', when='@:1.8.21',
+ sha256='0e20187cda3980a4fdff410da92358b63de7ebef2df1d7a425371af78e50f666')
+
+ # The argument 'buf_size' of the C function 'h5fget_file_image_c' is
+ # declared as intent(in) though it is modified by the invocation. As a
+ # result, aggressive compilers such as Fujitsu's may do a wrong
+ # optimization to cause an error.
+ def patch(self):
+ filter_file(
+ 'INTEGER(SIZE_T), INTENT(IN) :: buf_size',
+ 'INTEGER(SIZE_T), INTENT(OUT) :: buf_size',
+ 'fortran/src/H5Fff.F90',
+ string=True, ignore_absent=True)
+ filter_file(
+ 'INTEGER(SIZE_T), INTENT(IN) :: buf_size',
+ 'INTEGER(SIZE_T), INTENT(OUT) :: buf_size',
+ 'fortran/src/H5Fff_F03.f90',
+ string=True, ignore_absent=True)
+
+ # The parallel compiler wrappers (i.e. h5pcc, h5pfc, etc.) reference MPI
+ # compiler wrappers and do not need to be changed.
+ filter_compiler_wrappers('h5cc', 'h5hlcc',
+ 'h5fc', 'h5hlfc',
+ 'h5c++', 'h5hlc++',
+ relative_root='bin')
def url_for_version(self, version):
url = "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-{0}/hdf5-{1}/src/hdf5-{1}.tar.gz"
return url.format(version.up_to(2), version)
+ def flag_handler(self, name, flags):
+ cmake_flags = []
+
+ if name == "cflags":
+ if self.spec.satisfies('%gcc') \
+ or self.spec.satisfies('%clang'):
+ # Quiet warnings/errors about implicit declaration of functions
+ # in C99:
+ cmake_flags.append("-Wno-implicit-function-declaration")
+ # Note that this flag will cause an error if building %nvhpc.
+ if self.spec.satisfies('@:1.8.12~shared'):
+ # More recent versions set CMAKE_POSITION_INDEPENDENT_CODE to
+ # True and build with PIC flags.
+ cmake_flags.append(self.compiler.cc_pic_flag)
+ elif name == 'cxxflags':
+ if self.spec.satisfies('@:1.8.12+cxx~shared'):
+ cmake_flags.append(self.compiler.cxx_pic_flag)
+ elif name == "fflags":
+ if self.spec.satisfies('@:1.8.12+fortran~shared'):
+ cmake_flags.append(self.compiler.fc_pic_flag)
+ elif name == "ldlibs":
+ if '+fortran %fj' in self.spec:
+ cmake_flags.extend(['-lfj90i', '-lfj90f',
+ '-lfjsrcinfo', '-lelf'])
+
+ return flags, None, (cmake_flags or None)
+
@property
def libs(self):
"""HDF5 can be queried for the following parameters:
@@ -111,18 +218,46 @@ class Hdf5(AutotoolsPackage):
- "hl": high-level interface
- "cxx": C++ APIs
- "fortran": Fortran APIs
+ - "java": Java APIs
:return: list of matching libraries
"""
+ query_parameters = self.spec.last_query.extra_parameters
+
+ shared = '+shared' in self.spec
+
# This map contains a translation from query_parameters
# to the libraries needed
- query2libraries = { # noqa: F841
+ query2libraries = {
tuple(): ['libhdf5'],
- ('cxx', 'fortran', 'hl'): [
- 'libhdf5hl_fortran',
+ ('cxx', 'fortran', 'hl', 'java'): [
+ # When installed with Autotools, the basename of the real
+ # library file implementing the High-level Fortran interface is
+ # 'libhdf5hl_fortran'. Starting versions 1.8.22, 1.10.5 and
+ # 1.12.0, the Autotools installation also produces a symbolic
+ # link 'libhdf5_hl_fortran.<so/a>' to
+ # 'libhdf5hl_fortran.<so/a>'. Note that in the case of the
+ # dynamic library, the latter is a symlink to the real sonamed
+ # file 'libhdf5_fortran.so.<abi-version>'. This means that all
+ # dynamically linked executables/libraries of the dependent
+ # packages need 'libhdf5_fortran.so.<abi-version>' with the same
+ # DT_SONAME entry. However, the CMake installation (at least
+ # starting version 1.8.10) does not produce it. Instead, the
+ # basename of the library file is 'libhdf5_hl_fortran'. Which
+ # means that switching to CMake requires rebuilding of all
+ # dependant packages that use the High-level Fortran interface.
+ # Therefore, we do not try to preserve backward compatibility
+ # with Autotools installations by creating symlinks. The only
+ # packages that could benefit from it would be those that
+ # hardcode the library name in their building systems. Such
+ # packages should simply be patched.
+ 'libhdf5_hl_fortran',
+ 'libhdf5_hl_f90cstub',
'libhdf5_hl_cpp',
'libhdf5_hl',
'libhdf5_fortran',
+ 'libhdf5_f90cstub',
+ 'libhdf5_java',
'libhdf5',
],
('cxx', 'hl'): [
@@ -131,9 +266,11 @@ class Hdf5(AutotoolsPackage):
'libhdf5',
],
('fortran', 'hl'): [
- 'libhdf5hl_fortran',
+ 'libhdf5_hl_fortran',
+ 'libhdf5_hl_f90cstub',
'libhdf5_hl',
'libhdf5_fortran',
+ 'libhdf5_f90cstub',
'libhdf5',
],
('hl',): [
@@ -142,6 +279,7 @@ class Hdf5(AutotoolsPackage):
],
('cxx', 'fortran'): [
'libhdf5_fortran',
+ 'libhdf5_f90cstub',
'libhdf5_cpp',
'libhdf5',
],
@@ -151,112 +289,155 @@ class Hdf5(AutotoolsPackage):
],
('fortran',): [
'libhdf5_fortran',
+ 'libhdf5_f90cstub',
+ 'libhdf5',
+ ],
+ ('java',): [
+ 'libhdf5_java',
'libhdf5',
]
}
- # TUTORIAL: you need to fix the implementation below, and
- # return the correct list of libraries according to the
- # query parameters your dependency has used.
- #
- # You can retrieve the query parameters by doing
- #
- # query_parameters = self.spec.last_query.extra_parameters
- #
- # and use the map above to query the list of libraries you need
- # to search.
- #
- # Finally uncomment the lines below to return a LibraryList
- #
- # shared = '+shared' in self.spec
- # return find_libraries(
- # libraries, root=self.prefix, shared=shared, recursive=True
- # )
- return []
-
- @run_before('configure')
+ # Turn the query into the appropriate key
+ key = tuple(sorted(query_parameters))
+ libraries = query2libraries[key]
+
+ return find_libraries(
+ libraries, root=self.prefix, shared=shared, recursive=True
+ )
+
+ @when('@:1.8.21,1.10.0:1.10.5+szip')
+ def setup_build_environment(self, env):
+ env.set('SZIP_INSTALL', self.spec['szip'].prefix)
+
+ @run_before('cmake')
def fortran_check(self):
if '+fortran' in self.spec and not self.compiler.fc:
msg = 'cannot build a Fortran variant without a Fortran compiler'
raise RuntimeError(msg)
- def configure_args(self):
- # Always enable this option. This does not actually enable any
- # features: it only *allows* the user to specify certain
- # combinations of other arguments. Enabling it just skips a
- # sanity check in configure, so this doesn't merit a variant.
- extra_args = ['--enable-unsupported']
- extra_args += self.enable_or_disable('threadsafe')
- extra_args += self.enable_or_disable('cxx')
- extra_args += self.enable_or_disable('hl')
- extra_args += self.enable_or_disable('fortran')
-
- if '+szip' in self.spec:
- extra_args.append('--with-szlib=%s' % self.spec['szip'].prefix)
- else:
- extra_args.append('--without-szlib')
-
- if self.spec.satisfies('@1.10:'):
- if '+debug' in self.spec:
- extra_args.append('--enable-build-mode=debug')
- else:
- extra_args.append('--enable-build-mode=production')
- else:
- if '+debug' in self.spec:
- extra_args.append('--enable-debug=all')
- else:
- extra_args.append('--enable-production')
+ def cmake_args(self):
+ spec = self.spec
- # '--enable-fortran2003' no longer exists as of version 1.10.0
- if '+fortran' in self.spec:
- extra_args.append('--enable-fortran2003')
- else:
- extra_args.append('--disable-fortran2003')
-
- if '+shared' in self.spec:
- extra_args.append('--enable-shared')
- else:
- extra_args.append('--disable-shared')
- extra_args.append('--enable-static-exec')
-
- if '+pic' in self.spec:
- extra_args += ['%s=%s' % (f, self.compiler.pic_flag)
- for f in ['CFLAGS', 'CXXFLAGS', 'FCFLAGS']]
-
- if '+mpi' in self.spec:
- # The HDF5 configure script warns if cxx and mpi are enabled
- # together. There doesn't seem to be a real reason for this, except
- # that parts of the MPI interface are not accessible via the C++
- # interface. Since they are still accessible via the C interface,
- # this is not actually a problem.
- extra_args += ['--enable-parallel',
- 'CC=%s' % self.spec['mpi'].mpicc]
+ if spec.satisfies('@:1.8.15+shared'):
+ tty.warn('hdf5@:1.8.15+shared does not produce static libraries')
+
+ args = [
+ # Always enable this option. This does not actually enable any
+ # features: it only *allows* the user to specify certain
+ # combinations of other arguments.
+ self.define('ALLOW_UNSUPPORTED', True),
+ # Speed-up the building by skipping the examples:
+ self.define('HDF5_BUILD_EXAMPLES', False),
+ self.define(
+ 'BUILD_TESTING',
+ self.run_tests or
+ # Version 1.8.22 fails to build the tools when shared libraries
+ # are enabled but the tests are disabled.
+ spec.satisfies('@1.8.22+shared+tools')),
+ self.define('HDF5_ENABLE_Z_LIB_SUPPORT', True),
+ self.define_from_variant('HDF5_ENABLE_SZIP_SUPPORT', 'szip'),
+ self.define_from_variant('HDF5_ENABLE_SZIP_ENCODING', 'szip'),
+ self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),
+ self.define('ONLY_SHARED_LIBS', False),
+ self.define_from_variant('HDF5_ENABLE_PARALLEL', 'mpi'),
+ self.define_from_variant('HDF5_ENABLE_THREADSAFE', 'threadsafe'),
+ self.define_from_variant('HDF5_BUILD_HL_LIB', 'hl'),
+ self.define_from_variant('HDF5_BUILD_CPP_LIB', 'cxx'),
+ self.define_from_variant('HDF5_BUILD_FORTRAN', 'fortran'),
+ self.define_from_variant('HDF5_BUILD_JAVA', 'java'),
+ self.define_from_variant('HDF5_BUILD_TOOLS', 'tools')
+ ]
+
+ api = spec.variants['api'].value
+ if api != 'default':
+ args.append(self.define('DEFAULT_API_VERSION', api))
+
+ if '+mpi' in spec:
+ args.append(self.define('CMAKE_C_COMPILER', spec['mpi'].mpicc))
if '+cxx' in self.spec:
- extra_args.append('CXX=%s' % self.spec['mpi'].mpicxx)
+ args.append(self.define('CMAKE_CXX_COMPILER',
+ spec['mpi'].mpicxx))
if '+fortran' in self.spec:
- extra_args.append('FC=%s' % self.spec['mpi'].mpifc)
+ args.append(self.define('CMAKE_Fortran_COMPILER',
+ spec['mpi'].mpifc))
- extra_args.append('--with-zlib=%s' % self.spec['zlib'].prefix)
+ return args
- return extra_args
+ @run_after('install')
+ def ensure_parallel_compiler_wrappers(self):
+ # When installed with Autotools and starting at least version 1.8.10,
+ # the package produces C compiler wrapper called either 'h5cc' (when MPI
+ # support is disabled) or 'h5pcc' (when MPI support is enabled). The
+ # CMake installation produces the wrapper called 'h5cc' (regardless of
+ # whether MPI support is enabled) only starting versions 1.8.21, 1.10.2
+ # and 1.12.0. The current develop versions also produce 'h5pcc' when MPI
+ # support is enabled and the file is identical to 'h5cc'. Here, we make
+ # sure that 'h5pcc' is available when MPI support is enabled (only for
+ # versions that generate 'h5cc').
+ if self.spec.satisfies('@1.8.21:1.8.22,1.10.2:1.10.7,1.12.0+mpi'):
+ with working_dir(self.prefix.bin):
+ # No try/except here, fix the condition above instead:
+ symlink('h5cc', 'h5pcc')
+
+ # The same as for 'h5pcc'. However, the CMake installation produces the
+ # Fortran compiler wrapper called 'h5fc' only starting versions 1.8.22,
+ # 1.10.6 and 1.12.0. The current develop versions do not produce 'h5pfc'
+ # at all. Here, we make sure that 'h5pfc' is available when Fortran and
+ # MPI support are enabled (only for versions that generate 'h5fc').
+ if self.spec.satisfies('@1.8.22:1.8.999,'
+ '1.10.6:1.10.999,'
+ '1.12.0:1.12.999,'
+ 'develop:'
+ '+fortran+mpi'):
+ with working_dir(self.prefix.bin):
+ # No try/except here, fix the condition above instead:
+ symlink('h5fc', 'h5pfc')
- @run_after('configure')
- def patch_postdeps(self):
- if '@:1.8.14' in self.spec:
- # On Ubuntu14, HDF5 1.8.12 (and maybe other versions)
- # mysteriously end up with "-l -l" in the postdeps in the
- # libtool script. Patch this by removing the spurious -l's.
- filter_file(
- r'postdeps="([^"]*)"',
- lambda m: 'postdeps="%s"' % ' '.join(
- arg for arg in m.group(1).split(' ') if arg != '-l'),
- 'libtool')
+ @run_after('install')
+ def fix_package_config(self):
+ # We need to fix the pkg-config files, which are also used by the
+ # compiler wrappers. The files are created starting versions 1.8.21,
+ # 1.10.2 and 1.12.0. However, they are broken (except for the version
+ # 1.8.22): the files are named <name>-<version>.pc but reference <name>
+ # packages. This was fixed in the develop versions at some point: the
+ # files started referencing <name>-<version> packages but got broken
+ # again: the files got names <name>.pc but references had not been
+ # updated accordingly. Another issue, which we address here, is that
+ # some Linux distributions install pkg-config files named hdf5.pc and we
+ # want to override them. Therefore, the following solution makes sure
+ # that each <name>-<version>.pc file is symlinked by <name>.pc and all
+ # references to <name>-<version> packages in the original files are
+ # replaced with references to <name> packages.
+ pc_files = find(self.prefix.lib.pkgconfig, 'hdf5*.pc', recursive=False)
+
+ if not pc_files:
+ # This also tells us that the pkgconfig directory does not exist.
+ return
+
+ # Replace versioned references in all pkg-config files:
+ filter_file(
+ r'(Requires(?:\.private)?:.*)(hdf5[^\s,]*)(?:-[^\s,]*)(.*)',
+ r'\1\2\3', *pc_files, backup=False)
+
+ # Create non-versioned symlinks to the versioned pkg-config files:
+ with working_dir(self.prefix.lib.pkgconfig):
+ for f in pc_files:
+ src_filename = os.path.basename(f)
+ version_sep_idx = src_filename.find('-')
+ if version_sep_idx > -1:
+ tgt_filename = src_filename[:version_sep_idx] + '.pc'
+ if not os.path.exists(tgt_filename):
+ symlink(src_filename, tgt_filename)
@run_after('install')
@on_package_attributes(run_tests=True)
def check_install(self):
+ self._check_install()
+
+ def _check_install(self):
# Build and run a small program to test the installed HDF5 library
spec = self.spec
print("Checking HDF5 installation...")
@@ -305,3 +486,54 @@ HDF5 version {version} {version}
print('-' * 80)
raise RuntimeError("HDF5 install check failed")
shutil.rmtree(checkdir)
+
+ def _test_check_versions(self):
+ """Perform version checks on selected installed package binaries."""
+ spec_vers_str = 'Version {0}'.format(self.spec.version)
+
+ exes = [
+ 'h5copy', 'h5diff', 'h5dump', 'h5format_convert', 'h5ls',
+ 'h5mkgrp', 'h5repack', 'h5stat', 'h5unjam',
+ ]
+ use_short_opt = ['h52gif', 'h5repart', 'h5unjam']
+ for exe in exes:
+ reason = 'test: ensuring version of {0} is {1}' \
+ .format(exe, spec_vers_str)
+ option = '-V' if exe in use_short_opt else '--version'
+ self.run_test(exe, option, spec_vers_str, installed=True,
+ purpose=reason, skip_missing=True)
+
+ def _test_example(self):
+ """This test performs copy, dump, and diff on an example hdf5 file."""
+ test_data_dir = self.test_suite.current_test_data_dir
+
+ filename = 'spack.h5'
+ h5_file = test_data_dir.join(filename)
+
+ reason = 'test: ensuring h5dump produces expected output'
+ expected = get_escaped_text_output(test_data_dir.join('dump.out'))
+ self.run_test('h5dump', filename, expected, installed=True,
+ purpose=reason, skip_missing=True,
+ work_dir=test_data_dir)
+
+ reason = 'test: ensuring h5copy runs'
+ options = ['-i', h5_file, '-s', 'Spack', '-o', 'test.h5', '-d',
+ 'Spack']
+ self.run_test('h5copy', options, [], installed=True,
+ purpose=reason, skip_missing=True, work_dir='.')
+
+ reason = ('test: ensuring h5diff shows no differences between orig and'
+ ' copy')
+ self.run_test('h5diff', [h5_file, 'test.h5'], [], installed=True,
+ purpose=reason, skip_missing=True, work_dir='.')
+
+ def test(self):
+ """Perform smoke tests on the installed package."""
+ # Simple version check tests on known binaries
+ self._test_check_versions()
+
+ # Run sequence of commands on an hdf5 file
+ self._test_example()
+
+ # Run existing install check
+ self._check_install()
diff --git a/var/spack/repos/tutorial/packages/hdf5/test/dump.out b/var/spack/repos/tutorial/packages/hdf5/test/dump.out
new file mode 100644
index 0000000000..58decefc12
--- /dev/null
+++ b/var/spack/repos/tutorial/packages/hdf5/test/dump.out
@@ -0,0 +1,45 @@
+HDF5 "spack.h5" {
+GROUP "/" {
+ GROUP "Spack" {
+ GROUP "Software" {
+ ATTRIBUTE "Distribution" {
+ DATATYPE H5T_STRING {
+ STRSIZE H5T_VARIABLE;
+ STRPAD H5T_STR_NULLTERM;
+ CSET H5T_CSET_UTF8;
+ CTYPE H5T_C_S1;
+ }
+ DATASPACE SCALAR
+ DATA {
+ (0): "Open Source"
+ }
+ }
+ DATASET "data" {
+ DATATYPE H5T_IEEE_F64LE
+ DATASPACE SIMPLE { ( 7, 11 ) / ( 7, 11 ) }
+ DATA {
+ (0,0): 0.371141, 0.508482, 0.585975, 0.0944911, 0.684849,
+ (0,5): 0.580396, 0.720271, 0.693561, 0.340432, 0.217145,
+ (0,10): 0.636083,
+ (1,0): 0.686996, 0.773501, 0.656767, 0.617543, 0.226132,
+ (1,5): 0.768632, 0.0548711, 0.54572, 0.355544, 0.591548,
+ (1,10): 0.233007,
+ (2,0): 0.230032, 0.192087, 0.293845, 0.0369338, 0.038727,
+ (2,5): 0.0977931, 0.966522, 0.0821391, 0.857921, 0.495703,
+ (2,10): 0.746006,
+ (3,0): 0.598494, 0.990266, 0.993009, 0.187481, 0.746391,
+ (3,5): 0.140095, 0.122661, 0.929242, 0.542415, 0.802758,
+ (3,10): 0.757941,
+ (4,0): 0.372124, 0.411982, 0.270479, 0.950033, 0.329948,
+ (4,5): 0.936704, 0.105097, 0.742285, 0.556565, 0.18988, 0.72797,
+ (5,0): 0.801669, 0.271807, 0.910649, 0.186251, 0.868865,
+ (5,5): 0.191484, 0.788371, 0.920173, 0.582249, 0.682022,
+ (5,10): 0.146883,
+ (6,0): 0.826824, 0.0886705, 0.402606, 0.0532444, 0.72509,
+ (6,5): 0.964683, 0.330362, 0.833284, 0.630456, 0.411489, 0.247806
+ }
+ }
+ }
+ }
+}
+}
diff --git a/var/spack/repos/tutorial/packages/hdf5/test/spack.h5 b/var/spack/repos/tutorial/packages/hdf5/test/spack.h5
new file mode 100644
index 0000000000..c2f3a6f39d
--- /dev/null
+++ b/var/spack/repos/tutorial/packages/hdf5/test/spack.h5
Binary files differ