spack/var/spack/repos/builtin/packages/neuron/package.py
Harmen Stoppels eef9939c21
Automated git version fixes (#39637)
Use full length commit sha instead of short prefixes, to improve
reproducibility (future clashes) and guard against compromised repos and
man in the middle attacks.

Abbreviated commit shas are expanded to full length, to guard against future
clashes on short hash. It also guards against compromised repos and
man in the middle attacks, where attackers can easily fabricate a malicious
commit with a shasum prefix collision.

Versions with just tags now also get a commit sha, which can later be used to
check for retagged commits.
2023-08-29 16:33:03 +02:00

151 lines
5.5 KiB
Python

# Copyright 2013-2023 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 Neuron(CMakePackage):
"""NEURON is a simulation environment for single and networks of neurons.
NEURON is a simulation environment for modeling individual and networks of
neurons. NEURON models individual neurons via the use of sections that are
automatically subdivided into individual compartments, instead of
requiring the user to manually create compartments.
"""
homepage = "https://www.neuron.yale.edu/"
url = "https://neuron.yale.edu/ftp/neuron/versions/v7.7/nrn-7.7.tar.gz"
git = "https://github.com/neuronsimulator/nrn"
maintainers("pramodk", "nrnhines", "iomaganaris", "alexsavulescu")
version("develop", branch="master", submodules="True")
version(
"8.0.0", tag="8.0.0", commit="429d11ef34b1d860b3ddbfffc9f7960acb399b0c", submodules="True"
)
version(
"7.8.2", tag="7.8.2", commit="09b151ecb2b3984335c265932dc6ba3e4fcb318e", submodules="True"
)
version(
"7.8.1", tag="7.8.1", commit="47cd8c85aa3fde5dbb7319facd6f475438235d7d", submodules="True"
)
variant("coreneuron", default=False, description="Enable CoreNEURON as submodule")
variant("cross-compile", default=False, description="Build for cross-compile environment")
variant("interviews", default=False, description="Enable GUI with INTERVIEWS")
variant("legacy-unit", default=False, description="Enable legacy units")
variant("mpi", default=True, description="Enable MPI parallelism")
variant("python", default=True, description="Enable python")
variant("rx3d", default=False, description="Enable cython translated 3-d rxd")
variant("tests", default=False, description="Enable unit tests")
variant("caliper", default=False, description="Add LLNL/Caliper support")
depends_on("bison", type="build")
depends_on("flex", type="build")
depends_on("py-cython", when="+rx3d", type="build")
depends_on("gettext")
depends_on("mpi", when="+mpi")
depends_on("ncurses")
depends_on("python@2.7:", when="+python")
depends_on("py-pytest", when="+python+tests")
depends_on("py-mpi4py", when="+mpi+python+tests")
depends_on("readline")
depends_on("caliper", when="+caliper")
depends_on("py-numpy", type="run")
conflicts("+rx3d", when="~python")
patch("patch-v782-git-cmake-avx512.patch", when="@7.8.2")
def cmake_args(self):
spec = self.spec
def cmake_options(spec_options):
value = "TRUE" if spec_options in spec else "FALSE"
cmake_name = spec_options[1:].upper().replace("-", "_")
return "-DNRN_ENABLE_" + cmake_name + ":BOOL=" + value
args = [
cmake_options(variant)
for variant in [
"+coreneuron",
"+interviews",
"+mpi",
"+python",
"+rx3d",
"+coreneuron",
"+tests",
]
]
args.append("-DNRN_ENABLE_BINARY_SPECIAL=ON")
if "~mpi" in spec and "+coreneuron" in spec:
args.append("-DCORENRN_ENABLE_MPI=OFF")
if "+python" in spec:
args.append("-DPYTHON_EXECUTABLE:FILEPATH=" + spec["python"].command.path)
if spec.variants["build_type"].value == "Debug":
args.append("-DCMAKE_C_FLAGS=-g -O0")
args.append("-DCMAKE_CXX_FLAGS=-g -O0")
args.append("-DCMAKE_BUILD_TYPE=Custom")
if "+legacy-unit" in spec:
args.append("-DNRN_DYNAMIC_UNITS_USE_LEGACY=ON")
if "+caliper" in spec:
args.append("-DCORENRN_CALIPER_PROFILING=ON")
return args
@run_after("install")
def filter_compilers(self):
"""run after install to avoid spack compiler wrappers
getting embded into nrnivmodl script"""
spec = self.spec
if "cray" in spec.architecture:
cc_compiler = "cc"
cxx_compiler = "CC"
elif spec.satisfies("+mpi"):
cc_compiler = spec["mpi"].mpicc
cxx_compiler = spec["mpi"].mpicxx
else:
cc_compiler = self.compiler.cc
cxx_compiler = self.compiler.cxx
kwargs = {"backup": False, "string": True}
nrnmech_makefile = join_path(self.prefix, "./bin/nrnmech_makefile")
# assign_operator is changed to fix wheel support
if self.spec.satisfies("@:7"):
assign_operator = "?="
else:
assign_operator = "="
filter_file(
"CC {0} {1}".format(assign_operator, env["CC"]),
"CC = {0}".format(cc_compiler),
nrnmech_makefile,
**kwargs,
)
filter_file(
"CXX {0} {1}".format(assign_operator, env["CXX"]),
"CXX = {0}".format(cxx_compiler),
nrnmech_makefile,
**kwargs,
)
if spec.satisfies("+coreneuron"):
corenrn_makefile = join_path(self.prefix, "share/coreneuron/nrnivmodl_core_makefile")
filter_file(env["CXX"], cxx_compiler, corenrn_makefile, **kwargs)
def setup_run_environment(self, env):
env.prepend_path("PATH", join_path(self.prefix, "bin"))
env.prepend_path("LD_LIBRARY_PATH", join_path(self.prefix, "lib"))
if self.spec.satisfies("+python"):
env.prepend_path("PYTHONPATH", self.spec.prefix.lib.python)