summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/directives.py2
-rw-r--r--lib/spack/spack/environment.py21
-rw-r--r--lib/spack/spack/modules.py7
-rw-r--r--var/spack/repos/builtin/packages/lua-luaposix/package.py16
-rw-r--r--var/spack/repos/builtin/packages/lua/package.py76
5 files changed, 108 insertions, 14 deletions
diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py
index 74ee7b0add..1819f4308c 100644
--- a/lib/spack/spack/directives.py
+++ b/lib/spack/spack/directives.py
@@ -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"
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py
index 11998ad8d2..ee5afb15dd 100644
--- a/lib/spack/spack/environment.py
+++ b/lib/spack/spack/environment.py
@@ -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 @@ class UnsetEnv(NameModifier):
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 @@ class EnvironmentModifications(object):
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):
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index a35e21c3db..9b6a019108 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -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'
}
diff --git a/var/spack/repos/builtin/packages/lua-luaposix/package.py b/var/spack/repos/builtin/packages/lua-luaposix/package.py
new file mode 100644
index 0000000000..d0606b71f7
--- /dev/null
+++ b/var/spack/repos/builtin/packages/lua-luaposix/package.py
@@ -0,0 +1,16 @@
+from spack import *
+import glob
+
+class LuaLuaposix(Package):
+ """Lua posix bindings, including ncurses"""
+ homepage = "https://github.com/luaposix/luaposix/"
+ url = "https://github.com/luaposix/luaposix/archive/release-v33.4.0.tar.gz"
+
+ version('33.4.0', 'b36ff049095f28752caeb0b46144516c')
+
+ extends("lua")
+
+ def install(self, spec, prefix):
+ rockspec = glob.glob('luaposix-*.rockspec')
+ print rockspec
+ luarocks('--tree=' + prefix, 'install', rockspec[0])
diff --git a/var/spack/repos/builtin/packages/lua/package.py b/var/spack/repos/builtin/packages/lua/package.py
index 9a73a22645..b6ba2d600e 100644
--- a/var/spack/repos/builtin/packages/lua/package.py
+++ b/var/spack/repos/builtin/packages/lua/package.py
@@ -42,9 +42,17 @@ class Lua(Package):
version('5.1.4', 'd0870f2de55d59c1c8419f36e8fac150')
version('5.1.3', 'a70a8dfaa150e047866dc01a46272599')
+ extendable = True
+
depends_on('ncurses')
depends_on('readline')
+ resource(name="luarocks",
+ url="https://keplerproject.github.io/luarocks/releases/luarocks-2.3.0.tar.gz",
+ md5="a38126684cf42b7d0e7a3c7cf485defb",
+ destination="luarocks",
+ placement='luarocks')
+
def install(self, spec, prefix):
if spec.satisfies("=darwin-i686") or spec.satisfies("=darwin-x86_64"):
target = 'macosx'
@@ -56,3 +64,71 @@ class Lua(Package):
make('INSTALL_TOP=%s' % prefix,
'MYLDFLAGS=-L%s -lncurses' % spec['ncurses'].prefix.lib,
'install')
+
+ with working_dir(os.path.join('luarocks','luarocks')):
+ configure('--prefix=' + prefix,
+ '--with-lua=' + prefix)
+ make('build')
+ make('install')
+
+ def append_paths(self, paths, cpaths, path):
+ paths.append(os.path.join(path, '?.lua'))
+ paths.append(os.path.join(path, '?', 'init.lua'))
+ cpaths.append(os.path.join(path, '?.so'))
+
+ def setup_dependent_environment(self, spack_env, run_env, extension_spec):
+ lua_paths = [
+ ]
+ for d in extension_spec.traverse():
+ if d.package.extends(self.spec):
+ lua_paths.append(os.path.join(d.prefix, self.lua_lib_dir))
+ lua_paths.append(os.path.join(d.prefix, self.lua_share_dir))
+
+ lua_patterns = []
+ lua_cpatterns = []
+ for p in lua_paths:
+ if os.path.isdir(p):
+ self.append_paths(lua_patterns, lua_cpatterns, p)
+
+ # Always add this package's paths
+ for p in ( os.path.join(self.spec.prefix, self.lua_lib_dir), os.path.join(self.spec.prefix, self.lua_share_dir)):
+ self.append_paths(lua_patterns, lua_cpatterns, p)
+
+
+ spack_env.set('LUA_PATH', ';'.join(lua_patterns), separator=';')
+ spack_env.set('LUA_CPATH', ';'.join(lua_cpatterns), separator=';')
+
+ # For run time environment set only the path for extension_spec and prepend it to LUAPATH
+ if extension_spec.package.extends(self.spec):
+ run_env.prepend_path('LUA_PATH', ';'.join(lua_patterns), separator=';')
+ run_env.prepend_path('LUA_CPATH', ';'.join(lua_cpatterns), separator=';')
+ # run_env.prepend_path('LUA_PATH', os.path.join(extension_spec.prefix, self.lua_lib_dir, '?.lua'), separator=';')
+ # run_env.prepend_path('LUA_PATH', os.path.join(extension_spec.prefix, self.lua_lib_dir, '?', 'init.lua'), separator=';')
+ # run_env.prepend_path('LUA_CPATH', os.path.join(extension_spec.prefix, self.lua_lib_dir, '?.so'), separator=';')
+
+ def setup_environment(self, spack_env, run_env):
+ run_env.prepend_path('LUA_PATH', os.path.join(self.spec.prefix, self.lua_share_dir, '?.lua'), separator=';')
+ run_env.prepend_path('LUA_PATH', os.path.join(self.spec.prefix, self.lua_share_dir, '?', 'init.lua'), separator=';')
+ run_env.prepend_path('LUA_PATH', os.path.join(self.spec.prefix, self.lua_lib_dir, '?.lua'), separator=';')
+ run_env.prepend_path('LUA_PATH', os.path.join(self.spec.prefix, self.lua_lib_dir, '?', 'init.lua'), separator=';')
+ run_env.prepend_path('LUA_CPATH', os.path.join(self.spec.prefix, self.lua_lib_dir, '?.so'), separator=';')
+
+ @property
+ def lua_lib_dir(self):
+ return os.path.join('lib', 'lua', '%d.%d' % self.version[:2])
+ @property
+ def lua_share_dir(self):
+ return os.path.join('share', 'lua', '%d.%d' % self.version[:2])
+
+ def setup_dependent_package(self, module, ext_spec):
+ """
+ Called before lua modules's install() methods.
+
+ In most cases, extensions will only need to have two lines::
+
+ luarocks('--tree=' + prefix, 'install', rock_spec_path)
+ """
+ # Lua extension builds can have lua and luarocks executable functions
+ module.lua = Executable(join_path(self.spec.prefix.bin, 'lua'))
+ module.luarocks = Executable(join_path(self.spec.prefix.bin, 'luarocks'))
+