summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/py-pynucleus/package.py
blob: ed5029109e7818fb5efb3a3fad903c3b8d0ca63a (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
# 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 PyPynucleus(PythonPackage):
    """PyNucleus is a finite element code that specifically targets nonlocal operators."""

    homepage = "https://sandialabs.github.io/PyNucleus/index.html"
    git = "https://github.com/sandialabs/PyNucleus.git"

    maintainers("cgcgcg")

    refs = ["master", "develop"]

    license("MIT")

    for ref in refs:
        version(ref, branch=ref)

    variant("examples", default=True, description="Install examples")
    variant("tests", default=True, description="Install tests")

    depends_on("python@3.10:", type=("build", "run"))
    depends_on("py-mpi4py@2.0.0:", type=("build", "link", "run"))
    depends_on("py-cython@0.29.32:", type=("build", "run"))
    depends_on("py-numpy", type=("build", "link", "run"))
    depends_on("py-scipy", type=("build", "link", "run"))
    depends_on("metis", type=("build", "link", "run"))
    depends_on("parmetis", type=("build", "link", "run"))
    depends_on("suite-sparse", type=("build", "run"))
    depends_on("py-h5py", type=("build", "run"))
    depends_on("py-tabulate", type=("build", "run"))
    depends_on("py-pyyaml", type=("build", "run"))
    depends_on("py-matplotlib", type=("build", "run"))
    depends_on("py-scikit-sparse", type=("build", "run"))
    depends_on("py-modepy", type=("build", "run"))
    depends_on("py-meshpy", type=("build", "run"))
    depends_on("py-pytools", type=("build", "run"))
    depends_on("py-psutil", type="run")
    depends_on("py-pytest", when="+tests", type="run")
    depends_on("py-pytest-html", when="+tests", type="run")

    import_modules = [
        "PyNucleus",
        "PyNucleus-packageTools",
        "PyNucleus-base",
        "PyNucleus-metisCy",
        "PyNucleus-fem",
        "PyNucleus-multilevelSolver",
        "PyNucleus-nl",
    ]

    def setup_build_environment(self, env):
        env.set("PYNUCLEUS_BUILD_PARALLELISM", make_jobs)

    @run_before("install")
    def install_python(self):
        prefix = self.prefix
        for subpackage in ["packageTools", "base", "metisCy", "fem", "multilevelSolver", "nl"]:
            with working_dir(subpackage):
                args = std_pip_args + ["--prefix=" + prefix, "."]
                pip(*args)

    @run_after("install")
    def install_additional_files(self):
        spec = self.spec
        prefix = self.prefix
        if "+examples" in spec or "+tests" in spec:
            install_tree("drivers", prefix.drivers)
        if "+examples" in spec:
            install_tree("examples", prefix.examples)
        if "+tests" in spec:
            install_tree("tests", prefix.tests)