summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/cmd/module.py13
-rw-r--r--lib/spack/spack/hooks/dotkit.py4
-rw-r--r--lib/spack/spack/modules.py34
-rw-r--r--lib/spack/spack/util/string.py4
4 files changed, 28 insertions, 27 deletions
diff --git a/lib/spack/spack/cmd/module.py b/lib/spack/spack/cmd/module.py
index f23f3d2f9f..34f0855a50 100644
--- a/lib/spack/spack/cmd/module.py
+++ b/lib/spack/spack/cmd/module.py
@@ -57,14 +57,14 @@ def module_find(mtype, spec_array):
of type <mtype> there, and print out the name that the user
should type to use that package's module.
"""
+ if mtype not in module_types:
+ tty.die("Invalid module type: '%s'. Options are %s." % (mtype, comma_or(module_types)))
+
specs = spack.cmd.parse_specs(spec_array)
if len(specs) > 1:
tty.die("You can only pass one spec.")
spec = specs[0]
- if mtype not in module_types:
- tty.die("Invalid module type: '%s'. Options are " + comma_and(module_types))
-
specs = [s for s in spack.db.installed_package_specs() if s.satisfies(spec)]
if len(specs) == 0:
tty.die("No installed packages match spec %s" % spec)
@@ -76,10 +76,9 @@ def module_find(mtype, spec_array):
sys.exit(1)
mt = module_types[mtype]
- mod = mt(specs[0].package)
+ mod = mt(specs[0])
if not os.path.isfile(mod.file_name):
- tty.error( mod.file_name)
- tty.die("No %s module is installed for package %s." % (mtype, spec))
+ tty.die("No %s module is installed for %s." % (mtype, spec))
print mod.use_name
@@ -96,7 +95,7 @@ def module_refresh():
mkdirp(cls.path)
for spec in specs:
tty.debug(" Writing file for %s." % spec)
- cls(spec.package).write()
+ cls(spec).write()
diff --git a/lib/spack/spack/hooks/dotkit.py b/lib/spack/spack/hooks/dotkit.py
index 0f46f6a2fc..4e748ff80a 100644
--- a/lib/spack/spack/hooks/dotkit.py
+++ b/lib/spack/spack/hooks/dotkit.py
@@ -26,10 +26,10 @@ import spack.modules
def post_install(pkg):
- dk = spack.modules.Dotkit(pkg)
+ dk = spack.modules.Dotkit(pkg.spec)
dk.write()
def post_uninstall(pkg):
- dk = spack.modules.Dotkit(pkg)
+ dk = spack.modules.Dotkit(pkg.spec)
dk.remove()
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index 3f56208f5b..5d2105e37c 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -88,7 +88,7 @@ class EnvModule(object):
module_types[cls.name] = cls
- def __init__(self, pkg=None):
+ def __init__(self, spec=None):
# category in the modules system
# TODO: come up with smarter category names.
self.category = "spack"
@@ -100,7 +100,7 @@ class EnvModule(object):
# dict pathname -> list of directories to be prepended to in
# the module file.
self._paths = None
- self.pkg = pkg
+ self.spec = spec
@property
@@ -114,22 +114,22 @@ class EnvModule(object):
# Add paths if they exist.
for var, directory in [
- ('PATH', self.pkg.prefix.bin),
- ('MANPATH', self.pkg.prefix.man),
- ('MANPATH', self.pkg.prefix.share_man),
- ('LD_LIBRARY_PATH', self.pkg.prefix.lib),
- ('LD_LIBRARY_PATH', self.pkg.prefix.lib64)]:
+ ('PATH', self.spec.prefix.bin),
+ ('MANPATH', self.spec.prefix.man),
+ ('MANPATH', self.spec.prefix.share_man),
+ ('LD_LIBRARY_PATH', self.spec.prefix.lib),
+ ('LD_LIBRARY_PATH', self.spec.prefix.lib64)]:
if os.path.isdir(directory):
add_path(var, directory)
# short description is just the package + version
# TODO: maybe packages can optionally provide it.
- self.short_description = self.pkg.spec.format("$_ $@")
+ self.short_description = self.spec.format("$_ $@")
# long description is the docstring with reduced whitespace.
- if self.pkg.__doc__:
- self.long_description = re.sub(r'\s+', ' ', self.pkg.__doc__)
+ if self.spec.package.__doc__:
+ self.long_description = re.sub(r'\s+', ' ', self.spec.package.__doc__)
return self._paths
@@ -179,12 +179,12 @@ class Dotkit(EnvModule):
@property
def file_name(self):
- return join_path(Dotkit.path, self.pkg.spec.architecture,
- self.pkg.spec.format('$_$@$%@$+$#.dk'))
+ return join_path(Dotkit.path, self.spec.architecture,
+ self.spec.format('$_$@$%@$+$#.dk'))
@property
def use_name(self):
- return self.pkg.spec.format('$_$@$%@$+$#')
+ return self.spec.format('$_$@$%@$+$#')
def _write(self, dk_file):
@@ -207,7 +207,7 @@ class Dotkit(EnvModule):
dk_file.write("dk_alter %s %s\n" % (var, directory))
# Let CMake find this package.
- dk_file.write("dk_alter CMAKE_PREFIX_PATH %s\n" % self.pkg.prefix)
+ dk_file.write("dk_alter CMAKE_PREFIX_PATH %s\n" % self.spec.prefix)
class TclModule(EnvModule):
@@ -216,12 +216,12 @@ class TclModule(EnvModule):
@property
def file_name(self):
- return join_path(TclModule.path, self.pkg.spec.architecture, self.use_name)
+ return join_path(TclModule.path, self.spec.architecture, self.use_name)
@property
def use_name(self):
- return self.pkg.spec.format('$_$@$%@$+$#')
+ return self.spec.format('$_$@$%@$+$#')
def _write(self, m_file):
@@ -244,4 +244,4 @@ class TclModule(EnvModule):
for directory in dirs:
m_file.write("prepend-path %s \"%s\"\n" % (var, directory))
- m_file.write("prepend-path CMAKE_PREFIX_PATH \"%s\"\n" % self.pkg.prefix)
+ m_file.write("prepend-path CMAKE_PREFIX_PATH \"%s\"\n" % self.spec.prefix)
diff --git a/lib/spack/spack/util/string.py b/lib/spack/spack/util/string.py
index e7a9a6862e..234163bf52 100644
--- a/lib/spack/spack/util/string.py
+++ b/lib/spack/spack/util/string.py
@@ -33,7 +33,9 @@ def comma_list(sequence, article=''):
return sequence[0]
else:
out = ', '.join(str(s) for s in sequence[:-1])
- out += ', '
+ if len(sequence) != 2:
+ out += ',' # oxford comma
+ out += ' '
if article:
out += article + ' '
out += str(sequence[-1])