summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/fenics/package.py
blob: 711d6e3333c4caca6ae3226a61fa55592b74d7e2 (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# 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 *
from spack.pkg.builtin.boost import Boost


class Fenics(CMakePackage):
    """FEniCS is organized as a collection of interoperable components
    that together form the FEniCS Project. These components include
    the problem-solving environment DOLFIN, the form compiler FFC, the
    finite element tabulator FIAT, the just-in-time compiler Instant / Dijitso,
    the code generation interface UFC, the form language UFL and a range of
    additional components."""

    homepage = "https://fenicsproject.org/"
    git = "https://bitbucket.org/fenics-project/dolfin.git"
    url = "https://bitbucket.org/fenics-project/dolfin/downloads/dolfin-2019.1.0.post0.tar.gz"

    license("LGPL-3.0-only")

    version(
        "2019.1.0.post0", sha256="61abdcdb13684ba2a3ba4afb7ea6c7907aa0896a46439d3af7e8848483d4392f"
    )
    version(
        "2018.1.0.post1", sha256="425cc49b90e0f5c2ebdd765ba9934b1ada97e2ac2710d982d6d267a5e2c5982d"
    )
    # Pre 2018.1.0 versions are deprecated due to expected compatibility issues
    version(
        "2017.2.0.post0",
        sha256="d3c40cd8c1c882f517999c25ea4220adcd01dbb1d829406fce99b1fc40184c82",
        deprecated=True,
    )
    version(
        "2016.2.0",
        sha256="c6760996660a476f77889e11e4a0bc117cc774be0eec777b02a7f01d9ce7f43d",
        deprecated=True,
    )

    dolfin_versions = ["2019.1.0", "2018.1.0", "2017.2.0", "2016.2.0"]

    variant("python", default=True, description="Compile with Python interface")
    variant("hdf5", default=True, description="Compile with HDF5")
    variant("parmetis", default=True, description="Compile with ParMETIS")
    variant("scotch", default=True, description="Compile with Scotch")
    variant("petsc", default=True, description="Compile with PETSc")
    variant("slepc", default=True, description="Compile with SLEPc")
    variant("petsc4py", default=True, description="Use PETSC4py")
    variant("slepc4py", default=True, description="Use SLEPc4py")
    variant("trilinos", default=False, description="Compile with Trilinos")
    variant("suite-sparse", default=True, description="Compile with SuiteSparse solvers")
    variant("vtk", default=False, description="Compile with VTK")
    variant("qt", default=False, description="Compile with QT")
    variant("zlib", default=False, description="Compile with ZLIB")
    variant("mpi", default=True, description="Enables the distributed memory support")
    variant("openmp", default=True, description="Enables the shared memory support")
    variant("shared", default=True, description="Enables the build of shared libraries")
    variant("doc", default=False, description="Builds the documentation")
    variant(
        "build_type",
        default="RelWithDebInfo",
        description="The build type to build",
        values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel", "Developer"),
    )

    # Conflics for PETSC4PY / SLEPC4PY
    conflicts("+petsc4py", when="~python")
    conflicts("+petsc4py", when="~petsc")
    conflicts("+slepc4py", when="~python")
    conflicts("+slepc4py", when="~slepc")

    # Patches
    # patch('petsc-3.7.patch', when='petsc@3.7:')

    patch("header_fix.patch", when="@2019.1.0.post0")
    # endian.hpp for byte order detection was removed with Boost 1.73,
    # use __BYTE_ORDER__ instead
    patch(
        "https://bitbucket.org/fenics-project/dolfin/issues/attachments/1116/fenics-project/dolfin/1602778118.04/1116/0001-Use-__BYTE_ORDER__-instead-of-removed-Boost-endian.h.patch",
        sha256="1cc69e612df18feb5ebdc78cd902cfefda5ffc077735f0b67a1dcb1bf82e63c9",
        when="@2019.1.0.post0",
    )
    patch("petsc_3_11.patch", when="@2018.1.0.post1")

    # enable extension support for fenics package
    extends("python", when="+python")

    # fenics python package dependencies
    for ver in dolfin_versions:
        wver = "@" + ver
        depends_on("py-fenics-fiat{0}".format(wver), type=("build", "run"), when=wver + "+python")
        if Version(ver) < Version("2018.1.0"):
            depends_on(
                "py-fenics-instant{0}".format(wver), type=("build", "run"), when=wver + "+python"
            )
        else:
            depends_on(
                "py-fenics-dijitso{0}".format(wver), type=("build", "run"), when=wver + "+python"
            )
        depends_on("py-fenics-ufl{0}".format(wver), type=("build", "run"), when=wver + "+python")
        if ver in ["2019.1.0", "2017.2.0"]:
            wver = "@" + ver + ".post0"
        depends_on("py-fenics-ffc{0}".format(wver), type=("build", "run"), when=wver + "+python")

    # package dependencies
    depends_on("python@3.5:", type=("build", "run"), when="+python")
    depends_on("eigen@3.2.0:")
    depends_on("pkgconfig", type="build")
    depends_on("zlib-api", when="+zlib")

    depends_on("boost+filesystem+program_options+system+iostreams+timer+regex+chrono")
    depends_on(
        "boost+filesystem+program_options+system+iostreams+timer+regex+chrono@1.68.0",
        when="@:2018",
    )

    # TODO: replace this with an explicit list of components of Boost,
    # for instance depends_on('boost +filesystem')
    # See https://github.com/spack/spack/pull/22303 for reference
    depends_on(Boost.with_default_variants)

    depends_on("mpi", when="+mpi")
    depends_on("hdf5@:1.10+hl+fortran", when="+hdf5+petsc")
    depends_on("hdf5@:1.10+hl", when="+hdf5~petsc")
    depends_on("metis+real64", when="+parmetis")
    depends_on("parmetis", when="+parmetis")
    depends_on("scotch~metis", when="+scotch~mpi")
    depends_on("scotch+mpi~metis", when="+scotch+mpi")
    depends_on("petsc", when="+petsc")
    depends_on("slepc", when="+slepc")
    depends_on("py-petsc4py@3.6:", when="+petsc+python")
    depends_on("trilinos", when="+trilinos")
    depends_on("vtk", when="+vtk")
    depends_on("suite-sparse", when="+suite-sparse")
    depends_on("qt", when="+qt")

    depends_on("py-pybind11@2.2.4", type=("build", "run"))
    depends_on("cmake@3.17.3:", type="build")

    depends_on("py-pip", when="+python", type="build")
    depends_on("py-wheel", when="+python", type="build")
    depends_on("py-setuptools", type="build", when="+python")
    depends_on("py-pkgconfig", type=("build", "run"), when="+python")
    depends_on("py-sphinx@1.0.1:", when="+doc", type="build")

    def cmake_args(self):
        args = [
            self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
            self.define("DOLFIN_SKIP_BUILD_TESTS", True),
            self.define_from_variant("DOLFIN_ENABLE_OPENMP", "openmp"),
            self.define_from_variant("DOLFIN_ENABLE_CHOLMOD", "suite-sparse"),
            self.define_from_variant("DOLFIN_ENABLE_HDF5", "hdf5"),
            self.define_from_variant("HDF5_NO_FIND_PACKAGE_CONFIG_FILE", "hdf5"),
            self.define_from_variant("DOLFIN_ENABLE_MPI", "mpi"),
            self.define_from_variant("DOLFIN_ENABLE_PARMETIS", "parmetis"),
            self.define_from_variant("DOLFIN_ENABLE_PETSC", "petsc"),
            self.define_from_variant("DOLFIN_ENABLE_PETSC4PY", "petsc4py"),
            self.define_from_variant("DOLFIN_ENABLE_PYTHON", "python"),
            self.define_from_variant("DOLFIN_ENABLE_QT", "qt"),
            self.define_from_variant("DOLFIN_ENABLE_SCOTCH", "scotch"),
            self.define_from_variant("DOLFIN_ENABLE_SLEPC", "slepc"),
            self.define_from_variant("DOLFIN_ENABLE_SLEPC4PY", "slepc4py"),
            self.define_from_variant("DOLFIN_ENABLE_DOCS", "doc"),
            self.define_from_variant("DOLFIN_ENABLE_SPHINX", "doc"),
            self.define_from_variant("DOLFIN_ENABLE_TRILINOS", "trilinos"),
            self.define_from_variant("DOLFIN_ENABLE_UMFPACK", "suite-sparse"),
            self.define_from_variant("DOLFIN_ENABLE_VTK", "vtk"),
            self.define_from_variant("DOLFIN_ENABLE_ZLIB", "zlib"),
        ]

        if "+python" in self.spec:
            args.append(self.define("PYTHON_EXECUTABLE", self.spec["python"].command.path))

        return args

    # set environment for bulding python interface
    def setup_build_environment(self, env):
        env.set("DOLFIN_DIR", self.prefix)

    def setup_run_environment(self, env):
        env.set("DOLFIN_DIR", self.prefix)

    # build python interface of dolfin
    @run_after("install")
    def install_python_interface(self):
        if "+python" in self.spec:
            with working_dir("python"):
                args = std_pip_args + ["--prefix=" + self.prefix, "."]
                pip(*args)