-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.py
131 lines (112 loc) · 4.91 KB
/
package.py
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
# CoMMA
#
# Copyright © 2024 ONERA
#
# Authors: Nicolas Lantos, Alberto Remigi, and Riccardo Milani
# Contributors: Karim Anemiche
#
# Any copyright is dedicated to the Public Domain.
# https://creativecommons.org/publicdomain/zero/1.0/
from spack.package import *
class Comma(CMakePackage):
"""CoMMA (COarse Mesh Multigrid Agglomerator)."""
homepage = "https://github.com/onera/CoMMA"
url = "https://github.com/onera/CoMMA"
git = "https://github.com/onera/CoMMA.git"
submodules = True
maintainers("RiMillo")
version("develop", branch="main")
version("1.3.2", tag="v1.3.2", preferred=True)
version("1.3.1", tag="v1.3.1")
# Named 1.3, but as we have a 1.3.1 that changes patches, let us do this differently
version("1.3.0", tag="v1.3")
version("1.2", tag="v1.2")
version("1.1", tag="v1.1")
version("1.0", tag="v1.0")
# Add install methods
patch("v1.3_install.patch", when="@1.2:1.3.0") # Works for version 1.2 and 1.3
patch("v1.1_install.patch", when="@1.1")
patch("v1.0_install.patch", when="@1.0")
# Fix problems with path
patch("fix_pkgconfig_v1.3.1.patch", when="@1.3.1")
variant("python", when="@1.2:", description="Install python bindings", default=True)
variant("codaflags", when="@1.1:", description="Compile with usual CODA flags", default=False)
variant("doc", when="@1.3.1:", description="Build Doxygen documentation", default=False)
variant(
"pkgconfig",
when="@1.3.1:1.3.2", # In recent versions is always on
description="Add pkg-config configuration file",
default=True,
)
variant(
"int64",
when="@1.3.2:",
default=False,
description="Set size of integer types to 64 b (true) or 32 b (false)",
)
variant(
"real64",
when="@1.3.2:",
default=True,
description="Set size of real types to 64 b (double, true) or 32 b (false)",
)
depends_on("[email protected]:", type=("build"))
depends_on("doxygen", type=("build",), when="+doc")
extends("python", when="+python")
depends_on("python", type=("build", "link", "run"), when="+python")
# older versions always had a Python dependency
extends("python", when="@1.0:1.1")
depends_on("python", type=("build", "link", "run"), when="@1.0:1.1")
depends_on("py-pybind11", type=("build", "link", "run"), when="@develop:+python")
# MAJOR SHAMEFUL HACK
# The version of pybind11 included in <=1.3.2 does not support python>=3.11. In order to make
# this work for any version of spack, if needed, we get the right version of pybind11 as
# resource and apply a patch to make cmake use this latter instead of the
# default one
PYTHONVER_TO_PYBINDVER = {"3.11": "2.10.0", "3.12": "2.12.0"}
for pythonver, pybindver in PYTHONVER_TO_PYBINDVER.items():
depends_on(
"py-pybind11@{}:".format(pybindver),
type=("build", "link", "run"),
when="@develop:+python^python@{}".format(pythonver),
)
for commaver, ptch in [
("1.0", "python312_v10.patch"),
("1.1", "python312_v11.patch"),
("1.2", "python312_v13.patch"), # Same as 1.3
("1.3.0", "python312_v13.patch"),
("1.3.1", "python312_v131.patch"),
("1.3.2", "python312_v132.patch"),
]:
with when("@{}^python@{}".format(commaver, pythonver)):
patch(ptch)
resource(
name="pybind11",
git="https://github.com/pybind/pybind11.git",
tag="v{}".format(pybindver),
destination="pybind11new", # That's what we put in the patch
)
# However, see this bug report https://github.com/spack/spack/issues/29447
depends_on("catch2", type=("test",), when="@develop:")
# Require C++17 compilers
conflicts("%gcc@:8.9.9", msg="Compiler supporting C++17 required")
conflicts("%clang@:5.9.9", msg="Compiler supporting C++17 required")
conflicts("%intel@:19.9.9", msg="Compiler supporting C++17 required")
def cmake_args(self):
args = super(Comma, self).cmake_args()
args += [
self.define_from_variant("CODAFLAGS", "codaflags"),
self.define_from_variant("BUILD_PYTHON_BINDINGS", "python"),
self.define_from_variant("BUILD_DOC", "doc"),
self.define_from_variant("PKGCONFIG_SUPPORT", "pkgconfig"),
# `make test` added in v1.3.1
self.define("BUILD_TESTS", self.run_tests and self.spec.satisfies("@1.3.1:")),
]
if self.spec.satisfies("@1.3.2:"):
bit_int = 64 if "+int64" in self.spec else 32
args += [
self.define("INDEX_T", "uint{}_t".format(bit_int)),
self.define("INT_T", "int{}_t".format(bit_int)),
self.define("REAL_T", "double" if "+real64" in self.spec else "float"),
]
return args