summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/steps/package.py
blob: 7d6c59657a58ff6459d559ba3777b0e338537a88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# 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)

from spack.package import *


class Steps(CMakePackage):
    """STochastic Engine for Pathway Simulation"""

    homepage = "https://groups.oist.jp/cnu/software"
    git = "https://github.com/CNS-OIST/STEPS.git"

    maintainers("tristan0x")

    license("GPL-3.0-or-later")

    version("develop", branch="master", submodules=True)
    version("4.1.1", submodules=True)

    variant(
        "codechecks",
        default=False,
        description="Perform additional code checks like code formatting or static analysis",
    )
    variant("lapack", default=False, description="Use new BDSystem/Lapack code for E-Field solver")
    variant(
        "distmesh", default=True, when="+mpi", description="Add solvers based on distributed mesh"
    )
    variant("petsc", default=True, description="Use PETSc library for parallel E-Field solver")
    variant("mpi", default=True, description="Use MPI for parallel solvers")
    variant("coverage", default=False, description="Enable code coverage")
    variant("bundle", default=False, description="Use bundled libraries")
    variant("stochtests", default=True, description="Add stochastic tests to ctests")
    variant(
        "build_type",
        default="RelWithDebInfo",
        description="CMake build type",
        values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel", "RelWithDebInfoAndAssert"),
    )
    variant(
        "caliper", default=False, description="Build in caliper support (Instrumentor Interface)"
    )
    variant(
        "likwid", default=False, description="Build in likwid support (Instrumentor Interface)"
    )

    # Build with `ninja` instead of `make`
    generator("ninja")

    depends_on("benchmark", type=("build", "test"))
    depends_on("blas")
    depends_on("boost", type="build")
    depends_on("caliper", when="+caliper")
    depends_on("easyloggingpp", when="~bundle")
    depends_on("gmsh", when="+distmesh")
    depends_on("lapack", when="+lapack")
    depends_on("lcov", when="+coverage", type="build")
    depends_on("likwid", when="+likwid")
    depends_on("metis+int64")
    depends_on("mpi", when="+mpi")
    depends_on("omega-h+gmsh+mpi", when="~bundle+distmesh")
    depends_on("petsc~debug+int64+mpi", when="+petsc+mpi")
    depends_on("petsc~debug+int64~mpi", when="+petsc~mpi")
    depends_on("pkgconfig", type="build")
    depends_on("py-cython")
    depends_on("py-gcovr", when="+coverage", type="build")
    depends_on("py-h5py", type=("build", "test", "run"))
    depends_on("py-matplotlib", type=("build", "test"))
    depends_on("py-mpi4py", when="+distmesh", type=("build", "test", "run"))
    depends_on("py-numpy", type=("build", "test", "run"))
    depends_on("py-scipy", type=("build", "test", "run"))
    depends_on("python", type=("build", "test", "run"))
    depends_on("random123", when="~bundle")
    depends_on("sundials@:2.99.99+int64", when="~bundle")

    patch("for_aarch64.patch", when="target=aarch64:")

    def patch(self):
        # easylogging requires compilation by
        # its dependents: splice in disabling all errors
        filter_file(r"(-Wno-double-promotion)", r"-Wno-error \1", "src/steps/util/CMakeLists.txt")

    def cmake_args(self):
        args = [
            self.define("BLAS_LIBRARIES", self.spec["blas"].libs.joined(";")),
            self.define("PYTHON_EXECUTABLE", self.spec["python"].command),
            self.define("STEPS_INSTALL_PYTHON_DEPS", False),
            self.define_from_variant("BUILD_STOCHASTIC_TESTS", "stochtests"),
            self.define_from_variant("BUILD_TESTING", "codechecks"),
            self.define_from_variant("ENABLE_CODECOVERAGE", "coverage"),
            self.define_from_variant("STEPS_ENABLE_ERROR_ON_WARNING", "codechecks"),
            self.define_from_variant("STEPS_TEST_FORMATTING", "codechecks"),
            self.define_from_variant("STEPS_USE_CALIPER_PROFILING", "caliper"),
            self.define_from_variant("STEPS_USE_DIST_MESH", "distmesh"),
            self.define_from_variant("STEPS_USE_LIKWID_PROFILING", "likwid"),
            self.define_from_variant("USE_BDSYSTEM_LAPACK", "lapack"),
            self.define_from_variant("USE_MPI", "mpi"),
            self.define_from_variant("USE_PETSC", "petsc"),
        ]

        args.extend(
            [
                self.define_from_variant(f"USE_BUNDLE_{bundle}", "bundle")
                for bundle in ["EASYLOGGINGPP", "OMEGA_H", "RANDOM123", "SUNDIALS", "SUPERLU_DIST"]
            ]
        )

        return args

    @property
    def build_targets(self):
        targets = []
        if "+coverage" in self.spec:
            if self.compiler.name != "gcc":
                raise ValueError(
                    "Package " + self.name + " build with coverage enabled requires GCC to build"
                )
            targets = [
                "CTEST_OUTPUT_ON_FAILURE=1",
                "all",  # build
                "coverage_init",  # initialize coverage counters
                "test",  # run tests suite
                "coverage",  # collect coverage counters and build reports
            ]
        return targets

    def setup_run_environment(self, env):
        # This recipe exposes a Python package from a C++ CMake project.
        # This hook is required to reproduce what Spack PythonPackage does.
        env.prepend_path("PYTHONPATH", self.prefix)