Skip to content
Snippets Groups Projects
Commit 57ddbd28 authored by David Beckingsale's avatar David Beckingsale Committed by Todd Gamblin
Browse files

Fixed up module support

parent 94c5c966
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
install_path = join_path(prefix, "opt") install_path = join_path(prefix, "opt")
share_path = join_path(prefix, "share", "spack") share_path = join_path(prefix, "share", "spack")
dotkit_path = join_path(share_path, "dotkit") dotkit_path = join_path(share_path, "dotkit")
tclmodule_path = join_path(share_path, "tclmodule") tclmodule_path = join_path(share_path, "modules")
# #
# Set up the packages database. # Set up the packages database.
......
...@@ -70,7 +70,7 @@ def module_find(parser, args): ...@@ -70,7 +70,7 @@ def module_find(parser, args):
sys.exit(1) sys.exit(1)
match = specs[0] match = specs[0]
if not os.path.isfile(spack.hooks.tclmodules.tclmodules_file(match.package)): if not os.path.isfile(spack.hooks.tclmodule.module_file(match.package)):
tty.die("No module is installed for package %s." % spec) tty.die("No module is installed for package %s." % spec)
print match.format('$_$@$+$%@$=$#') print match.format('$_$@$+$%@$=$#')
...@@ -84,8 +84,8 @@ def module_refresh(parser, args): ...@@ -84,8 +84,8 @@ def module_refresh(parser, args):
specs = [s for s in specs specs = [s for s in specs
if any(s.satisfies(q) for q in query_specs)] if any(s.satisfies(q) for q in query_specs)]
else: else:
shutil.rmtree(spack.module_path, ignore_errors=False) shutil.rmtree(spack.tclmodule_path, ignore_errors=False)
mkdirp(spack.module_path) mkdirp(spack.tclmodule_path)
for spec in specs: for spec in specs:
spack.hooks.tclmodule.post_install(spec.package) spack.hooks.tclmodule.post_install(spec.package)
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
def module_file(pkg): def module_file(pkg):
m_file_name = pkg.spec.format('$_$@$%@$+$=$#') m_file_name = pkg.spec.format('$_$@$%@$+$=$#')
return join_path(spack.module_path, m_file_name) return join_path(spack.tclmodule_path, m_file_name)
def post_install(pkg): def post_install(pkg):
...@@ -51,26 +51,27 @@ def post_install(pkg): ...@@ -51,26 +51,27 @@ def post_install(pkg):
('LD_LIBRARY_PATH', pkg.prefix.lib64)]: ('LD_LIBRARY_PATH', pkg.prefix.lib64)]:
if os.path.isdir(path): if os.path.isdir(path):
alterations.append("prepend_path %s %s\n" % (var, path)) alterations.append("prepend-path %s \"%s\"\n" % (var, path))
if not alterations: if not alterations:
return return
alterations.append("prepend_path CMAKE_PREFIX_PATH %s\n" % pkg.prefix) alterations.append("prepend-path CMAKE_PREFIX_PATH \"%s\"\n" % pkg.prefix)
m_file = module_file(pkg) m_file = module_file(pkg)
with closing(open(m_file, 'w')) as m: with closing(open(m_file, 'w')) as m:
# Put everything in the spack category. # Put everything in the spack category.
m.write('#%Module1.0\n') m.write('#%Module1.0\n')
m.write('module-whatis \"%s\"\n' % pkg.spec.format("$_ $@")) m.write('module-whatis \"%s\"\n\n' % pkg.spec.format("$_ $@"))
# Recycle the description # Recycle the description
if pkg.__doc__: if pkg.__doc__:
m.write('proc ModulesHelp { } {\n') m.write('proc ModulesHelp { } {\n')
doc = re.sub(r'\s+', ' ', pkg.__doc__) doc = re.sub(r'\s+', ' ', pkg.__doc__)
m.write("puts str \"%s\"\n" % doc) doc = re.sub(r'"', '\"', pkg.__doc__)
m.write('}') m.write("puts stderr \"%s\"\n" % doc)
m.write('}\n\n')
# Write alterations # Write alterations
......
##############################################################################
# Copyright (c) 2013, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Written by David Beckingsale, david@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://scalability-llnl.github.io/spack
# Please also see the LICENSE file for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License (as published by
# the Free Software Foundation) version 2.1 dated February 1999.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
# conditions of the GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
#
#
# This file is part of Spack and sets up the spack environment for zsh shells.
# This includes dotkit and module support as well as putting spack
# in your path. Source it like this:
#
# source /path/to/spack/share/spack/setup-env.zsh
#
#
########################################################################
# This is a wrapper around the spack command that forwards calls to
# 'spack use' and 'spack unuse' to shell functions. This in turn
# allows them to be used to invoke dotkit functions.
#
# 'spack use' is smarter than just 'use' because it converts its
# arguments into a unique spack spec that is then passed to dotkit
# commands. This allows the user to use packages without knowing all
# their installation details.
#
# e.g., rather than requring a full spec for libelf, the user can type:
#
# spack use libelf
#
# This will first find the available libelf dotkits and use a
# matching one. If there are two versions of libelf, the user would
# need to be more specific, e.g.:
#
# spack use libelf@0.8.13
#
# This is very similar to how regular spack commands work and it
# avoids the need to come up with a user-friendly naming scheme for
# spack dotfiles.
########################################################################
function spack {
_spack_subcommand=${1}; shift
_spack_spec="$@"
# Filter out use and unuse. For any other commands, just run the
# command.
case ${_spack_subcommand} in
"use"|"unuse")
# Shift any other args for use off before parsing spec.
_spack_use_args=""
if [[ "$1" =~ ^- ]]; then
_spack_use_args="$1"; shift
_spack_spec="$@"
fi
# Here the user has run use or unuse with a spec. Find a matching
# spec with a dotkit using spack dotkit, then use or unuse the
# result. If spack dotkit comes back with an error, do nothing.
if _spack_full_spec=$(command spack dotkit $_spack_spec); then
$_spack_subcommand $_spack_use_args $_spack_full_spec
fi
return
;;
"load"|"unload")
# Shift any other args for module off before parsing spec.
_spack_module_args=""
if [[ "$1" =~ ^- ]]; then
_spack_module_args="$1"; shift
_spack_spec="$@"
fi
# Here the user has run use or unuse with a spec. Find a matching
# spec with a dotkit using spack dotkit, then use or unuse the
# result. If spack dotkit comes back with an error, do nothing.
if _spack_full_spec=$(command spack tclmodule ${_spack_spec}); then
module ${_spack_subcommand} ${_spack_module_args} ${_spack_full_spec}
fi
return
;;
*)
command spack $_spack_subcommand "$@"
return
;;
esac
# If no args or -h, just run that command as well.
if [ -z "$1" -o "$1" = "-h" ]; then
command spack $_spack_subcommand -h
return
fi
}
#
# Set up dotkit and path in the user environment
#
_spack_share_dir="$(dirname $0:A)"
_spack_prefix="$(dirname $(dirname ${_spack_share_dir}))"
export DK_NODE="$_spack_share_dir/dotkit:$DK_NODE"
export MODULEPATH="$_spack_share_dir/modules:$MODULEPATH"
export PATH="$_spack_prefix/bin:$PATH"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment