diff options
author | alalazo <massimiliano.culpo@googlemail.com> | 2016-04-12 15:42:55 +0200 |
---|---|---|
committer | alalazo <massimiliano.culpo@googlemail.com> | 2016-04-18 13:21:41 +0200 |
commit | 00f44d558ab3b3ee4b9d04534a01ad7decbe0d7b (patch) | |
tree | ffbee47ecd4b63ca230603c644fa49e25ee039ae /lib | |
parent | 1b4c4be151650f28e0e7d796cbfe85d05ea91f49 (diff) | |
download | spack-00f44d558ab3b3ee4b9d04534a01ad7decbe0d7b.tar.gz spack-00f44d558ab3b3ee4b9d04534a01ad7decbe0d7b.tar.bz2 spack-00f44d558ab3b3ee4b9d04534a01ad7decbe0d7b.tar.xz spack-00f44d558ab3b3ee4b9d04534a01ad7decbe0d7b.zip |
modules : started working on naming schemes and conflict
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/config.py | 9 | ||||
-rw-r--r-- | lib/spack/spack/modules.py | 56 |
2 files changed, 42 insertions, 23 deletions
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index cf3b885ae6..f9a680d109 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -297,6 +297,9 @@ section_schemas = { 'properties': { 'whitelist': {'$ref': '#/definitions/array_of_strings'}, 'blacklist': {'$ref': '#/definitions/array_of_strings'}, + 'naming_scheme': { + 'type': 'string' # Can we be more specific here? + } } }, { @@ -322,7 +325,11 @@ section_schemas = { 'tcl': { 'allOf': [ {'$ref': '#/definitions/module_type_configuration'}, # Base configuration - {} # Specific tcl extensions + { + 'properties': { + 'conflict': {'type': 'string'} + } + } # Specific tcl extensions ] }, 'dotkit': { diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py index 2c68c0c170..e6e9be1eff 100644 --- a/lib/spack/spack/modules.py +++ b/lib/spack/spack/modules.py @@ -41,11 +41,11 @@ various shell-support files in $SPACK/share/spack/setup-env.*. Each hook in hooks/ implements the logic for writing its specific type of module file. """ import copy +import datetime import os import os.path import re import textwrap -import datetime import llnl.util.tty as tty import spack @@ -75,7 +75,7 @@ def print_help(): " . %s/setup-env.sh" % spack.share_path, "", "For csh and tcsh:", - " setenv SPACK_ROOT %s" % spack.prefix, + " setenv SPACK_ROOT %s" % spack.prefix, " source %s/setup-env.csh" % spack.share_path, "") @@ -264,6 +264,34 @@ class EnvModule(object): self.long_description = re.sub(r'\s+', ' ', self.spec.package.__doc__) @property + def naming_scheme(self): + try: + naming_scheme = CONFIGURATION[self.name]['naming_scheme'] + except KeyError: + naming_scheme = self.default_naming_format + return naming_scheme + + @property + def tokens(self): + tokens = { + 'name': self.spec.name, + 'version': self.spec.version, + 'compiler': self.spec.compiler, + 'hash': self.spec.dag_hash() + } + return tokens + + @property + def use_name(self): + """ + Subclasses should implement this to return the name the module command uses to refer to the package. + """ + naming_tokens = self.tokens + naming_scheme = self.naming_scheme + name = naming_scheme.format(**naming_tokens) + return name + + @property def category(self): # Anything defined at the package level takes precedence if hasattr(self.pkg, 'category'): @@ -379,12 +407,6 @@ class EnvModule(object): where this module lives.""" raise NotImplementedError() - @property - def use_name(self): - """Subclasses should implement this to return the name the - module command uses to refer to the package.""" - raise NotImplementedError() - def remove(self): mod_file = self.file_name if os.path.exists(mod_file): @@ -408,18 +430,13 @@ class Dotkit(EnvModule): prerequisite_format = None # TODO : does something like prerequisite exist for dotkit? + default_naming_format = '{name}-{version}-{compiler.name}-{compiler.version}-{hash}' + @property def file_name(self): return join_path(Dotkit.path, self.spec.architecture, '%s.dk' % self.use_name) @property - def use_name(self): - return "%s-%s-%s-%s-%s" % (self.spec.name, self.spec.version, - self.spec.compiler.name, - self.spec.compiler.version, - self.spec.dag_hash()) - - @property def header(self): # Category header = '' @@ -456,18 +473,13 @@ class TclModule(EnvModule): prerequisite_format = 'prereq {module_file}\n' + default_naming_format = '{name}-{version}-{compiler.name}-{compiler.version}-{hash}' + @property def file_name(self): return join_path(TclModule.path, self.spec.architecture, self.use_name) @property - def use_name(self): - return "%s-%s-%s-%s-%s" % (self.spec.name, self.spec.version, - self.spec.compiler.name, - self.spec.compiler.version, - self.spec.dag_hash()) - - @property def header(self): # TCL Modulefile header header = '#%Module1.0\n' |