Changed all target values to architecture. Also added a sort_key method so that older architecture specs can be sorted with the newer ones
This commit is contained in:
parent
749508af01
commit
918ad28a93
2 changed files with 16 additions and 92 deletions
|
@ -32,8 +32,6 @@
|
||||||
import shutil
|
import shutil
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import platform
|
import platform
|
||||||
import re
|
|
||||||
|
|
||||||
from llnl.util.filesystem import *
|
from llnl.util.filesystem import *
|
||||||
|
|
||||||
import spack
|
import spack
|
||||||
|
@ -59,9 +57,6 @@
|
||||||
SPACK_SHORT_SPEC = 'SPACK_SHORT_SPEC'
|
SPACK_SHORT_SPEC = 'SPACK_SHORT_SPEC'
|
||||||
SPACK_DEBUG_LOG_DIR = 'SPACK_DEBUG_LOG_DIR'
|
SPACK_DEBUG_LOG_DIR = 'SPACK_DEBUG_LOG_DIR'
|
||||||
|
|
||||||
SPACK_CRAYPE = 'SPACK_CRAYPE'
|
|
||||||
SPACK_COMP_MODULE = 'SPACK_COMP_MODULE'
|
|
||||||
|
|
||||||
|
|
||||||
class MakeExecutable(Executable):
|
class MakeExecutable(Executable):
|
||||||
"""Special callable executable object for make so the user can
|
"""Special callable executable object for make so the user can
|
||||||
|
@ -88,68 +83,6 @@ def __call__(self, *args, **kwargs):
|
||||||
return super(MakeExecutable, self).__call__(*args, **kwargs)
|
return super(MakeExecutable, self).__call__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def load_module(mod):
|
|
||||||
"""Takes a module name and removes modules until it is possible to
|
|
||||||
load that module. It then loads the provided module. Depends on the
|
|
||||||
modulecmd implementation of modules used in cray and lmod.
|
|
||||||
"""
|
|
||||||
#Create an executable of the module command that will output python code
|
|
||||||
modulecmd = which('modulecmd')
|
|
||||||
modulecmd.add_default_arg('python')
|
|
||||||
|
|
||||||
# Read the module and remove any conflicting modules
|
|
||||||
# We do this without checking that they are already installed
|
|
||||||
# for ease of programming because unloading a module that is not
|
|
||||||
# loaded does nothing.
|
|
||||||
text = modulecmd('show', mod, output=str, error=str).split()
|
|
||||||
for i, word in enumerate(text):
|
|
||||||
if word == 'conflict':
|
|
||||||
exec(compile(modulecmd('unload', text[i+1], output=str, error=str), '<string>', 'exec'))
|
|
||||||
# Load the module now that there are no conflicts
|
|
||||||
load = modulecmd('load', mod, output=str, error=str)
|
|
||||||
exec(compile(load, '<string>', 'exec'))
|
|
||||||
|
|
||||||
|
|
||||||
def get_path_from_module(mod):
|
|
||||||
"""Inspects a TCL module for entries that indicate the absolute path
|
|
||||||
at which the library supported by said module can be found.
|
|
||||||
"""
|
|
||||||
# Create a modulecmd executable
|
|
||||||
modulecmd = which('modulecmd')
|
|
||||||
modulecmd.add_default_arg('python')
|
|
||||||
|
|
||||||
# Read the module
|
|
||||||
text = modulecmd('show', mod, output=str, error=str).split('\n')
|
|
||||||
|
|
||||||
# If it lists its package directory, return that
|
|
||||||
for line in text:
|
|
||||||
if line.find(mod.upper()+'_DIR') >= 0:
|
|
||||||
words = line.split()
|
|
||||||
return words[2]
|
|
||||||
|
|
||||||
# If it lists a -rpath instruction, use that
|
|
||||||
for line in text:
|
|
||||||
rpath = line.find('-rpath/')
|
|
||||||
if rpath >= 0:
|
|
||||||
return line[rpath+6:line.find('/lib')]
|
|
||||||
|
|
||||||
# If it lists a -L instruction, use that
|
|
||||||
for line in text:
|
|
||||||
L = line.find('-L/')
|
|
||||||
if L >= 0:
|
|
||||||
return line[L+2:line.find('/lib')]
|
|
||||||
|
|
||||||
# If it sets the LD_LIBRARY_PATH or CRAY_LD_LIBRARY_PATH, use that
|
|
||||||
for line in text:
|
|
||||||
if line.find('LD_LIBRARY_PATH') >= 0:
|
|
||||||
words = line.split()
|
|
||||||
path = words[2]
|
|
||||||
return path[:path.find('/lib')]
|
|
||||||
|
|
||||||
# Unable to find module path
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def set_compiler_environment_variables(pkg):
|
def set_compiler_environment_variables(pkg):
|
||||||
assert(pkg.spec.concrete)
|
assert(pkg.spec.concrete)
|
||||||
compiler = pkg.compiler
|
compiler = pkg.compiler
|
||||||
|
@ -176,10 +109,6 @@ def set_compiler_environment_variables(pkg):
|
||||||
|
|
||||||
os.environ['SPACK_COMPILER_SPEC'] = str(pkg.spec.compiler)
|
os.environ['SPACK_COMPILER_SPEC'] = str(pkg.spec.compiler)
|
||||||
|
|
||||||
if compiler.strategy == 'MODULES':
|
|
||||||
for mod in compiler.modules:
|
|
||||||
load_module(mod)
|
|
||||||
|
|
||||||
|
|
||||||
def set_build_environment_variables(pkg):
|
def set_build_environment_variables(pkg):
|
||||||
"""This ensures a clean install environment when we build packages.
|
"""This ensures a clean install environment when we build packages.
|
||||||
|
@ -243,8 +172,6 @@ def add_env_path(path):
|
||||||
pkg_config_dirs.append(pcdir)
|
pkg_config_dirs.append(pcdir)
|
||||||
path_set("PKG_CONFIG_PATH", pkg_config_dirs)
|
path_set("PKG_CONFIG_PATH", pkg_config_dirs)
|
||||||
|
|
||||||
if pkg.spec.architecture.target.module_name:
|
|
||||||
load_module(pkg.spec.architecture.target.module_name)
|
|
||||||
|
|
||||||
def set_module_variables_for_package(pkg, m):
|
def set_module_variables_for_package(pkg, m):
|
||||||
"""Populate the module scope of install() with some useful functions.
|
"""Populate the module scope of install() with some useful functions.
|
||||||
|
@ -314,21 +241,10 @@ def set_module_variables_for_package(pkg, m):
|
||||||
|
|
||||||
def get_rpaths(pkg):
|
def get_rpaths(pkg):
|
||||||
"""Get a list of all the rpaths for a package."""
|
"""Get a list of all the rpaths for a package."""
|
||||||
|
|
||||||
# First load all modules for external packages and update the external
|
|
||||||
# packages' paths to reflect what is found in the modules so that we can
|
|
||||||
# rpath through the modules when possible, but if not possible they are
|
|
||||||
# already loaded.
|
|
||||||
for spec in pkg.spec.traverse(root=False):
|
|
||||||
if spec.external_module:
|
|
||||||
load_module(spec.external_module)
|
|
||||||
spec.external = get_path_from_module(spec.external_module)
|
|
||||||
|
|
||||||
# Construct rpaths from the paths of each dep
|
|
||||||
rpaths = [pkg.prefix.lib, pkg.prefix.lib64]
|
rpaths = [pkg.prefix.lib, pkg.prefix.lib64]
|
||||||
rpaths.extend(d.prefix.lib for d in pkg.spec.traverse(root=False)
|
rpaths.extend(d.prefix.lib for d in pkg.spec.dependencies.values()
|
||||||
if os.path.isdir(d.prefix.lib))
|
if os.path.isdir(d.prefix.lib))
|
||||||
rpaths.extend(d.prefix.lib64 for d in pkg.spec.traverse(root=False)
|
rpaths.extend(d.prefix.lib64 for d in pkg.spec.dependencies.values()
|
||||||
if os.path.isdir(d.prefix.lib64))
|
if os.path.isdir(d.prefix.lib64))
|
||||||
return rpaths
|
return rpaths
|
||||||
|
|
||||||
|
@ -348,8 +264,8 @@ def parent_class_modules(cls):
|
||||||
|
|
||||||
def setup_package(pkg):
|
def setup_package(pkg):
|
||||||
"""Execute all environment setup routines."""
|
"""Execute all environment setup routines."""
|
||||||
set_build_environment_variables(pkg)
|
|
||||||
set_compiler_environment_variables(pkg)
|
set_compiler_environment_variables(pkg)
|
||||||
|
set_build_environment_variables(pkg)
|
||||||
|
|
||||||
# If a user makes their own package repo, e.g.
|
# If a user makes their own package repo, e.g.
|
||||||
# spack.repos.mystuff.libelf.Libelf, and they inherit from
|
# spack.repos.mystuff.libelf.Libelf, and they inherit from
|
||||||
|
|
|
@ -90,18 +90,26 @@ def display_specs(specs, **kwargs):
|
||||||
hlen = None
|
hlen = None
|
||||||
|
|
||||||
# Make a dict with specs keyed by target and compiler.
|
# Make a dict with specs keyed by target and compiler.
|
||||||
index = index_by(specs, ('target', 'compiler'))
|
index = index_by(specs, ('architecture', 'compiler'))
|
||||||
|
|
||||||
# Traverse the index and print out each package
|
# Create sort key based off of whether read architecture is string
|
||||||
for i, (target, compiler) in enumerate(sorted(index)):
|
def sort_key(index_dict):
|
||||||
|
if isinstance(index_dict[0],basestring):
|
||||||
|
return(str, index_dict[1]._cmp_key())
|
||||||
|
elif isinstance(index_dict[0], spack.architecture.Arch):
|
||||||
|
return (index_dict[0]._cmp_key(), index_dict[1]._cmp_key())
|
||||||
|
|
||||||
|
sorted_index = sorted(index, key=sort_key)
|
||||||
|
|
||||||
|
for i, (architecture, compiler) in enumerate(sorted_index):
|
||||||
if i > 0: print
|
if i > 0: print
|
||||||
|
|
||||||
header = "%s{%s} / %s{%s}" % (
|
header = "%s{%s} / %s{%s}" % (
|
||||||
spack.spec.target_color, target,
|
spack.spec.architecture_color, architecture,
|
||||||
spack.spec.compiler_color, compiler)
|
spack.spec.compiler_color, compiler)
|
||||||
tty.hline(colorize(header), char='-')
|
tty.hline(colorize(header), char='-')
|
||||||
|
|
||||||
specs = index[(target,compiler)]
|
specs = index[(architecture, compiler)]
|
||||||
specs.sort()
|
specs.sort()
|
||||||
|
|
||||||
nfmt = '.' if namespace else '_'
|
nfmt = '.' if namespace else '_'
|
||||||
|
|
Loading…
Reference in a new issue