def test_get_path_from_module_faked(monkeypatch): for line in test_module_lines: def fake_module(*args): return line monkeypatch.setattr(spack.util.module_cmd, 'module', fake_module) path = get_path_from_module('mod') assert path == '/path/to'
def test_get_path_from_module_faked(save_module_func): for line in test_module_lines: def fake_module(*args): return line spack.util.module_cmd.module = fake_module path = get_path_from_module('mod') assert path == '/path/to'
def test_get_path_from_module(save_env): lines = [ 'prepend-path LD_LIBRARY_PATH /path/to/lib', 'setenv MOD_DIR /path/to', 'setenv LDFLAGS -Wl,-rpath/path/to/lib', 'setenv LDFLAGS -L/path/to/lib', 'prepend-path PATH /path/to/bin' ] for line in lines: module_func = '() { eval `echo ' + line + ' bash filler`\n}' os.environ['BASH_FUNC_module()'] = module_func path = get_path_from_module('mod') assert path == '/path/to' os.environ['BASH_FUNC_module()'] = '() { eval $(echo fill bash $*)\n}' path = get_path_from_module('mod') assert path is None
def test_get_path_from_module(save_env): lines = ['prepend-path LD_LIBRARY_PATH /path/to/lib', 'prepend-path CRAY_LD_LIBRARY_PATH /path/to/lib', 'setenv MOD_DIR /path/to', 'setenv LDFLAGS -Wl,-rpath/path/to/lib', 'setenv LDFLAGS -L/path/to/lib', 'prepend-path PATH /path/to/bin'] for line in lines: module_func = '() { eval `echo ' + line + ' bash filler`\n}' os.environ['BASH_FUNC_module()'] = module_func path = get_path_from_module('mod') assert path == '/path/to' os.environ['BASH_FUNC_module()'] = '() { eval $(echo fill bash $*)\n}' path = get_path_from_module('mod') assert path is None
def get_rpaths(pkg): """Get a list of all the rpaths for a package.""" rpaths = [pkg.prefix.lib, pkg.prefix.lib64] deps = get_rpath_deps(pkg) rpaths.extend(d.prefix.lib for d in deps if os.path.isdir(d.prefix.lib)) rpaths.extend(d.prefix.lib64 for d in deps if os.path.isdir(d.prefix.lib64)) # Second module is our compiler mod name. We use that to get rpaths from # module show output. if pkg.compiler.modules and len(pkg.compiler.modules) > 1: rpaths.append(get_path_from_module(pkg.compiler.modules[1])) return rpaths
def get_rpaths(pkg): """Get a list of all the rpaths for a package.""" rpaths = [pkg.prefix.lib, pkg.prefix.lib64] deps = get_rpath_deps(pkg) rpaths.extend(d.prefix.lib for d in deps if os.path.isdir(d.prefix.lib)) rpaths.extend(d.prefix.lib64 for d in deps if os.path.isdir(d.prefix.lib64)) # Second module is our compiler mod name. We use that to get rpaths from # module show output. if pkg.compiler.modules and len(pkg.compiler.modules) > 1: rpaths.append(get_path_from_module(pkg.compiler.modules[1])) return rpaths