summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Johnson <glenn-johnson@uiowa.edu>2022-08-25 13:58:31 -0500
committerGitHub <noreply@github.com>2022-08-25 11:58:31 -0700
commitc2291f7eb3560c552b9dfedda9a62787a9347440 (patch)
tree28388e756319a6d1b55e17331d6af3bdc6c2f06a
parent925a99a043866fac44a6b645c1c8f82b32edbfdf (diff)
downloadspack-c2291f7eb3560c552b9dfedda9a62787a9347440.tar.gz
spack-c2291f7eb3560c552b9dfedda9a62787a9347440.tar.bz2
spack-c2291f7eb3560c552b9dfedda9a62787a9347440.tar.xz
spack-c2291f7eb3560c552b9dfedda9a62787a9347440.zip
new packages: r-cmdstanr and cmdstan (#32364)
-rw-r--r--var/spack/repos/builtin/packages/cmdstan/package.py83
-rw-r--r--var/spack/repos/builtin/packages/r-cmdstanr/package.py34
2 files changed, 117 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/cmdstan/package.py b/var/spack/repos/builtin/packages/cmdstan/package.py
new file mode 100644
index 0000000000..a4e182a657
--- /dev/null
+++ b/var/spack/repos/builtin/packages/cmdstan/package.py
@@ -0,0 +1,83 @@
+# Copyright 2013-2022 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.package import *
+
+
+class Cmdstan(MakefilePackage):
+ """CmdStan is the command line interface to Stan."""
+
+ homepage = "https://mc-stan.org/users/interfaces/cmdstan"
+ url = "https://github.com/stan-dev/cmdstan/releases/download/v2.30.1/cmdstan-2.30.1.tar.gz"
+
+ version("2.30.1", sha256="bab76dcefa7f4c955595c0bf0496770507fc6ab0df5896e8cf8c2db0a17eedb9")
+
+ variant("threads", default=True, description="enable thread support")
+ variant("opencl", default=False, description="enable OpenCl support")
+ variant("mpi", default=False, description="enable MPI support")
+
+ depends_on("opencl", when="+opencl")
+ depends_on("mpi", when="+mpi")
+
+ build_targets = ["build"]
+
+ filter_compiler_wrappers("local", relative_root="make")
+
+ def edit(self, spec, prefix):
+ if spec.compiler.name == "intel":
+ cxx_type = "icc"
+ else:
+ cxx_type = spec.compiler.name
+
+ if "+mpi" in spec:
+ cxx = spec["mpi"].mpicxx
+ else:
+ cxx = spack_cxx
+
+ make_options = [
+ "CXX={0}\n".format(cxx),
+ "CXXFLAGS+= -O2 -funroll-loops\n",
+ "LDFLAGS+={0}{1}\n".format(
+ self.compiler.cc_rpath_arg,
+ join_path(prefix, "stan", "lib", "stan_math", "lib", "tbb"),
+ ),
+ "STANCFLAGS+= --warn-pedantic\n",
+ "TBB_CXX_TYPE={0}\n".format(cxx_type),
+ ]
+
+ if "+threads" in spec:
+ make_options.append("STAN_THREADS=true\n")
+
+ if "+opencl" in spec:
+ make_options.append("STAN_OPENCL=true\n")
+
+ if "+mpi" in spec:
+ make_options.append("STAN_MPI=true\n")
+
+ filepath = join_path(self.stage.source_path, "make", "local")
+ with open(filepath, "w") as make_file:
+ make_file.writelines(make_options)
+
+ def install(self, spec, prefix):
+ make(join_path("examples", "bernoulli", "bernoulli"))
+
+ mkdir(prefix.bin)
+
+ with working_dir(self.build_directory):
+ copy("makefile", prefix)
+ copy_tree("make", prefix.make)
+ copy_tree("examples", prefix.examples)
+ copy_tree("lib", prefix.lib)
+ copy_tree("src", prefix.src)
+ copy_tree("stan", prefix.stan)
+
+ with working_dir(join_path(self.build_directory, "bin")):
+ install("diagnose", prefix.bin)
+ install("print", prefix.bin)
+ install("stanc", prefix.bin)
+ install("stansummary", prefix.bin)
+
+ def setup_run_environment(self, env):
+ env.set("CMDSTAN", self.prefix)
diff --git a/var/spack/repos/builtin/packages/r-cmdstanr/package.py b/var/spack/repos/builtin/packages/r-cmdstanr/package.py
new file mode 100644
index 0000000000..d55dc23360
--- /dev/null
+++ b/var/spack/repos/builtin/packages/r-cmdstanr/package.py
@@ -0,0 +1,34 @@
+# Copyright 2013-2022 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.package import *
+
+
+class RCmdstanr(RPackage):
+ """R Interface to 'CmdStan'.
+
+ A lightweight interface to 'Stan' <https://mc-stan.org>. The 'CmdStanR'
+ interface is an alternative to 'RStan' that calls the command line
+ interface for compilation and running algorithms instead of interfacing
+ with C++ via 'Rcpp'. This has many benefits including always being
+ compatible with the latest version of Stan, fewer installation errors,
+ fewer unexpected crashes in RStudio, and a more permissive license."""
+
+ homepage = "https://mc-stan.org/cmdstanr/"
+ url = "https://github.com/stan-dev/cmdstanr/archive/refs/tags/v0.5.3.tar.gz"
+
+ version("0.5.3", sha256="dafd5808e1a17d2e4ae4048437235b4399464a7c65de68ba4af0ab2b03e27871")
+ version("0.5.2", sha256="5bc2e164e7cce3bfb93d592df5e3059157c8d510b136535bdb6d09c3ef060f64")
+ version("0.5.1", sha256="5b3e83d48c19d309ccca720979449a8ac130ba7e443e70992b1771a1dd9124c9")
+
+ depends_on("r@3.5.0:", type=("build", "run"))
+ depends_on("r-checkmate", type=("build", "run"))
+ depends_on("r-data-table", type=("build", "run"))
+ depends_on("r-jsonlite@1.2.0:", type=("build", "run"))
+ depends_on("r-posterior@1.1.0:", type=("build", "run"))
+ depends_on("r-processx@3.5.0:", type=("build", "run"))
+ depends_on("r-r6@2.4.0:", type=("build", "run"))
+ depends_on("r-withr@2.5.0:", type=("build", "run"), when="@0.5.2:")
+ depends_on("cmdstan", type="run")