From 54517e571a34fdbfb1bc9074ac1f67c31b9d6cb9 Mon Sep 17 00:00:00 2001 From: Sergey Kosukhin Date: Fri, 25 Sep 2020 09:44:37 +0200 Subject: [PATCH] eccodes: update and a add new version (#18864) --- .../packages/eccodes/enable_only_jasper.patch | 34 ---------- .../eccodes/enable_only_openjpeg.patch | 30 --------- .../packages/eccodes/openjpeg_jasper.patch | 39 +++++++++++ .../repos/builtin/packages/eccodes/package.py | 66 +++++++++++-------- 4 files changed, 77 insertions(+), 92 deletions(-) delete mode 100644 var/spack/repos/builtin/packages/eccodes/enable_only_jasper.patch delete mode 100644 var/spack/repos/builtin/packages/eccodes/enable_only_openjpeg.patch create mode 100644 var/spack/repos/builtin/packages/eccodes/openjpeg_jasper.patch diff --git a/var/spack/repos/builtin/packages/eccodes/enable_only_jasper.patch b/var/spack/repos/builtin/packages/eccodes/enable_only_jasper.patch deleted file mode 100644 index ad09c75199..0000000000 --- a/var/spack/repos/builtin/packages/eccodes/enable_only_jasper.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -151,18 +151,7 @@ set( HAVE_LIBOPENJPEG 0 ) - - if( ENABLE_JPG ) - -- # Note: This is a deprecated feature but we need it to find Jasper at ECMWF. -- # ecbuild_add_extra_search_paths modifies CMAKE_PREFIX_PATH -- # which can affect future package discovery if not undone by the caller. -- # The current CMAKE_PREFIX_PATH is backed up as _CMAKE_PREFIX_PATH -- # -- set(CMAKE_WARN_DEPRECATED OFF) # Suppress deprecation message -- ecbuild_add_extra_search_paths( jasper ) - find_package( Jasper ) -- set(CMAKE_PREFIX_PATH ${_CMAKE_PREFIX_PATH}) # Restore CMAKE_PREFIX_PATH -- set(CMAKE_WARN_DEPRECATED ON) # Remove suppression -- -- find_package( OpenJPEG ) - - if( JASPER_FOUND ) - list( APPEND ECCODES_TPLS Jasper ) -@@ -172,12 +161,6 @@ if( ENABLE_JPG ) - string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" JASPER_VERSION_MAJOR "${JASPER_VERSION_STRING}") - endif() - -- if( OPENJPEG_FOUND ) -- list( APPEND ECCODES_TPLS OpenJPEG ) -- set( HAVE_JPEG 1 ) -- set( HAVE_LIBOPENJPEG 1 ) -- endif() -- - endif() - - diff --git a/var/spack/repos/builtin/packages/eccodes/enable_only_openjpeg.patch b/var/spack/repos/builtin/packages/eccodes/enable_only_openjpeg.patch deleted file mode 100644 index 29a6dff454..0000000000 --- a/var/spack/repos/builtin/packages/eccodes/enable_only_openjpeg.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -151,27 +151,8 @@ set( HAVE_LIBOPENJPEG 0 ) - - if( ENABLE_JPG ) - -- # Note: This is a deprecated feature but we need it to find Jasper at ECMWF. -- # ecbuild_add_extra_search_paths modifies CMAKE_PREFIX_PATH -- # which can affect future package discovery if not undone by the caller. -- # The current CMAKE_PREFIX_PATH is backed up as _CMAKE_PREFIX_PATH -- # -- set(CMAKE_WARN_DEPRECATED OFF) # Suppress deprecation message -- ecbuild_add_extra_search_paths( jasper ) -- find_package( Jasper ) -- set(CMAKE_PREFIX_PATH ${_CMAKE_PREFIX_PATH}) # Restore CMAKE_PREFIX_PATH -- set(CMAKE_WARN_DEPRECATED ON) # Remove suppression -- - find_package( OpenJPEG ) - -- if( JASPER_FOUND ) -- list( APPEND ECCODES_TPLS Jasper ) -- set( HAVE_JPEG 1 ) -- set( HAVE_LIBJASPER 1 ) -- # Extract Jasper's major version number to enable conditional code. See ECC-396 -- string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" JASPER_VERSION_MAJOR "${JASPER_VERSION_STRING}") -- endif() -- - if( OPENJPEG_FOUND ) - list( APPEND ECCODES_TPLS OpenJPEG ) - set( HAVE_JPEG 1 ) diff --git a/var/spack/repos/builtin/packages/eccodes/openjpeg_jasper.patch b/var/spack/repos/builtin/packages/eccodes/openjpeg_jasper.patch new file mode 100644 index 0000000000..5793f56827 --- /dev/null +++ b/var/spack/repos/builtin/packages/eccodes/openjpeg_jasper.patch @@ -0,0 +1,39 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -43,6 +43,18 @@ ecbuild_add_option( FEATURE JPG + DESCRIPTION "support for JPG decoding/encoding" + DEFAULT ON + ) ++# Options related to JPG. The Jasper and OpenJPEG libraries ++ecbuild_add_option( FEATURE JPG_LIBJASPER ++ DESCRIPTION "Support for JPG decoding/encoding with the Jasper library" ++ CONDITION ENABLE_JPG ++ DEFAULT ON ++) ++ecbuild_add_option( FEATURE JPG_LIBOPENJPEG ++ DESCRIPTION "Support for JPG decoding/encoding with the OpenJPEG library" ++ CONDITION ENABLE_JPG ++ DEFAULT ON ++) ++ + + ecbuild_add_option( FEATURE PNG + DESCRIPTION "support for PNG decoding/encoding" +@@ -144,7 +156,7 @@ if( ENABLE_JPG ) + + find_package( OpenJPEG ) + +- if( JASPER_FOUND ) ++ if( JASPER_FOUND AND ENABLE_JPG_LIBJASPER ) + list( APPEND ECCODES_TPLS Jasper ) + set( HAVE_JPEG 1 ) + set( HAVE_LIBJASPER 1 ) +@@ -152,7 +164,7 @@ if( ENABLE_JPG ) + string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" JASPER_VERSION_MAJOR "${JASPER_VERSION_STRING}") + endif() + +- if( OPENJPEG_FOUND ) ++ if( OPENJPEG_FOUND AND ENABLE_JPG_LIBOPENJPEG ) + list( APPEND ECCODES_TPLS OpenJPEG ) + set( HAVE_JPEG 1 ) + set( HAVE_LIBOPENJPEG 1 ) diff --git a/var/spack/repos/builtin/packages/eccodes/package.py b/var/spack/repos/builtin/packages/eccodes/package.py index 8638463740..c31bb14f45 100644 --- a/var/spack/repos/builtin/packages/eccodes/package.py +++ b/var/spack/repos/builtin/packages/eccodes/package.py @@ -17,6 +17,7 @@ class Eccodes(CMakePackage): maintainers = ['skosukhin'] + version('2.18.0', sha256='d88943df0f246843a1a062796edbf709ef911de7269648eef864be259e9704e3') version('2.13.0', sha256='c5ce1183b5257929fc1f1c8496239e52650707cfab24f4e0e1f1a471135b8272') version('2.5.0', sha256='18ab44bc444168fd324d07f7dea94f89e056f5c5cd973e818c8783f952702e4e') version('2.2.0', sha256='1a4112196497b8421480e2a0a1164071221e467853486577c4f07627a702f4c3') @@ -36,30 +37,23 @@ class Eccodes(CMakePackage): variant('memfs', default=False, description='Enable memory based access to definitions/samples') variant('python', default=False, - description='Enable the Python interface') + description='Enable the Python 2 interface') variant('fortran', default=False, description='Enable the Fortran support') - variant('examples', default=True, - description='Build the examples (part of the full test suite)') - variant('test', default=True, description='Enable the tests') - variant('build_type', default='RelWithDebInfo', - description='The build type to build', - values=('Debug', 'Release', 'RelWithDebInfo', 'Production')) - - # The building script tries to find an optional package valgrind when - # tests are enabled but the testing scripts don't use it. - # depends_on('valgrind', type='test', when='+test') depends_on('netcdf-c', when='+netcdf') - depends_on('openjpeg@1.5.0:1.5.999,2.1.0:2.1.999', when='jp2k=openjpeg') + # Cannot be built with openjpeg@2.0.x. + depends_on('openjpeg@1.5.0:1.5.999,2.1.0:2.3.999', when='jp2k=openjpeg') + # Additional constraint for older versions. + depends_on('openjpeg@:2.1.999', when='@:2.16 jp2k=openjpeg') depends_on('jasper', when='jp2k=jasper') depends_on('libpng', when='+png') depends_on('libaec', when='+aec') - # Can be built with Python2 or Python3. + # Can be built with Python 2 or Python 3. depends_on('python', when='+memfs', type='build') - # The interface works only for Python2. - # Python 3 support was added in 2.13.0: + # The interface is available only for Python 2. + # Python 3 interface is available as a separate packages: # https://confluence.ecmwf.int/display/ECC/Python+3+interface+for+ecCodes - depends_on('python@2.6:2.999', when='@:2.12+python', + depends_on('python@2.6:2.999', when='+python', type=('build', 'link', 'run')) depends_on('py-numpy', when='+python', type=('build', 'run')) extends('python', when='+python') @@ -67,9 +61,9 @@ class Eccodes(CMakePackage): conflicts('+openmp', when='+pthreads', msg='Cannot enable both POSIX threads and OMP') - # The following enforces linking against the specified JPEG2000 backend. - patch('enable_only_openjpeg.patch', when='jp2k=openjpeg') - patch('enable_only_jasper.patch', when='jp2k=jasper') + # Enforce linking against the specified JPEG2000 backend, see also + # https://github.com/ecmwf/eccodes/commit/2c10828495900ff3d80d1e570fe96c1df16d97fb + patch('openjpeg_jasper.patch', when='@:2.16') # CMAKE_INSTALL_RPATH must be a semicolon-separated list. patch('cmake_install_rpath.patch', when='@:2.10') @@ -85,14 +79,22 @@ def cmake_args(self): ('+openmp', 'ECCODES_OMP_THREADS'), ('+memfs', 'MEMFS'), ('+python', 'PYTHON'), - ('+fortran', 'FORTRAN'), - ('+examples', 'EXAMPLES'), - ('+test', 'TESTS'), - ('+test', 'EXTRA_TESTS')] + ('+fortran', 'FORTRAN')] args = ['-DENABLE_%s=%s' % (opt, 'ON' if var in self.spec else 'OFF') for var, opt in var_opt_list] + args.extend( + ['-DENABLE_%s=%s' % (opt, 'ON' if self.run_tests else 'OFF') + for opt in ['TESTS', + # Examples are not installed and are + # just part of the test suite. + 'EXAMPLES']]) + + # Unconditionally disable the extended regression testing, + # which requires data downloads. + args.append('-DENABLE_EXTRA_TESTS=OFF') + if '+netcdf' in self.spec: args.extend(['-DENABLE_NETCDF=ON', # Prevent overriding by environment variable @@ -104,12 +106,15 @@ def cmake_args(self): else: args.append('-DENABLE_NETCDF=OFF') - if self.spec.variants['jp2k'].value == 'none': - args.append('-DENABLE_JPG=OFF') - else: - args.append('-DENABLE_JPG=ON') + jp2k = self.spec.variants['jp2k'].value + args.append('-DENABLE_JPG=' + + ('OFF' if jp2k == 'none' else 'ON')) + args.append('-DENABLE_JPG_LIBJASPER=' + + ('ON' if jp2k == 'jasper' else 'OFF')) + args.append('-DENABLE_JPG_LIBOPENJPEG=' + + ('ON' if jp2k == 'openjpeg' else 'OFF')) - if self.spec.variants['jp2k'].value == 'openjpeg': + if jp2k == 'openjpeg': args.append('-DOPENJPEG_PATH=' + self.spec['openjpeg'].prefix) if '+png' in self.spec: @@ -130,3 +135,8 @@ def cmake_args(self): args.append('-DPYTHON_EXECUTABLE:FILEPATH=' + python.path) return args + + def check(self): + # https://confluence.ecmwf.int/display/ECC/ecCodes+installation + with working_dir(self.build_directory): + ctest()