complete lua rework, also module path fix
This is a complete rework of the lua package, it also allows the environment modification classes to handle paths that are not separated by colons, and uses the support for same in TCL modules as well. The biggest difference is the handling for lua extension packages, which now have their paths set correctly by the lua parent package, and have access to both lua and luarocks as installation tools. See the luaposix package for what should be required for most lua packages after this.
This commit is contained in:
@@ -292,7 +292,7 @@ def resource(pkg, **kwargs):
|
||||
message += "\tdestination : '{dest}\n'".format(dest=destination)
|
||||
raise RuntimeError(message)
|
||||
# Check if the path falls within the main package stage area
|
||||
test_path = 'stage_folder_root/'
|
||||
test_path = 'stage_folder_root'
|
||||
normalized_destination = os.path.normpath(join_path(test_path, destination)) # Normalized absolute path
|
||||
if test_path not in normalized_destination:
|
||||
message = "The destination folder of a resource must fall within the main package stage directory.\n"
|
||||
|
@@ -39,7 +39,8 @@ class NameValueModifier(object):
|
||||
def __init__(self, name, value, **kwargs):
|
||||
self.name = name
|
||||
self.value = value
|
||||
self.args = {'name': name, 'value': value}
|
||||
self.separator = kwargs.get('separator', ':')
|
||||
self.args = {'name': name, 'value': value, 'delim': self.separator}
|
||||
self.args.update(kwargs)
|
||||
|
||||
|
||||
@@ -56,34 +57,34 @@ def execute(self):
|
||||
|
||||
class SetPath(NameValueModifier):
|
||||
def execute(self):
|
||||
string_path = concatenate_paths(self.value)
|
||||
string_path = concatenate_paths(self.value, separator=self.separator)
|
||||
os.environ[self.name] = string_path
|
||||
|
||||
|
||||
class AppendPath(NameValueModifier):
|
||||
def execute(self):
|
||||
environment_value = os.environ.get(self.name, '')
|
||||
directories = environment_value.split(':') if environment_value else []
|
||||
directories = environment_value.split(self.separator) if environment_value else []
|
||||
directories.append(os.path.normpath(self.value))
|
||||
os.environ[self.name] = ':'.join(directories)
|
||||
os.environ[self.name] = self.separator.join(directories)
|
||||
|
||||
|
||||
class PrependPath(NameValueModifier):
|
||||
def execute(self):
|
||||
environment_value = os.environ.get(self.name, '')
|
||||
directories = environment_value.split(':') if environment_value else []
|
||||
directories = environment_value.split(self.separator) if environment_value else []
|
||||
directories = [os.path.normpath(self.value)] + directories
|
||||
os.environ[self.name] = ':'.join(directories)
|
||||
os.environ[self.name] = self.separator.join(directories)
|
||||
|
||||
|
||||
class RemovePath(NameValueModifier):
|
||||
def execute(self):
|
||||
environment_value = os.environ.get(self.name, '')
|
||||
directories = environment_value.split(':') if environment_value else []
|
||||
directories = environment_value.split(self.separator) if environment_value else []
|
||||
directories = [os.path.normpath(x)
|
||||
for x in directories
|
||||
if x != os.path.normpath(self.value)]
|
||||
os.environ[self.name] = ':'.join(directories)
|
||||
os.environ[self.name] = self.separator.join(directories)
|
||||
|
||||
|
||||
class EnvironmentModifications(object):
|
||||
@@ -238,7 +239,7 @@ def apply_modifications(self):
|
||||
x.execute()
|
||||
|
||||
|
||||
def concatenate_paths(paths):
|
||||
def concatenate_paths(paths, separator=';'):
|
||||
"""
|
||||
Concatenates an iterable of paths into a string of column separated paths
|
||||
|
||||
@@ -248,7 +249,7 @@ def concatenate_paths(paths):
|
||||
Returns:
|
||||
string
|
||||
"""
|
||||
return ':'.join(str(item) for item in paths)
|
||||
return separator.join(str(item) for item in paths)
|
||||
|
||||
|
||||
def set_or_unset_not_first(variable, changes, errstream):
|
||||
|
@@ -485,9 +485,10 @@ class TclModule(EnvModule):
|
||||
path = join_path(spack.share_path, "modules")
|
||||
|
||||
environment_modifications_formats = {
|
||||
PrependPath: 'prepend-path {name} \"{value}\"\n',
|
||||
AppendPath: 'append-path {name} \"{value}\"\n',
|
||||
RemovePath: 'remove-path {name} \"{value}\"\n',
|
||||
formats = {
|
||||
PrependPath: 'prepend-path --delim "{delim}" {name} \"{value}\"\n',
|
||||
AppendPath: 'append-path --delim "{delim}" {name} \"{value}\"\n',
|
||||
RemovePath: 'remove-path --delim "{delim}" {name} \"{value}\"\n',
|
||||
SetEnv: 'setenv {name} \"{value}\"\n',
|
||||
UnsetEnv: 'unsetenv {name}\n'
|
||||
}
|
||||
|
Reference in New Issue
Block a user