Make neuron package more generic (#7393)

Make neuron package more generic

* find the bin directory dynamically for use in run_env and spack_env
* replace filter_compilers after install with filter_compiler_wrappers
* update checksum for _current_ 7.5 version
* make +python conflict with ~shared
* prepend the architecture specific lib directory to the LD_LIBRARY_PATH

Signed-off-by: Ricardo Silva <ricardo.silva@epfl.ch>
This commit is contained in:
Ricardo Silva 2018-03-06 16:31:28 +01:00 committed by Massimiliano Culpo
parent 8f350d0002
commit 4a54178ff8

View file

@ -27,19 +27,20 @@
class Neuron(Package): class Neuron(Package):
"""NEURON is a simulation environment for single and networks of neurons.
"""NEURON is a simulation environment for modeling individual NEURON is a simulation environment for modeling individual and networks of
and networks of neurons. NEURON models individual neurons via neurons. NEURON models individual neurons via the use of sections that are
the use of sections that are automatically subdivided into individual automatically subdivided into individual compartments, instead of
compartments, instead of requiring the user to manually create requiring the user to manually create compartments. The primary scripting
compartments. The primary scripting language is hoc but a Python language is hoc but a Python interface is also available.
interface is also available.""" """
homepage = "https://www.neuron.yale.edu/" homepage = "https://www.neuron.yale.edu/"
url = "http://www.neuron.yale.edu/ftp/neuron/versions/v7.5/nrn-7.5.tar.gz" url = "http://www.neuron.yale.edu/ftp/neuron/versions/v7.5/nrn-7.5.tar.gz"
github = "https://github.com/nrnhines/nrn" github = "https://github.com/nrnhines/nrn"
version('7.5', '1641ae7a7cd02728e5ae4c8aa93b3749') version('7.5', 'fb72c841374dfacbb6c2168ff57bfae9')
version('7.4', '2c0bbee8a9e55d60fa26336f4ab7acbf') version('7.4', '2c0bbee8a9e55d60fa26336f4ab7acbf')
version('7.3', '993e539cb8bf102ca52e9fefd644ab61') version('7.3', '993e539cb8bf102ca52e9fefd644ab61')
version('7.2', '5486709b6366add932e3a6d141c4f7ad') version('7.2', '5486709b6366add932e3a6d141c4f7ad')
@ -64,6 +65,26 @@ class Neuron(Package):
depends_on('python@2.6:', when='+python') depends_on('python@2.6:', when='+python')
depends_on('ncurses', when='~cross-compile') depends_on('ncurses', when='~cross-compile')
conflicts('~shared', when='+python')
filter_compiler_wrappers('*/bin/nrniv_makefile')
def get_neuron_archdir(self):
"""Determine the architecture-specific neuron base directory.
Instead of recreating the logic of the neuron's configure
we dynamically find the architecture-specific directory by
looking for a specific binary.
"""
file_list = find(self.prefix, '*/bin/nrniv_makefile')
# check needed as when initially evaluated the prefix is empty
if file_list:
neuron_archdir = os.path.dirname(os.path.dirname(file_list[0]))
else:
neuron_archdir = self.prefix
return neuron_archdir
def patch(self): def patch(self):
# aclocal need complete include path (especially on os x) # aclocal need complete include path (especially on os x)
pkgconf_inc = '-I %s/share/aclocal/' % (self.spec['pkg-config'].prefix) pkgconf_inc = '-I %s/share/aclocal/' % (self.spec['pkg-config'].prefix)
@ -90,18 +111,6 @@ def get_arch_options(self, spec):
return options return options
def get_arch_dir(self):
if 'bgq' in self.spec.architecture:
arch = 'powerpc64'
elif 'cray' in self.spec.architecture:
arch = 'x86_64'
elif 'ppc64le' in self.spec.architecture:
arch = 'powerpc64le'
else:
arch = self.spec.architecture.target
return arch
def get_python_options(self, spec): def get_python_options(self, spec):
options = [] options = []
@ -199,26 +208,14 @@ def install(self, spec, prefix):
make('VERBOSE=1') make('VERBOSE=1')
make('install') make('install')
@run_after('install')
def filter_compilers(self):
"""run after install to avoid spack compiler wrappers
getting embded into nrnivmodl script"""
arch = self.get_arch_dir()
nrnmakefile = join_path(self.prefix, arch, 'bin/nrniv_makefile')
kwargs = {
'backup': False,
'string': True
}
filter_file(env['CC'], self.compiler.cc, nrnmakefile, **kwargs)
filter_file(env['CXX'], self.compiler.cxx, nrnmakefile, **kwargs)
def setup_environment(self, spack_env, run_env): def setup_environment(self, spack_env, run_env):
arch = self.get_arch_dir() neuron_archdir = self.get_neuron_archdir()
run_env.prepend_path('PATH', join_path(self.prefix, arch, 'bin')) run_env.prepend_path('PATH', join_path(neuron_archdir, 'bin'))
run_env.prepend_path(
'LD_LIBRARY_PATH', join_path(neuron_archdir, 'lib'))
def setup_dependent_environment(self, spack_env, run_env, dependent_spec): def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
arch = self.get_arch_dir() neuron_archdir = self.get_neuron_archdir()
spack_env.prepend_path('PATH', join_path(self.prefix, arch, 'bin')) spack_env.prepend_path('PATH', join_path(neuron_archdir, 'bin'))
spack_env.prepend_path(
'LD_LIBRARY_PATH', join_path(neuron_archdir, 'lib'))