Beispiel #1
0
def install(name, keep_prefix=False, keep_stage=False, ignore_deps=False, environs=None, compiler=None):
    _init_spack()
    from spack import repo, installed_db
    from spack.cmd import parse_specs
    from os import environ
    if not isinstance(name, str):
        results = [], []
        for pkg in name:
            a, b = install(pkg, keep_prefix=keep_prefix, keep_stage=keep_stage,
                           ignore_deps=ignore_deps, environs=environs,
                           compiler=compiler)
            results[0].extend(a)
            results[1].extend(b)
        return results
    if environs is not None:
        environ.update(environs)
    if compiler is not None:
        names = name.split()
        names.insert(1, "%" + compiler.rstrip().lstrip())
        name = ' '.join(names)
    specs = parse_specs(name, concretize=True)
    packages = [repo.get(spec) for spec in specs]
    new_pkgs = [u for u in packages if not u.installed]
    for package in new_pkgs:
        with installed_db.write_transaction():
            package.do_install(
                keep_prefix=keep_prefix,
                keep_stage=keep_stage,
                ignore_deps=ignore_deps
            )
    return [p.name for p in new_pkgs if p.installed], \
        [p.name for p in new_pkgs if not p.installed]
Beispiel #2
0
def installed_spec(specs=None, pillar=None, default=None):
    """ Returns concretized spec object of installed package """
    from spack import repo
    result = spec(specs, pillar=pillar, default=default)
    if repo.get(result).installed is False:
        raise Exception("Requested package is not installed")
    return result
Beispiel #3
0
def installed_spec(specs=None, pillar=None, default=None):
    """ Returns concretized spec object of installed package """
    from spack import repo
    result = spec(specs, pillar=pillar, default=default)
    if repo.get(result).installed is False:
        raise Exception("Requested package is not installed")
    return result
Beispiel #4
0
def is_installed(name, compiler=None):
    _init_spack()
    from spack import repo
    from spack.cmd import parse_specs
    names = [name] if isinstance(name, str) else name
    for name in names:
        if compiler is not None:
            name = name.split()
            name.insert(1, "%" + compiler.rstrip().lstrip())
            name = ' '.join(name)
        specs = parse_specs(name, concretize=True)
        for spec in specs:
           a = repo.get(spec)
           if not a.installed:
               return False
    return True
Beispiel #5
0
def is_installed(name, compiler=None):
    _init_spack()
    from spack import repo
    from spack.cmd import parse_specs
    names = [name] if isinstance(name, str) else name
    for name in names:
        if compiler is not None:
            name = name.split()
            name.insert(1, "%" + compiler.rstrip().lstrip())
            name = ' '.join(name)
        specs = parse_specs(name, concretize=True)
        for spec in specs:
            a = repo.get(spec)
            if not a.installed:
                return False
    return True
Beispiel #6
0
def install(name,
            keep_prefix=False,
            keep_stage=False,
            install_deps=True,
            environs=None,
            compiler=None):
    _init_spack()
    from spack import repo
    from spack.store import db as installed_db
    from spack.cmd import parse_specs
    from os import environ
    if not isinstance(name, str):
        results = [], []
        for pkg in name:
            a, b = install(
                pkg,
                keep_prefix=keep_prefix,
                keep_stage=keep_stage,
                install_deps=install_deps,
                environs=environs,
                compiler=compiler)
            results[0].extend(a)
            results[1].extend(b)
        return results
    if environs is not None:
        environ.update(environs)
    if compiler is not None:
        names = name.split()
        names.insert(1, "%" + compiler.rstrip().lstrip())
        name = ' '.join(names)
    specs = parse_specs(name, concretize=True)
    packages = [repo.get(spec) for spec in specs]
    new_pkgs = [u for u in packages if not u.installed]
    for package in new_pkgs:
        with installed_db.write_transaction():
            package.do_install(
                keep_prefix=keep_prefix,
                keep_stage=keep_stage,
                install_deps=install_deps)
    return [p.name for p in new_pkgs if p.installed], \
        [p.name for p in new_pkgs if not p.installed]