From b5979b13e3f9bcf3e151b494bb2a557aaabedeff Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Sat, 14 May 2016 16:03:42 -0700 Subject: 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. --- .../repos/builtin/packages/lua-luaposix/package.py | 16 +++++ var/spack/repos/builtin/packages/lua/package.py | 76 ++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 var/spack/repos/builtin/packages/lua-luaposix/package.py (limited to 'var') 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')) + -- cgit v1.2.3-60-g2f50 From 21161a60ffdacd96918912953444fab0376faf24 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Sat, 14 May 2016 17:38:13 -0700 Subject: changes to appease flake8 (mostly) for lua package --- var/spack/repos/builtin/packages/lua/package.py | 63 ++++++++++++++----------- 1 file changed, 36 insertions(+), 27 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/lua/package.py b/var/spack/repos/builtin/packages/lua/package.py index b6ba2d600e..11d66bc8f9 100644 --- a/var/spack/repos/builtin/packages/lua/package.py +++ b/var/spack/repos/builtin/packages/lua/package.py @@ -25,10 +25,11 @@ from spack import * import os + class Lua(Package): """ The Lua programming language interpreter and library """ homepage = "http://www.lua.org" - url = "http://www.lua.org/ftp/lua-5.1.5.tar.gz" + url = "http://www.lua.org/ftp/lua-5.1.5.tar.gz" version('5.3.2', '33278c2ab5ee3c1a875be8d55c1ca2a1') version('5.3.1', '797adacada8d85761c079390ff1d9961') @@ -47,11 +48,12 @@ class Lua(Package): 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') + 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"): @@ -59,15 +61,13 @@ class Lua(Package): else: target = 'linux' make('INSTALL_TOP=%s' % prefix, - 'MYLDFLAGS=-L%s -lncurses' % spec['ncurses'].prefix.lib, - target) + 'MYLDFLAGS=-L%s -lncurses' % spec['ncurses'].prefix.lib, target) 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) + with working_dir(os.path.join('luarocks', 'luarocks')): + configure('--prefix=' + prefix, '--with-lua=' + prefix) make('build') make('install') @@ -77,8 +77,7 @@ class Lua(Package): cpaths.append(os.path.join(path, '?.so')) def setup_dependent_environment(self, spack_env, run_env, extension_spec): - lua_paths = [ - ] + 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)) @@ -91,31 +90,41 @@ class Lua(Package): 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)): + 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=';') + run_env.prepend_path('LUA_PATH', ';'.join(lua_patterns), + separator=';') + run_env.prepend_path('LUA_CPATH', ';'.join(lua_cpatterns), + 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=';') + 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]) @@ -130,5 +139,5 @@ class Lua(Package): """ # 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')) - + module.luarocks = Executable(join_path(self.spec.prefix.bin, + 'luarocks')) -- cgit v1.2.3-60-g2f50 From 0668b6d7bab8e96834251d39d2bcda5ba016e34d Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Sat, 14 May 2016 17:38:32 -0700 Subject: changes to appease flake8 for lua-luaposix package --- var/spack/repos/builtin/packages/lua-luaposix/package.py | 1 + 1 file changed, 1 insertion(+) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/lua-luaposix/package.py b/var/spack/repos/builtin/packages/lua-luaposix/package.py index d0606b71f7..1e8a925c43 100644 --- a/var/spack/repos/builtin/packages/lua-luaposix/package.py +++ b/var/spack/repos/builtin/packages/lua-luaposix/package.py @@ -1,6 +1,7 @@ from spack import * import glob + class LuaLuaposix(Package): """Lua posix bindings, including ncurses""" homepage = "https://github.com/luaposix/luaposix/" -- cgit v1.2.3-60-g2f50 From f50439b990a46cdb06e133f2f11d59271f878c7c Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Sat, 14 May 2016 17:49:06 -0700 Subject: appeasing the great vengeful flake8 gods --- var/spack/repos/builtin/packages/lua/package.py | 41 +++++++++++++++---------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/lua/package.py b/var/spack/repos/builtin/packages/lua/package.py index 11d66bc8f9..639b4dd15a 100644 --- a/var/spack/repos/builtin/packages/lua/package.py +++ b/var/spack/repos/builtin/packages/lua/package.py @@ -50,7 +50,8 @@ class Lua(Package): resource( name="luarocks", - url="https://keplerproject.github.io/luarocks/releases/luarocks-2.3.0.tar.gz", + url="https://keplerproject.github.io/luarocks/releases/" + "luarocks-2.3.0.tar.gz", md5="a38126684cf42b7d0e7a3c7cf485defb", destination="luarocks", placement='luarocks') @@ -97,7 +98,8 @@ class Lua(Package): 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 + # 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=';') @@ -105,21 +107,26 @@ class Lua(Package): 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=';') + 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): -- cgit v1.2.3-60-g2f50 From b7aa47a17822f49cdff50cda165367957ee20a73 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Sun, 15 May 2016 09:52:09 -0700 Subject: remove debug print --- var/spack/repos/builtin/packages/lua-luaposix/package.py | 1 - 1 file changed, 1 deletion(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/lua-luaposix/package.py b/var/spack/repos/builtin/packages/lua-luaposix/package.py index 1e8a925c43..9e96548f08 100644 --- a/var/spack/repos/builtin/packages/lua-luaposix/package.py +++ b/var/spack/repos/builtin/packages/lua-luaposix/package.py @@ -13,5 +13,4 @@ class LuaLuaposix(Package): def install(self, spec, prefix): rockspec = glob.glob('luaposix-*.rockspec') - print rockspec luarocks('--tree=' + prefix, 'install', rockspec[0]) -- cgit v1.2.3-60-g2f50 From 52c359bc77d1f790157ab9f74c31edae262d106c Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Mon, 16 May 2016 03:36:31 -0700 Subject: fix linking issue on ubuntu Evidently some readline variants are built with only a dynamic dependency on ncurses, this addresses that problem for such systems. --- var/spack/repos/builtin/packages/lua/package.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/lua/package.py b/var/spack/repos/builtin/packages/lua/package.py index 639b4dd15a..5e9c8e36ee 100644 --- a/var/spack/repos/builtin/packages/lua/package.py +++ b/var/spack/repos/builtin/packages/lua/package.py @@ -62,9 +62,18 @@ class Lua(Package): else: target = 'linux' make('INSTALL_TOP=%s' % prefix, - 'MYLDFLAGS=-L%s -lncurses' % spec['ncurses'].prefix.lib, target) + 'MYLDFLAGS=-L%s -L%s ' % ( + spec['readline'].prefix.lib, + spec['ncurses'].prefix.lib + ), + 'MYLIBS=-lncurses', + target) make('INSTALL_TOP=%s' % prefix, - 'MYLDFLAGS=-L%s -lncurses' % spec['ncurses'].prefix.lib, + 'MYLDFLAGS=-L%s -L%s ' % ( + spec['readline'].prefix.lib, + spec['ncurses'].prefix.lib + ), + 'MYLIBS=-lncurses', 'install') with working_dir(os.path.join('luarocks', 'luarocks')): -- cgit v1.2.3-60-g2f50 From 97804279406376273726b231faac4c6342a172fe Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Mon, 16 May 2016 05:37:04 -0700 Subject: fixing more flake8 errors that only appear on travis... --- var/spack/repos/builtin/packages/lua/package.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/lua/package.py b/var/spack/repos/builtin/packages/lua/package.py index 5e9c8e36ee..e621967586 100644 --- a/var/spack/repos/builtin/packages/lua/package.py +++ b/var/spack/repos/builtin/packages/lua/package.py @@ -64,15 +64,13 @@ class Lua(Package): make('INSTALL_TOP=%s' % prefix, 'MYLDFLAGS=-L%s -L%s ' % ( spec['readline'].prefix.lib, - spec['ncurses'].prefix.lib - ), + spec['ncurses'].prefix.lib), 'MYLIBS=-lncurses', target) make('INSTALL_TOP=%s' % prefix, 'MYLDFLAGS=-L%s -L%s ' % ( spec['readline'].prefix.lib, - spec['ncurses'].prefix.lib - ), + spec['ncurses'].prefix.lib), 'MYLIBS=-lncurses', 'install') -- cgit v1.2.3-60-g2f50