From c7a6a053041f752c3d83d1db46edca66389461d8 Mon Sep 17 00:00:00 2001 From: Ben Cumming Date: Mon, 14 Oct 2024 12:55:48 +0200 Subject: [PATCH] add mch/climana uenv that provides everything needed for imagemagick (#157) --- config.yaml | 18 +- recipes/mch/climana/24.10/compilers.yaml | 5 + recipes/mch/climana/24.10/config.yaml | 6 + recipes/mch/climana/24.10/environments.yaml | 56 ++++ recipes/mch/climana/24.10/modules.yaml | 36 +++ recipes/mch/climana/24.10/post-install | 39 +++ .../repo/packages/r/change_optflags_tmp.patch | 67 +++++ .../climana/24.10/repo/packages/r/package.py | 280 ++++++++++++++++++ .../24.10/repo/packages/r/package.py.back | 262 ++++++++++++++++ .../repo/packages/r/relocate-which.patch | 52 ++++ .../climana/24.10/repo/packages/r/zlib.patch | 29 ++ 11 files changed, 846 insertions(+), 4 deletions(-) create mode 100644 recipes/mch/climana/24.10/compilers.yaml create mode 100644 recipes/mch/climana/24.10/config.yaml create mode 100644 recipes/mch/climana/24.10/environments.yaml create mode 100644 recipes/mch/climana/24.10/modules.yaml create mode 100755 recipes/mch/climana/24.10/post-install create mode 100644 recipes/mch/climana/24.10/repo/packages/r/change_optflags_tmp.patch create mode 100644 recipes/mch/climana/24.10/repo/packages/r/package.py create mode 100644 recipes/mch/climana/24.10/repo/packages/r/package.py.back create mode 100644 recipes/mch/climana/24.10/repo/packages/r/relocate-which.patch create mode 100644 recipes/mch/climana/24.10/repo/packages/r/zlib.patch diff --git a/config.yaml b/config.yaml index f1ff4757..d17ab6dc 100644 --- a/config.yaml +++ b/config.yaml @@ -4,12 +4,14 @@ clusters: - uarch: 'a100' partition: 'normal' + variables: + F7T_URL: 'https://api.cscs.ch/mch/firecrest/v1' - uarch: 'zen3' partition: 'postproc' - runner: - slurm-tag: balfrin-spack-stack-builder - baremetal-tag: balfrin-login-baremetal + variables: + F7T_URL: 'https://api.cscs.ch/mch/firecrest/v1' + runner: f7t daint: targets: - @@ -35,7 +37,6 @@ clusters: SLURM_CONSTRAINT: 'mc' F7T_URL: 'https://firecrest-dev.cscs.ch' runner: f7t - #no_bwrap: True santis: targets: - @@ -71,6 +72,15 @@ uenvs: deploy: balfrin: [zen3, a100] develop: False + climana: + "24.10": + recipes: + zen2: mch/climana/24.10 + zen3: mch/climana/24.10 + a100: mch/climana/24.10 + deploy: + balfrin: [zen3, a100] + develop: False editors: "24.7": recipes: diff --git a/recipes/mch/climana/24.10/compilers.yaml b/recipes/mch/climana/24.10/compilers.yaml new file mode 100644 index 00000000..99cfe619 --- /dev/null +++ b/recipes/mch/climana/24.10/compilers.yaml @@ -0,0 +1,5 @@ +bootstrap: + spec: gcc@11.3 +gcc: + specs: + - gcc@12.3 diff --git a/recipes/mch/climana/24.10/config.yaml b/recipes/mch/climana/24.10/config.yaml new file mode 100644 index 00000000..e2d3f0c8 --- /dev/null +++ b/recipes/mch/climana/24.10/config.yaml @@ -0,0 +1,6 @@ +name: mch +store: /user-environment +spack: + commit: releases/v0.22 + repo: https://github.com/spack/spack.git +description: MCH climate analysys toolkit diff --git a/recipes/mch/climana/24.10/environments.yaml b/recipes/mch/climana/24.10/environments.yaml new file mode 100644 index 00000000..e6e81af1 --- /dev/null +++ b/recipes/mch/climana/24.10/environments.yaml @@ -0,0 +1,56 @@ +climana: + compiler: + - toolchain: gcc + spec: gcc@12 + unify: when_possible + mpi: + spec: cray-mpich@8.1.28 + packages: + - perl + - autoconf + - m4 + - automake + - texinfo + - libtool + - gawk + - curl + specs: + # choose fftw instead of the default intel-oneapi-mkl. + # this saves ~2GB of space, and reduces image build time. + - cdo ^[virtuals=fftw-api] fftw + - gdal + - geos + - gsl + - hdf5@1.12.2 +fortran +threadsafe ~mpi + - imagemagick + - ncview + - nco + - ncl + - netcdf-c@4.8.1~mpi ^hdf5~mpi api=v18 + - proj + - python@3.11 + - sqlite + - udunits + # R and its packages + # +X is required for png, tiff, jpeg, etc support + - r@4.4 +X + # install here so that the openssl built by Spack is used. + - r-curl + # R needs to find all of the following use pkg-config + # so we add them to the view, where they will be picked up. + - freetype + - fribidi + - glib + - harfbuzz + - libjpeg-turbo + - libpng + - libtiff + - zstd + # required as a runtime dependency of the ssl R package + - openssl + views: + climana: + link: roots + uenv: + prefix_paths: + LD_LIBRARY_PATH: [lib, lib64] diff --git a/recipes/mch/climana/24.10/modules.yaml b/recipes/mch/climana/24.10/modules.yaml new file mode 100644 index 00000000..80dce730 --- /dev/null +++ b/recipes/mch/climana/24.10/modules.yaml @@ -0,0 +1,36 @@ +modules: + # Paths to check when creating modules for all module sets + prefix_inspections: + bin: + - PATH + lib: + - LD_LIBRARY_PATH + lib64: + - LD_LIBRARY_PATH + lib/pkgconfig: + - PKG_CONFIG_PATH + lib64/pkgconfig: + - PKG_CONFIG_PATH + + default: + arch_folder: false + # Where to install modules + roots: + tcl: /user-environment/modules + tcl: + all: + autoload: none + netcdf-c: + environment: + set: + NETCDF_C_ROOT: '{prefix}' + hash_length: 0 + exclude_implicits: true + include: + - hdf5 + - zlib+shared + exclude: + - '%gcc@7.5.0' + - 'gcc %gcc@7.5.0' + projections: + all: '{name}/{version}' diff --git a/recipes/mch/climana/24.10/post-install b/recipes/mch/climana/24.10/post-install new file mode 100755 index 00000000..bf70a6d9 --- /dev/null +++ b/recipes/mch/climana/24.10/post-install @@ -0,0 +1,39 @@ +#!/bin/bash + +# don't generate an error message if a glob does not match any files +shopt -s nullglob + +# where all of the applications built by spack are installed +# this has to change if +# - the compiler version used to build software changes +# - we build for a different micro-architecture +# - we upgrade to SLES 16 +install_base=/user-environment/linux-sles15-zen3/gcc-12.3.0 +view_base=/user-environment/env/climana + +# iterate over all of the locations where pkgconfig files are likely to be installed +for pkbase in "lib/pkgconfig" "lib64/pkgconfig" "share/pkgconfig" "rlib/pkgconfig" +do + # find all directories that match the pattern + pkgpaths=$(find $install_base -type d -path '*/'$pkbase) + + # iterate over each directory, searching for pkg-config .pc files + for pkpath in $pkgpaths + do + pcfiles=($pkpath/*.pc) + for pcpath in ${pcfiles[@]} + do + pcfile=$(basename $pcpath) + from=$pkpath/$pcfile + to_root=$view_base/$pkbase + to=$to_root/$pcfile + mkdir -p $to_root + if [ ! -e $to ]; then + echo '+ ' $pkbase/$pcfile + ln -s "$from" "$to" + else + echo 'skip ' $pkbase/$pcfile + fi + done + done +done diff --git a/recipes/mch/climana/24.10/repo/packages/r/change_optflags_tmp.patch b/recipes/mch/climana/24.10/repo/packages/r/change_optflags_tmp.patch new file mode 100644 index 00000000..4e39b02b --- /dev/null +++ b/recipes/mch/climana/24.10/repo/packages/r/change_optflags_tmp.patch @@ -0,0 +1,67 @@ +diff -ur R-3.6.3.org/configure R-3.6.3/configure +--- R-3.6.3.org/configure 2020-03-09 11:09:16.060825352 +0900 ++++ R-3.6.3/configure 2020-03-09 11:10:47.011280195 +0900 +@@ -6470,13 +6470,13 @@ + CFLAGS=$ac_save_CFLAGS + elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then +- CFLAGS="-g -O2" ++ CFLAGS="-g -O1" + else + CFLAGS="-g" + fi + else + if test "$GCC" = yes; then +- CFLAGS="-O2" ++ CFLAGS="-O1" + else + CFLAGS= + fi +@@ -7445,13 +7445,13 @@ + FCFLAGS=$ac_save_FCFLAGS + elif test $ac_cv_prog_fc_g = yes; then + if test "x$ac_cv_fc_compiler_gnu" = xyes; then +- FCFLAGS="-g -O2" ++ FCFLAGS="-g -O1" + else + FCFLAGS="-g" + fi + else + if test "x$ac_cv_fc_compiler_gnu" = xyes; then +- FCFLAGS="-O2" ++ FCFLAGS="-O1" + else + FCFLAGS= + fi +@@ -7717,13 +7717,13 @@ + CXXFLAGS=$ac_save_CXXFLAGS + elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then +- CXXFLAGS="-g -O2" ++ CXXFLAGS="-g -O1" + else + CXXFLAGS="-g" + fi + else + if test "$GXX" = yes; then +- CXXFLAGS="-O2" ++ CXXFLAGS="-O1" + else + CXXFLAGS= + fi +@@ -8336,13 +8336,13 @@ + OBJCFLAGS=$ac_save_OBJCFLAGS + elif test $ac_cv_prog_objc_g = yes; then + if test "$GOBJC" = yes; then +- OBJCFLAGS="-g -O2" ++ OBJCFLAGS="-g -O1" + else + OBJCFLAGS="-g" + fi + else + if test "$GOBJC" = yes; then +- OBJCFLAGS="-O2" ++ OBJCFLAGS="-O1" + else + OBJCFLAGS= + fi diff --git a/recipes/mch/climana/24.10/repo/packages/r/package.py b/recipes/mch/climana/24.10/repo/packages/r/package.py new file mode 100644 index 00000000..bc411863 --- /dev/null +++ b/recipes/mch/climana/24.10/repo/packages/r/package.py @@ -0,0 +1,280 @@ +# Copyright 2013-2024 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) + +import os + +from spack.package import * + + +class R(AutotoolsPackage): + """R is 'GNU S', a freely available language and environment for + statistical computing and graphics which provides a wide variety of + statistical and graphical techniques: linear and nonlinear modelling, + statistical tests, time series analysis, classification, clustering, etc. + Please consult the R project homepage for further information.""" + + homepage = "https://www.r-project.org" + url = "https://cloud.r-project.org/src/base/R-4/R-4.4.0.tar.gz" + + extendable = True + + license("GPL-2.0-or-later") + + version("4.4.0", sha256="ace4125f9b976d2c53bcc5fca30c75e30d4edc401584859cbadb080e72b5f030") + version("4.3.3", sha256="80851231393b85bf3877ee9e39b282e750ed864c5ec60cbd68e6e139f0520330") + version("4.3.2", sha256="b3f5760ac2eee8026a3f0eefcb25b47723d978038eee8e844762094c860c452a") + version("4.3.1", sha256="8dd0bf24f1023c6f618c3b317383d291b4a494f40d73b983ac22ffea99e4ba99") + version("4.3.0", sha256="45dcc48b6cf27d361020f77fde1a39209e997b81402b3663ca1c010056a6a609") + version("4.2.3", sha256="55e4a9a6d43be314e2c03d0266a6fa5444afdce50b303bfc3b82b3979516e074") + version("4.2.2", sha256="0ff62b42ec51afa5713caee7c4fde7a0c45940ba39bef8c5c9487fef0c953df5") + version("4.2.1", sha256="4d52db486d27848e54613d4ee977ad952ec08ce17807e1b525b10cd4436c643f") + version("4.2.0", sha256="38eab7719b7ad095388f06aa090c5a2b202791945de60d3e2bb0eab1f5097488") + version("4.1.3", sha256="15ff5b333c61094060b2a52e9c1d8ec55cc42dd029e39ca22abdaa909526fed6") + version("4.1.2", sha256="2036225e9f7207d4ce097e54972aecdaa8b40d7d9911cd26491fac5a0fab38af") + version("4.1.1", sha256="515e03265752257d0b7036f380f82e42b46ed8473f54f25c7b67ed25bbbdd364") + version("4.1.0", sha256="e8e68959d7282ca147360fc9644ada9bd161bab781bab14d33b8999a95182781") + version("4.0.5", sha256="0a3ee079aa772e131fe5435311ab627fcbccb5a50cabc54292e6f62046f1ffef") + version("4.0.4", sha256="523f27d69744a08c8f0bd5e1e6c3d89a4db29ed983388ba70963a3cd3a4a802e") + version("4.0.3", sha256="09983a8a78d5fb6bc45d27b1c55f9ba5265f78fa54a55c13ae691f87c5bb9e0d") + version("4.0.2", sha256="d3bceab364da0876625e4097808b42512395fdf41292f4915ab1fd257c1bbe75") + version("4.0.1", sha256="95fe24a4d8d8f8f888460c8f5fe4311cec656e7a1722d233218bc03861bc6f32") + version("4.0.0", sha256="06beb0291b569978484eb0dcb5d2339665ec745737bdfb4e873e7a5a75492940") + version("3.6.3", sha256="89302990d8e8add536e12125ec591d6951022cf8475861b3690bc8bf1cefaa8f") + version("3.6.2", sha256="bd65a45cddfb88f37370fbcee4ac8dd3f1aebeebe47c2f968fd9770ba2bbc954") + version("3.6.1", sha256="5baa9ebd3e71acecdcc3da31d9042fb174d55a42829f8315f2457080978b1389") + version("3.6.0", sha256="36fcac3e452666158e62459c6fc810adc247c7109ed71c5b6c3ad5fc2bf57509") + version("3.5.3", sha256="2bfa37b7bd709f003d6b8a172ddfb6d03ddd2d672d6096439523039f7a8e678c") + version("3.5.2", sha256="e53d8c3cf20f2b8d7a9c1631b6f6a22874506fb392034758b3bb341c586c5b62") + version("3.5.1", sha256="0463bff5eea0f3d93fa071f79c18d0993878fd4f2e18ae6cf22c1639d11457ed") + version("3.5.0", sha256="fd1725535e21797d3d9fea8963d99be0ba4c3aecadcf081b43e261458b416870") + version("3.4.4", sha256="b3e97d2fab7256d1c655c4075934725ba1cd7cb9237240a11bb22ccdad960337") + version("3.4.3", sha256="7a3cb831de5b4151e1f890113ed207527b7d4b16df9ec6b35e0964170007f426") + version("3.4.2", sha256="971e30c2436cf645f58552905105d75788bd9733bddbcb7c4fbff4c1a6d80c64") + version("3.4.1", sha256="02b1135d15ea969a3582caeb95594a05e830a6debcdb5b85ed2d5836a6a3fc78") + version("3.4.0", sha256="288e9ed42457c47720780433b3d5c3c20983048b789291cc6a7baa11f9428b91") + version("3.3.3", sha256="5ab768053a275084618fb669b4fbaadcc39158998a87e8465323829590bcfc6c") + version("3.3.2", sha256="d294ad21e9f574fb4828ebb3a94b8cb34f4f304a41687a994be00dd41a4e514c") + version("3.3.1", sha256="3dc59ae5831f5380f83c169bac2103ad052efe0ecec4ffa74bde4d85a0fda9e2") + version("3.3.0", sha256="9256b154b1a5993d844bee7b1955cd49c99ad72cef03cce3cd1bdca1310311e4") + version("3.2.5", sha256="60745672dce5ddc201806fa59f6d4e0ba6554d8ed78d0f9f0d79a629978f80b5") + version("3.2.3", sha256="b93b7d878138279234160f007cb9b7f81b8a72c012a15566e9ec5395cfd9b6c1") + version("3.2.2", sha256="9c9152e74134b68b0f3a1c7083764adc1cb56fd8336bec003fd0ca550cd2461d") + version("3.2.1", sha256="d59dbc3f04f4604a5cf0fb210b8ea703ef2438b3ee65fd5ab536ec5234f4c982") + version("3.2.0", sha256="f5ae953f18ba6f3d55b46556bbbf73441350f9fd22625402b723a2b81ff64f35") + version("3.1.3", sha256="07e98323935baa38079204bfb9414a029704bb9c0ca5ab317020ae521a377312") + version("3.1.2", sha256="bcd150afcae0e02f6efb5f35a6ab72432be82e849ec52ce0bb89d8c342a8fa7a") + + variant("X", default=False, description="Enable X11 support (TCLTK, PNG, JPEG, TIFF, CAIRO)") + variant("memory_profiling", default=False, description="Enable memory profiling") + variant("rmath", default=False, description="Build standalone Rmath library") + + depends_on("blas") + depends_on("lapack") + + depends_on("bzip2") + depends_on("curl+libidn2") + # R didn't anticipate the celebratory non-breaking major version bump of curl 8. + depends_on("curl@:7", when="@:4.2") + depends_on("icu4c") + depends_on("java") + depends_on("libtirpc") + depends_on("ncurses") + depends_on("pcre", when="@:3.6.3") + depends_on("pcre2", when="@4:") + depends_on("readline") + depends_on("xz") + depends_on("which", type=("build", "run")) + depends_on("zlib-api") + depends_on("zlib@1.2.5:", when="^[virtuals=zlib-api] zlib") + depends_on("texinfo", type="build") + + with when("+X"): + depends_on("cairo+X+gobject+pdf") + depends_on("pango+X") + depends_on("harfbuzz+graphite2") + depends_on("jpeg") + depends_on("libpng") + depends_on("libtiff") + depends_on("libx11") + depends_on("libxmu") + depends_on("libxt") + depends_on("tk") + + patch("zlib.patch", when="@:3.3.2") + + # R cannot be built with '-O2' optimization + # with Fujitsu Compiler @4.1.0 now. + # Until the Fujitsu compiler resolves this problem, + # temporary fix to lower the optimization level. + patch("change_optflags_tmp.patch", when="%fj@4.1.0") + + # Make R use a symlink to which in Sys.which, otherwise an absolute path + # gets stored as compressed byte code, which is not relocatable + patch("relocate-which.patch") + + # CVE-2024-27322 Patch only needed in R 4.3.3 and below; doesn't apply to R older than 3.5.0. + patch( + "https://github.com/r-devel/r-svn/commit/f7c46500f455eb4edfc3656c3fa20af61b16abb7.patch?full_index=1", + sha256="56c77763cb104aa9cb63420e585da63cb2c23bc03fa3ef9d088044eeff9d7380", + when="@3.5.0:4.3.3", + ) + + build_directory = "spack-build" + + # R custom URL version + def url_for_version(self, version): + """Handle R's customed URL versions""" + url = "https://cloud.r-project.org/src/base" + return url + "/R-%s/R-%s.tar.gz" % (version.up_to(1), version) + + @property + def etcdir(self): + return join_path(prefix, "rlib", "R", "etc") + + @run_after("install") + def install_rmath(self): + if "+rmath" in self.spec: + with working_dir(join_path(self.build_directory, "src", "nmath", "standalone")): + make() + make("install", parallel=False) + + def configure_args(self): + spec = self.spec + prefix = self.prefix + + extra_rpath = join_path(prefix, "rlib", "R", "lib") + + blas_flags: str = spec["blas"].libs.ld_flags + lapack_flags: str = spec["lapack"].libs.ld_flags + + # R uses LAPACK in Fortran, which requires libmkl_gf_* when gfortran is used. + # TODO: cleaning this up seem to require both compilers as dependencies and use variants. + if spec["lapack"].name in INTEL_MATH_LIBRARIES and "gfortran" in self.compiler.fc: + xlp64 = "ilp64" if spec["lapack"].satisfies("+ilp64") else "lp64" + blas_flags = blas_flags.replace(f"mkl_intel_{xlp64}", f"mkl_gf_{xlp64}") + lapack_flags = lapack_flags.replace(f"mkl_intel_{xlp64}", f"mkl_gf_{xlp64}") + + config_args = [ + "--with-internal-tzcode", + "--libdir={0}".format(join_path(prefix, "rlib")), + "--enable-R-shlib", + "--enable-R-framework=no", + "--without-recommended-packages", + f"LDFLAGS=-Wl,-rpath,{extra_rpath}", + f"--with-blas={blas_flags}", + f"--with-lapack={lapack_flags}", + # cannot disable docs with a normal configure option + "ac_cv_path_PDFLATEX=", + "ac_cv_path_PDFTEX=", + "ac_cv_path_TEX=", + "ac_cv_path_TEXI2DVI=", + ] + + if "+X" in spec: + config_args.append("--with-cairo") + config_args.append("--with-jpeglib") + config_args.append("--with-libpng") + config_args.append("--with-libtiff") + config_args.append("--with-tcltk") + config_args.append("--with-x") + + tcl_config_path = join_path(spec["tcl"].libs.directories[0], "tclConfig.sh") + config_args.append("--with-tcl-config={0}".format(tcl_config_path)) + + tk_config_path = join_path(spec["tk"].libs.directories[0], "tkConfig.sh") + config_args.append("--with-tk-config={0}".format(tk_config_path)) + else: + config_args.append("--without-cairo") + config_args.append("--without-jpeglib") + config_args.append("--without-libpng") + config_args.append("--without-libtiff") + config_args.append("--without-tcltk") + config_args.append("--without-x") + + if "+memory_profiling" in spec: + config_args.append("--enable-memory-profiling") + + # Set FPICFLAGS for compilers except 'gcc'. + if self.compiler.name != "gcc": + config_args.append("FPICFLAGS={0}".format(self.compiler.cc_pic_flag)) + + if self.spec.satisfies("@:3.6.1 %gcc@10:"): + config_args.append("CFLAGS=-fcommon") + config_args.append("FFLAGS=-fallow-argument-mismatch") + + return config_args + + @run_after("install") + def copy_makeconf(self): + # Make a copy of Makeconf because it will be needed to properly build R + # dependencies in Spack. + src_makeconf = join_path(self.etcdir, "Makeconf") + dst_makeconf = join_path(self.etcdir, "Makeconf.spack") + install(src_makeconf, dst_makeconf) + + # To respect order of execution, we should filter after we made the copy above + filter_compiler_wrappers("Makeconf", relative_root=os.path.join("rlib", "R", "etc")) + + # ======================================================================== + # Set up environment to make install easy for R extensions. + # ======================================================================== + + @property + def r_lib_dir(self): + return join_path("rlib", "R", "library") + + def setup_dependent_build_environment(self, env, dependent_spec): + # Set R_LIBS to include the library dir for the + # extension and any other R extensions it depends on. + r_libs_path = [] + for d in dependent_spec.traverse(deptype=("build", "run")): + if d.package.extends(self.spec): + r_libs_path.append(join_path(d.prefix, self.r_lib_dir)) + + r_libs_path = ":".join(r_libs_path) + env.set("R_LIBS", r_libs_path) + # R_LIBS_USER gets set to a directory in HOME/R if it is not set, such as + # during package installation with the --vanilla flag. Set it to null + # to ensure that it does not point to a directory that may contain R + # packages. + env.set("R_LIBS_USER", "") + env.set("R_MAKEVARS_SITE", join_path(self.etcdir, "Makeconf.spack")) + + # Use the number of make_jobs set in spack. The make program will + # determine how many jobs can actually be started. + env.set("MAKEFLAGS", "-j{0}".format(make_jobs)) + env.set("R_HOME", join_path(self.prefix, "rlib", "R")) + + def setup_dependent_run_environment(self, env, dependent_spec): + # For run time environment set only the path for dependent_spec and + # prepend it to R_LIBS + env.set("R_HOME", join_path(self.prefix, "rlib", "R")) + if dependent_spec.package.extends(self.spec): + env.prepend_path("R_LIBS", join_path(dependent_spec.prefix, self.r_lib_dir)) + + def setup_run_environment(self, env): + env.prepend_path("LD_LIBRARY_PATH", join_path(self.prefix, "rlib", "R", "lib")) + env.prepend_path("PKG_CONFIG_PATH", join_path(self.prefix, "rlib", "pkgconfig")) + env.set("R_HOME", join_path(self.prefix, "rlib", "R")) + + if "+rmath" in self.spec: + env.prepend_path("LD_LIBRARY_PATH", join_path(self.prefix, "rlib")) + + def setup_dependent_package(self, module, dependent_spec): + """Called before R modules' install() methods. In most cases, + extensions will only need to have one line: + R('CMD', 'INSTALL', '--library={0}'.format(self.module.r_lib_dir), + self.stage.source_path)""" + + # R extension builds can have a global R executable function + module.R = Executable(join_path(self.spec.prefix.bin, "R")) + + # Add variable for library directry + module.r_lib_dir = join_path(dependent_spec.prefix, self.r_lib_dir) + + # Make the site packages directory for extensions, if it does not exist + # already. + if dependent_spec.package.is_extension: + mkdirp(module.r_lib_dir) diff --git a/recipes/mch/climana/24.10/repo/packages/r/package.py.back b/recipes/mch/climana/24.10/repo/packages/r/package.py.back new file mode 100644 index 00000000..df61847b --- /dev/null +++ b/recipes/mch/climana/24.10/repo/packages/r/package.py.back @@ -0,0 +1,262 @@ +# Copyright 2013-2023 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) + +import os +import re + +from spack.package import * + + +class R(AutotoolsPackage): + """R is 'GNU S', a freely available language and environment for + statistical computing and graphics which provides a wide variety of + statistical and graphical techniques: linear and nonlinear modelling, + statistical tests, time series analysis, classification, clustering, etc. + Please consult the R project homepage for further information.""" + + homepage = "https://www.r-project.org" + url = "https://cloud.r-project.org/src/base/R-3/R-3.4.3.tar.gz" + + extendable = True + + maintainers("glennpj") + + version("4.2.2", sha256="0ff62b42ec51afa5713caee7c4fde7a0c45940ba39bef8c5c9487fef0c953df5") + version("4.2.1", sha256="4d52db486d27848e54613d4ee977ad952ec08ce17807e1b525b10cd4436c643f") + version("4.2.0", sha256="38eab7719b7ad095388f06aa090c5a2b202791945de60d3e2bb0eab1f5097488") + version("4.1.3", sha256="15ff5b333c61094060b2a52e9c1d8ec55cc42dd029e39ca22abdaa909526fed6") + version("4.1.2", sha256="2036225e9f7207d4ce097e54972aecdaa8b40d7d9911cd26491fac5a0fab38af") + version("4.1.1", sha256="515e03265752257d0b7036f380f82e42b46ed8473f54f25c7b67ed25bbbdd364") + version("4.1.0", sha256="e8e68959d7282ca147360fc9644ada9bd161bab781bab14d33b8999a95182781") + version("4.0.5", sha256="0a3ee079aa772e131fe5435311ab627fcbccb5a50cabc54292e6f62046f1ffef") + version("4.0.4", sha256="523f27d69744a08c8f0bd5e1e6c3d89a4db29ed983388ba70963a3cd3a4a802e") + version("4.0.3", sha256="09983a8a78d5fb6bc45d27b1c55f9ba5265f78fa54a55c13ae691f87c5bb9e0d") + version("4.0.2", sha256="d3bceab364da0876625e4097808b42512395fdf41292f4915ab1fd257c1bbe75") + version("4.0.1", sha256="95fe24a4d8d8f8f888460c8f5fe4311cec656e7a1722d233218bc03861bc6f32") + version("4.0.0", sha256="06beb0291b569978484eb0dcb5d2339665ec745737bdfb4e873e7a5a75492940") + version("3.6.3", sha256="89302990d8e8add536e12125ec591d6951022cf8475861b3690bc8bf1cefaa8f") + version("3.6.2", sha256="bd65a45cddfb88f37370fbcee4ac8dd3f1aebeebe47c2f968fd9770ba2bbc954") + version("3.6.1", sha256="5baa9ebd3e71acecdcc3da31d9042fb174d55a42829f8315f2457080978b1389") + version("3.6.0", sha256="36fcac3e452666158e62459c6fc810adc247c7109ed71c5b6c3ad5fc2bf57509") + version("3.5.3", sha256="2bfa37b7bd709f003d6b8a172ddfb6d03ddd2d672d6096439523039f7a8e678c") + version("3.5.2", sha256="e53d8c3cf20f2b8d7a9c1631b6f6a22874506fb392034758b3bb341c586c5b62") + version("3.5.1", sha256="0463bff5eea0f3d93fa071f79c18d0993878fd4f2e18ae6cf22c1639d11457ed") + version("3.5.0", sha256="fd1725535e21797d3d9fea8963d99be0ba4c3aecadcf081b43e261458b416870") + version("3.4.4", sha256="b3e97d2fab7256d1c655c4075934725ba1cd7cb9237240a11bb22ccdad960337") + version("3.4.3", sha256="7a3cb831de5b4151e1f890113ed207527b7d4b16df9ec6b35e0964170007f426") + version("3.4.2", sha256="971e30c2436cf645f58552905105d75788bd9733bddbcb7c4fbff4c1a6d80c64") + version("3.4.1", sha256="02b1135d15ea969a3582caeb95594a05e830a6debcdb5b85ed2d5836a6a3fc78") + version("3.4.0", sha256="288e9ed42457c47720780433b3d5c3c20983048b789291cc6a7baa11f9428b91") + version("3.3.3", sha256="5ab768053a275084618fb669b4fbaadcc39158998a87e8465323829590bcfc6c") + version("3.3.2", sha256="d294ad21e9f574fb4828ebb3a94b8cb34f4f304a41687a994be00dd41a4e514c") + version("3.3.1", sha256="3dc59ae5831f5380f83c169bac2103ad052efe0ecec4ffa74bde4d85a0fda9e2") + version("3.3.0", sha256="9256b154b1a5993d844bee7b1955cd49c99ad72cef03cce3cd1bdca1310311e4") + version("3.2.5", sha256="60745672dce5ddc201806fa59f6d4e0ba6554d8ed78d0f9f0d79a629978f80b5") + version("3.2.3", sha256="b93b7d878138279234160f007cb9b7f81b8a72c012a15566e9ec5395cfd9b6c1") + version("3.2.2", sha256="9c9152e74134b68b0f3a1c7083764adc1cb56fd8336bec003fd0ca550cd2461d") + version("3.2.1", sha256="d59dbc3f04f4604a5cf0fb210b8ea703ef2438b3ee65fd5ab536ec5234f4c982") + version("3.2.0", sha256="f5ae953f18ba6f3d55b46556bbbf73441350f9fd22625402b723a2b81ff64f35") + version("3.1.3", sha256="07e98323935baa38079204bfb9414a029704bb9c0ca5ab317020ae521a377312") + version("3.1.2", sha256="bcd150afcae0e02f6efb5f35a6ab72432be82e849ec52ce0bb89d8c342a8fa7a") + + variant( + "external-lapack", default=False, description="Links to externally installed BLAS/LAPACK" + ) + variant("X", default=False, description="Enable X11 support (TCLTK, PNG, JPEG, TIFF, CAIRO)") + variant("memory_profiling", default=False, description="Enable memory profiling") + variant("rmath", default=False, description="Build standalone Rmath library") + + depends_on("blas", when="+external-lapack") + depends_on("lapack", when="+external-lapack") + depends_on("bzip2") + # R didn't anticipate the celebratory + # non-breaking major version bump of curl 8. + depends_on("curl+libidn2@:7") + depends_on("icu4c") + depends_on("java") + depends_on("ncurses") + depends_on("pcre", when="@:3.6.3") + depends_on("pcre2", when="@4:") + depends_on("readline") + depends_on("xz") + depends_on("which", type=("build", "run")) + depends_on("zlib@1.2.5:") + depends_on("texinfo", type="build") + depends_on("cairo+X+gobject+pdf", when="+X") + depends_on("pango+X", when="+X") + depends_on("harfbuzz+graphite2", when="+X") + depends_on("jpeg", when="+X") + depends_on("libpng", when="+X") + depends_on("libtiff", when="+X") + depends_on("libx11", when="+X") + depends_on("libxmu", when="+X") + depends_on("libxt", when="+X") + depends_on("tk", when="+X") + + patch("zlib.patch", when="@:3.3.2") + + # R cannot be built with '-O2' optimization + # with Fujitsu Compiler @4.1.0 now. + # Until the Fujitsu compiler resolves this problem, + # temporary fix to lower the optimization level. + patch("change_optflags_tmp.patch", when="%fj@4.1.0") + + # R custom URL version + def url_for_version(self, version): + """Handle R's customed URL versions""" + url = "https://cloud.r-project.org/src/base" + return url + "/R-%s/R-%s.tar.gz" % (version.up_to(1), version) + + @property + def etcdir(self): + return join_path(prefix, "rlib", "R", "etc") + + @run_after("install") + def install_rmath(self): + if "+rmath" in self.spec: + with working_dir("src/nmath/standalone"): + make() + make("install", parallel=False) + + def configure_args(self): + spec = self.spec + prefix = self.prefix + + config_args = [ + "--libdir={0}".format(join_path(prefix, "rlib")), + "--enable-R-shlib", + "--enable-BLAS-shlib", + "--enable-R-framework=no", + "--without-recommended-packages", + "LDFLAGS=-L{0} -Wl,-rpath,{0}".format(join_path(prefix, "rlib", "R", "lib")), + # cannot disable docs with a normal configure option + "ac_cv_path_PDFLATEX=", + "ac_cv_path_PDFTEX=", + "ac_cv_path_TEX=", + "ac_cv_path_TEXI2DVI=", + ] + + if "+external-lapack" in spec: + if "^mkl" in spec and "gfortran" in self.compiler.fc: + mkl_re = re.compile(r"(mkl_)intel(_i?lp64\b)") + config_args.extend( + [ + mkl_re.sub( + r"\g<1>gf\g<2>", "--with-blas={0}".format(spec["blas"].libs.ld_flags) + ), + "--with-lapack", + ] + ) + else: + config_args.extend( + ["--with-blas={0}".format(spec["blas"].libs.ld_flags), "--with-lapack"] + ) + + if "+X" in spec: + config_args.append("--with-cairo") + config_args.append("--with-jpeglib") + config_args.append("--with-libpng") + config_args.append("--with-libtiff") + config_args.append("--with-tcltk") + config_args.append("--with-x") + + tcl_config_path = join_path(spec["tcl"].libs.directories[0], "tclConfig.sh") + config_args.append("--with-tcl-config={0}".format(tcl_config_path)) + + tk_config_path = join_path(spec["tk"].libs.directories[0], "tkConfig.sh") + config_args.append("--with-tk-config={0}".format(tk_config_path)) + else: + config_args.append("--without-cairo") + config_args.append("--without-jpeglib") + config_args.append("--without-libpng") + config_args.append("--without-libtiff") + config_args.append("--without-tcltk") + config_args.append("--without-x") + + if "+memory_profiling" in spec: + config_args.append("--enable-memory-profiling") + + # Set FPICFLAGS for compilers except 'gcc'. + if self.compiler.name != "gcc": + config_args.append("FPICFLAGS={0}".format(self.compiler.cc_pic_flag)) + + if self.spec.satisfies("@:3.6.1 %gcc@10:"): + config_args.append("CFLAGS=-fcommon") + config_args.append("FFLAGS=-fallow-argument-mismatch") + + return config_args + + @run_after("install") + def copy_makeconf(self): + # Make a copy of Makeconf because it will be needed to properly build R + # dependencies in Spack. + src_makeconf = join_path(self.etcdir, "Makeconf") + dst_makeconf = join_path(self.etcdir, "Makeconf.spack") + install(src_makeconf, dst_makeconf) + + # To respect order of execution, we should filter after we made the copy above + filter_compiler_wrappers("Makeconf", relative_root=os.path.join("rlib", "R", "etc")) + + # ======================================================================== + # Set up environment to make install easy for R extensions. + # ======================================================================== + + @property + def r_lib_dir(self): + return join_path("rlib", "R", "library") + + def setup_dependent_build_environment(self, env, dependent_spec): + # Set R_LIBS to include the library dir for the + # extension and any other R extensions it depends on. + r_libs_path = [] + for d in dependent_spec.traverse(deptype=("build", "run")): + if d.package.extends(self.spec): + r_libs_path.append(join_path(d.prefix, self.r_lib_dir)) + + r_libs_path = ":".join(r_libs_path) + env.set("R_LIBS", r_libs_path) + # R_LIBS_USER gets set to a directory in HOME/R if it is not set, such as + # during package installation with the --vanilla flag. Set it to null + # to ensure that it does not point to a directory that may contain R + # packages. + env.set("R_LIBS_USER", "") + env.set("R_MAKEVARS_SITE", join_path(self.etcdir, "Makeconf.spack")) + + # Use the number of make_jobs set in spack. The make program will + # determine how many jobs can actually be started. + env.set("MAKEFLAGS", "-j{0}".format(make_jobs)) + env.set("R_HOME", join_path(self.prefix, "rlib", "R")) + + def setup_dependent_run_environment(self, env, dependent_spec): + # For run time environment set only the path for dependent_spec and + # prepend it to R_LIBS + env.set("R_HOME", join_path(self.prefix, "rlib", "R")) + if dependent_spec.package.extends(self.spec): + env.prepend_path("R_LIBS", join_path(dependent_spec.prefix, self.r_lib_dir)) + + def setup_run_environment(self, env): + env.prepend_path("LD_LIBRARY_PATH", join_path(self.prefix, "rlib", "R", "lib")) + env.prepend_path("PKG_CONFIG_PATH", join_path(self.prefix, "rlib", "pkgconfig")) + env.set("R_HOME", join_path(self.prefix, "rlib", "R")) + + if "+rmath" in self.spec: + env.prepend_path("LD_LIBRARY_PATH", join_path(self.prefix, "rlib")) + + def setup_dependent_package(self, module, dependent_spec): + """Called before R modules' install() methods. In most cases, + extensions will only need to have one line: + R('CMD', 'INSTALL', '--library={0}'.format(self.module.r_lib_dir), + self.stage.source_path)""" + + # R extension builds can have a global R executable function + module.R = Executable(join_path(self.spec.prefix.bin, "R")) + + # Add variable for library directry + module.r_lib_dir = join_path(dependent_spec.prefix, self.r_lib_dir) + + # Make the site packages directory for extensions, if it does not exist + # already. + if dependent_spec.package.is_extension: + mkdirp(module.r_lib_dir) diff --git a/recipes/mch/climana/24.10/repo/packages/r/relocate-which.patch b/recipes/mch/climana/24.10/repo/packages/r/relocate-which.patch new file mode 100644 index 00000000..d8e18e18 --- /dev/null +++ b/recipes/mch/climana/24.10/repo/packages/r/relocate-which.patch @@ -0,0 +1,52 @@ +From 3f2b1b6c94460fd4d3e9f03c9f17a25db2d2b473 Mon Sep 17 00:00:00 2001 +From: Harmen Stoppels +Date: Wed, 10 Jan 2024 12:40:40 +0100 +Subject: [PATCH] base: use a symlink for which instead of hard-coded string + +--- + share/make/basepkg.mk | 8 ++++---- + src/library/base/R/unix/system.unix.R | 6 +++--- + 2 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/share/make/basepkg.mk b/share/make/basepkg.mk +index c0a69c8a0af338ec002156236e47b9d7efea8165..4cf6387870915001cbb8b1439509ff4955cc67b1 100644 +--- a/share/make/basepkg.mk ++++ b/share/make/basepkg.mk +@@ -72,16 +72,16 @@ mkRbase: + else \ + cat $(RSRC) > "$${f}"; \ + fi; \ +- f2=$${TMPDIR:-/tmp}/R2$$$$; \ +- sed -e "s:@WHICH@:${WHICH}:" "$${f}" > "$${f2}"; \ +- rm -f "$${f}"; \ +- $(SHELL) $(top_srcdir)/tools/move-if-change "$${f2}" all.R) ++ $(SHELL) $(top_srcdir)/tools/move-if-change "$${f}" all.R) + @if ! test -f $(top_builddir)/library/$(pkg)/R/$(pkg); then \ + $(INSTALL_DATA) all.R $(top_builddir)/library/$(pkg)/R/$(pkg); \ + else if test all.R -nt $(top_builddir)/library/$(pkg)/R/$(pkg); then \ + $(INSTALL_DATA) all.R $(top_builddir)/library/$(pkg)/R/$(pkg); \ + fi \ + fi ++ @if ! test -f $(top_builddir)/library/$(pkg)/R/which; then \ ++ cd $(top_builddir)/library/$(pkg)/R/ && $(LN_S) $(WHICH) which; \ ++ fi + + mkdesc: + @if test -f DESCRIPTION; then \ +diff --git a/src/library/base/R/unix/system.unix.R b/src/library/base/R/unix/system.unix.R +index 3bb7d0cb27cc73a024bcea3e41e2e0c5c7e9648a..78271c8c12cb3217bc068e9d53ef9e3060e8dcc9 100644 +--- a/src/library/base/R/unix/system.unix.R ++++ b/src/library/base/R/unix/system.unix.R +@@ -114,9 +114,9 @@ system2 <- function(command, args = character(), + Sys.which <- function(names) + { + res <- character(length(names)); names(res) <- names +- ## hopefully configure found [/usr]/bin/which +- which <- "@WHICH@" +- if (!nzchar(which)) { ++ which <- file.path(R.home(), "library", "base", "R", "which") ++ ## which should be a symlink to the system's which ++ if (!file.exists(which)) { + warning("'which' was not found on this platform") + return(res) + } diff --git a/recipes/mch/climana/24.10/repo/packages/r/zlib.patch b/recipes/mch/climana/24.10/repo/packages/r/zlib.patch new file mode 100644 index 00000000..673d5352 --- /dev/null +++ b/recipes/mch/climana/24.10/repo/packages/r/zlib.patch @@ -0,0 +1,29 @@ +*** a/configure 2017-01-21 21:48:35.077000000 +0000 +--- b/configure 2017-01-21 21:50:50.700000000 +0000 +*************** +*** 35496,35505 **** + #include + #include + int main() { +! #ifdef ZLIB_VERSION +! /* Work around Debian bug: it uses 1.2.3.4 even though there was no such +! version on the master site zlib.net */ +! exit(strncmp(ZLIB_VERSION, "1.2.5", 5) < 0); + #else + exit(1); + #endif +--- 35496,35509 ---- + #include + #include + int main() { +! /* Checking ZLIB_VERNUM trick learned here: +! * https://github.com/TransitApp/protobuf/blob/master/configure.ac#L95 +! */ +! #ifdef ZLIB_VERNUM +! if (ZLIB_VERNUM < 0x1250) { +! exit(1); +! } +! exit(0); + #else + exit(1); + #endif