summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/__init__.py47
-rw-r--r--lib/spack/spack/architecture.py6
-rw-r--r--lib/spack/spack/build_environment.py42
-rw-r--r--lib/spack/spack/cmd/__init__.py8
-rw-r--r--lib/spack/spack/cmd/blame.py6
-rw-r--r--lib/spack/spack/cmd/clone.py4
-rw-r--r--lib/spack/spack/cmd/common/__init__.py9
-rw-r--r--lib/spack/spack/cmd/debug.py4
-rw-r--r--lib/spack/spack/cmd/edit.py16
-rw-r--r--lib/spack/spack/cmd/flake8.py19
-rw-r--r--lib/spack/spack/cmd/gpg.py9
-rw-r--r--lib/spack/spack/cmd/install.py4
-rw-r--r--lib/spack/spack/cmd/location.py8
-rw-r--r--lib/spack/spack/cmd/pkg.py12
-rw-r--r--lib/spack/spack/cmd/test.py4
-rw-r--r--lib/spack/spack/compilers/__init__.py9
-rw-r--r--lib/spack/spack/compilers/clang.py11
-rw-r--r--lib/spack/spack/compilers/gcc.py4
-rw-r--r--lib/spack/spack/compilers/intel.py2
-rw-r--r--lib/spack/spack/compilers/nag.py2
-rw-r--r--lib/spack/spack/compilers/pgi.py2
-rw-r--r--lib/spack/spack/compilers/xl.py2
-rw-r--r--lib/spack/spack/compilers/xl_r.py2
-rw-r--r--lib/spack/spack/config.py10
-rw-r--r--lib/spack/spack/hooks/__init__.py6
-rw-r--r--lib/spack/spack/hooks/sbang.py4
-rw-r--r--lib/spack/spack/main.py29
-rw-r--r--lib/spack/spack/modules/common.py5
-rw-r--r--lib/spack/spack/package.py19
-rw-r--r--lib/spack/spack/paths.py80
-rw-r--r--lib/spack/spack/platforms/cray.py2
-rw-r--r--lib/spack/spack/spec.py3
-rw-r--r--lib/spack/spack/stage.py26
-rw-r--r--lib/spack/spack/store.py4
-rw-r--r--lib/spack/spack/test/build_environment.py8
-rw-r--r--lib/spack/spack/test/cc.py12
-rw-r--r--lib/spack/spack/test/cmd/blame.py4
-rw-r--r--lib/spack/spack/test/cmd/flake8.py6
-rw-r--r--lib/spack/spack/test/cmd/gpg.py11
-rw-r--r--lib/spack/spack/test/cmd/url.py15
-rw-r--r--lib/spack/spack/test/config.py19
-rw-r--r--lib/spack/spack/test/conftest.py19
-rw-r--r--lib/spack/spack/test/directory_layout.py3
-rw-r--r--lib/spack/spack/test/environment.py2
-rw-r--r--lib/spack/spack/test/llnl/util/file_list.py11
-rw-r--r--lib/spack/spack/test/modules/conftest.py13
-rw-r--r--lib/spack/spack/test/package_sanity.py4
-rw-r--r--lib/spack/spack/test/packages.py12
-rw-r--r--lib/spack/spack/test/packaging.py3
-rw-r--r--lib/spack/spack/test/patch.py6
-rw-r--r--lib/spack/spack/test/python_version.py32
-rw-r--r--lib/spack/spack/test/repo.py7
-rw-r--r--lib/spack/spack/test/sbang.py4
-rw-r--r--lib/spack/spack/test/stage.py13
-rw-r--r--lib/spack/spack/test/web.py4
-rw-r--r--lib/spack/spack/util/executable.py2
-rw-r--r--lib/spack/spack/util/gpg.py5
-rw-r--r--lib/spack/spack/util/naming.py2
-rw-r--r--lib/spack/spack/util/path.py6
-rw-r--r--var/spack/repos/builtin.mock/packages/url-list-test/package.py4
-rw-r--r--var/spack/repos/builtin/packages/cbtf-krell/package.py1
-rw-r--r--var/spack/repos/builtin/packages/gobject-introspection/package.py2
-rw-r--r--var/spack/repos/builtin/packages/openspeedshop/package.py1
-rw-r--r--var/spack/repos/builtin/packages/perl/package.py6
-rw-r--r--var/spack/repos/builtin/packages/python/package.py6
65 files changed, 367 insertions, 296 deletions
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py
index bc41c9ff23..e0ed62c0fd 100644
--- a/lib/spack/spack/__init__.py
+++ b/lib/spack/spack/__init__.py
@@ -27,51 +27,7 @@ import os
import sys
import multiprocessing
-from llnl.util.filesystem import ancestor
-
-#-----------------------------------------------------------------------------
-# Variables describing how Spack is laid out in its prefix.
-#-----------------------------------------------------------------------------
-# This file lives in $prefix/lib/spack/spack/__file__
-spack_root = ancestor(__file__, 4)
-
-# The spack script itself
-spack_file = os.path.join(spack_root, "bin", "spack")
-
-# spack directory hierarchy
-lib_path = os.path.join(spack_root, "lib", "spack")
-external_path = os.path.join(lib_path, "external")
-build_env_path = os.path.join(lib_path, "env")
-module_path = os.path.join(lib_path, "spack")
-platform_path = os.path.join(module_path, 'platforms')
-compilers_path = os.path.join(module_path, "compilers")
-build_systems_path = os.path.join(module_path, 'build_systems')
-operating_system_path = os.path.join(module_path, 'operating_systems')
-test_path = os.path.join(module_path, "test")
-hooks_path = os.path.join(module_path, "hooks")
-var_path = os.path.join(spack_root, "var", "spack")
-stage_path = os.path.join(var_path, "stage")
-repos_path = os.path.join(var_path, "repos")
-share_path = os.path.join(spack_root, "share", "spack")
-
-# Paths to built-in Spack repositories.
-packages_path = os.path.join(repos_path, "builtin")
-mock_packages_path = os.path.join(repos_path, "builtin.mock")
-
-# User configuration location
-user_config_path = os.path.expanduser('~/.spack')
-
-prefix = spack_root
-opt_path = os.path.join(prefix, "opt")
-etc_path = os.path.join(prefix, "etc")
-system_etc_path = '/etc'
-
-# GPG paths.
-gpg_keys_path = os.path.join(var_path, "gpg")
-mock_gpg_data_path = os.path.join(var_path, "gpg.mock", "data")
-mock_gpg_keys_path = os.path.join(var_path, "gpg.mock", "keys")
-gpg_path = os.path.join(opt_path, "spack", "gpg")
-
+from spack.paths import var_path, user_config_path
#-----------------------------------------------------------------------------
# Below code imports spack packages.
@@ -280,4 +236,3 @@ __all__ += [
# Add default values for attributes that would otherwise be modified from
# Spack main script
debug = False
-spack_working_dir = None
diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py
index 900747bedc..a3407b95d1 100644
--- a/lib/spack/spack/architecture.py
+++ b/lib/spack/spack/architecture.py
@@ -83,12 +83,12 @@ from llnl.util.lang import memoized, list_modules, key_ordering
from llnl.util.filesystem import join_path
import llnl.util.tty as tty
-import spack
+import spack.paths
+import spack.error as serr
from spack.util.naming import mod_to_class
from spack.util.environment import get_path
from spack.util.multiproc import parmap
from spack.util.spack_yaml import syaml_dict
-import spack.error as serr
class NoPlatformError(serr.SpackError):
@@ -463,7 +463,7 @@ def arch_for_spec(arch_spec):
@memoized
def all_platforms():
classes = []
- mod_path = spack.platform_path
+ mod_path = spack.paths.platform_path
parent_module = "spack.platforms"
for name in list_modules(mod_path):
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index 2bb54ab680..fc7b12f8fd 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -63,9 +63,10 @@ from six import StringIO
import llnl.util.tty as tty
from llnl.util.tty.color import colorize
-from llnl.util.filesystem import join_path, mkdirp, install, install_tree
+from llnl.util.filesystem import mkdirp, install, install_tree
-import spack
+import spack.main
+import spack.paths
import spack.store
from spack.environment import EnvironmentModifications, validate
from spack.util.environment import env_flag, filter_system_paths, get_path
@@ -138,21 +139,21 @@ def set_compiler_environment_variables(pkg, env):
# and return it
# TODO : add additional kwargs for better diagnostics, like requestor,
# ttyout, ttyerr, etc.
- link_dir = spack.build_env_path
+ link_dir = spack.paths.build_env_path
# Set SPACK compiler variables so that our wrapper knows what to call
if compiler.cc:
env.set('SPACK_CC', compiler.cc)
- env.set('CC', join_path(link_dir, compiler.link_paths['cc']))
+ env.set('CC', os.path.join(link_dir, compiler.link_paths['cc']))
if compiler.cxx:
env.set('SPACK_CXX', compiler.cxx)
- env.set('CXX', join_path(link_dir, compiler.link_paths['cxx']))
+ env.set('CXX', os.path.join(link_dir, compiler.link_paths['cxx']))
if compiler.f77:
env.set('SPACK_F77', compiler.f77)
- env.set('F77', join_path(link_dir, compiler.link_paths['f77']))
+ env.set('F77', os.path.join(link_dir, compiler.link_paths['f77']))
if compiler.fc:
env.set('SPACK_FC', compiler.fc)
- env.set('FC', join_path(link_dir, compiler.link_paths['fc']))
+ env.set('FC', os.path.join(link_dir, compiler.link_paths['fc']))
# Set SPACK compiler rpath flags so that our wrapper knows what to use
env.set('SPACK_CC_RPATH_ARG', compiler.cc_rpath_arg)
@@ -302,20 +303,21 @@ def set_build_environment_variables(pkg, env, dirty):
env.prepend_path('PATH', bin_dir)
# Add spack build environment path with compiler wrappers first in
- # the path. We add both spack.env_path, which includes default
+ # the path. We add the compiler wrapper path, which includes default
# wrappers (cc, c++, f77, f90), AND a subdirectory containing
# compiler-specific symlinks. The latter ensures that builds that
- # are sensitive to the *name* of the compiler see the right name
- # when we're building with the wrappers.
+ # are sensitive to the *name* of the compiler see the right name when
+ # we're building with the wrappers.
#
# Conflicts on case-insensitive systems (like "CC" and "cc") are
# handled by putting one in the <build_env_path>/case-insensitive
# directory. Add that to the path too.
env_paths = []
- compiler_specific = join_path(spack.build_env_path, pkg.compiler.name)
- for item in [spack.build_env_path, compiler_specific]:
+ compiler_specific = os.path.join(
+ spack.paths.build_env_path, pkg.compiler.name)
+ for item in [spack.paths.build_env_path, compiler_specific]:
env_paths.append(item)
- ci = join_path(item, 'case-insensitive')
+ ci = os.path.join(item, 'case-insensitive')
if os.path.isdir(ci):
env_paths.append(ci)
@@ -328,12 +330,12 @@ def set_build_environment_variables(pkg, env, dirty):
env.set(SPACK_DEBUG, 'TRUE')
env.set(SPACK_SHORT_SPEC, pkg.spec.short_spec)
env.set(SPACK_DEBUG_LOG_ID, pkg.spec.format('${PACKAGE}-${HASH:7}'))
- env.set(SPACK_DEBUG_LOG_DIR, spack.spack_working_dir)
+ env.set(SPACK_DEBUG_LOG_DIR, spack.main.spack_working_dir)
# Add any pkgconfig directories to PKG_CONFIG_PATH
for prefix in build_link_prefixes:
for directory in ('lib', 'lib64', 'share'):
- pcdir = join_path(prefix, directory, 'pkgconfig')
+ pcdir = os.path.join(prefix, directory, 'pkgconfig')
if os.path.isdir(pcdir):
env.prepend_path('PKG_CONFIG_PATH', pcdir)
@@ -374,11 +376,11 @@ def set_module_variables_for_package(pkg, module):
m.std_cmake_args = spack.CMakePackage._std_args(pkg)
# Put spack compiler paths in module scope.
- link_dir = spack.build_env_path
- m.spack_cc = join_path(link_dir, pkg.compiler.link_paths['cc'])
- m.spack_cxx = join_path(link_dir, pkg.compiler.link_paths['cxx'])
- m.spack_f77 = join_path(link_dir, pkg.compiler.link_paths['f77'])
- m.spack_fc = join_path(link_dir, pkg.compiler.link_paths['fc'])
+ link_dir = spack.paths.build_env_path
+ m.spack_cc = os.path.join(link_dir, pkg.compiler.link_paths['cc'])
+ m.spack_cxx = os.path.join(link_dir, pkg.compiler.link_paths['cxx'])
+ m.spack_f77 = os.path.join(link_dir, pkg.compiler.link_paths['f77'])
+ m.spack_fc = os.path.join(link_dir, pkg.compiler.link_paths['fc'])
# Emulate some shell commands for convenience
m.pwd = os.getcwd
diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py
index 3f713287e6..6c6bb8496e 100644
--- a/lib/spack/spack/cmd/__init__.py
+++ b/lib/spack/spack/cmd/__init__.py
@@ -33,8 +33,8 @@ from llnl.util.tty.colify import colify
from llnl.util.tty.color import colorize
from llnl.util.filesystem import working_dir
-import spack
import spack.config
+import spack.paths
import spack.spec
import spack.store
from spack.error import SpackError
@@ -58,8 +58,6 @@ ignore_files = r'^\.|^__init__.py$|^#'
SETUP_PARSER = "setup_parser"
DESCRIPTION = "description"
-command_path = os.path.join(spack.lib_path, "spack", "cmd")
-
#: Names of all commands
all_commands = []
@@ -74,7 +72,7 @@ def cmd_name(python_name):
return python_name.replace('_', '-')
-for file in os.listdir(command_path):
+for file in os.listdir(spack.paths.command_path):
if file.endswith(".py") and not re.search(ignore_files, file):
cmd = re.sub(r'.py$', '', file)
all_commands.append(cmd_name(cmd))
@@ -320,5 +318,5 @@ def display_specs(specs, args=None, **kwargs):
def spack_is_git_repo():
"""Ensure that this instance of Spack is a git clone."""
- with working_dir(spack.prefix):
+ with working_dir(spack.paths.prefix):
return os.path.isdir('.git')
diff --git a/lib/spack/spack/cmd/blame.py b/lib/spack/spack/cmd/blame.py
index 28dcdd27ad..38b2a13879 100644
--- a/lib/spack/spack/cmd/blame.py
+++ b/lib/spack/spack/cmd/blame.py
@@ -30,7 +30,7 @@ from llnl.util.lang import pretty_date
from llnl.util.filesystem import working_dir
from llnl.util.tty.colify import colify_table
-import spack
+import spack.paths
from spack.util.executable import which
from spack.cmd import spack_is_git_repo
@@ -67,7 +67,7 @@ def blame(parser, args):
blame_file = None
if os.path.isfile(args.package_name):
path = os.path.realpath(args.package_name)
- if path.startswith(spack.prefix):
+ if path.startswith(spack.paths.prefix):
blame_file = path
if not blame_file:
@@ -75,7 +75,7 @@ def blame(parser, args):
blame_file = pkg.module.__file__.rstrip('c') # .pyc -> .py
# get git blame for the package
- with working_dir(spack.prefix):
+ with working_dir(spack.paths.prefix):
if args.view == 'git':
git('blame', blame_file)
return
diff --git a/lib/spack/spack/cmd/clone.py b/lib/spack/spack/cmd/clone.py
index 3c548c66ed..f8b3f899ee 100644
--- a/lib/spack/spack/cmd/clone.py
+++ b/lib/spack/spack/cmd/clone.py
@@ -27,7 +27,7 @@ import os
import llnl.util.tty as tty
from llnl.util.filesystem import mkdirp, working_dir
-import spack
+import spack.paths
from spack.util.executable import ProcessError, which
_SPACK_UPSTREAM = 'https://github.com/spack/spack'
@@ -47,7 +47,7 @@ def setup_parser(subparser):
def get_origin_info(remote):
- git_dir = os.path.join(spack.prefix, '.git')
+ git_dir = os.path.join(spack.paths.prefix, '.git')
git = which('git', required=True)
try:
branch = git('symbolic-ref', '--short', 'HEAD', output=str)
diff --git a/lib/spack/spack/cmd/common/__init__.py b/lib/spack/spack/cmd/common/__init__.py
index e7e2b142f8..25cfdf4398 100644
--- a/lib/spack/spack/cmd/common/__init__.py
+++ b/lib/spack/spack/cmd/common/__init__.py
@@ -23,7 +23,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
-import spack
+import spack.paths
from llnl.util import tty
@@ -35,9 +35,10 @@ def print_module_placeholder_help():
"To initialize spack's shell commands, you must run one of",
"the commands below. Choose the right command for your shell.",
"", "For bash and zsh:",
- " . %s/setup-env.sh" % spack.share_path, "",
- "For csh and tcsh:", " setenv SPACK_ROOT %s" % spack.prefix,
- " source %s/setup-env.csh" % spack.share_path, "",
+ " . %s/setup-env.sh" % spack.paths.share_path, "",
+ "For csh and tcsh:",
+ " setenv SPACK_ROOT %s" % spack.paths.prefix,
+ " source %s/setup-env.csh" % spack.paths.share_path, "",
"This exposes a 'spack' shell function, which you can use like",
" $ spack load package-foo", "",
"Running the Spack executable directly (for example, invoking",
diff --git a/lib/spack/spack/cmd/debug.py b/lib/spack/spack/cmd/debug.py
index db8180621a..2a85be8a00 100644
--- a/lib/spack/spack/cmd/debug.py
+++ b/lib/spack/spack/cmd/debug.py
@@ -30,7 +30,7 @@ from glob import glob
import llnl.util.tty as tty
from llnl.util.filesystem import working_dir
-import spack
+import spack.paths
from spack.util.executable import which
description = "debugging commands for troubleshooting Spack"
@@ -52,7 +52,7 @@ def _debug_tarball_suffix():
if not git:
return 'nobranch-nogit-%s' % suffix
- with working_dir(spack.spack_root):
+ with working_dir(spack.paths.prefix):
if not os.path.isdir('.git'):
return 'nobranch.nogit.%s' % suffix
diff --git a/lib/spack/spack/cmd/edit.py b/lib/spack/spack/cmd/edit.py
index 32a892e565..0b555d50e1 100644
--- a/lib/spack/spack/cmd/edit.py
+++ b/lib/spack/spack/cmd/edit.py
@@ -27,8 +27,8 @@ import glob
import llnl.util.tty as tty
-import spack
import spack.cmd
+import spack.paths
from spack.spec import Spec
from spack.repository import Repo
@@ -74,23 +74,23 @@ def setup_parser(subparser):
# Edits package files by default
excl_args.add_argument(
'-b', '--build-system', dest='path', action='store_const',
- const=spack.build_systems_path,
+ const=spack.paths.build_systems_path,
help="Edit the build system with the supplied name.")
excl_args.add_argument(
'-c', '--command', dest='path', action='store_const',
- const=spack.cmd.command_path,
+ const=spack.paths.command_path,
help="edit the command with the supplied name")
excl_args.add_argument(
'-d', '--docs', dest='path', action='store_const',
- const=os.path.join(spack.lib_path, 'docs'),
+ const=os.path.join(spack.paths.lib_path, 'docs'),
help="edit the docs with the supplied name")
excl_args.add_argument(
'-t', '--test', dest='path', action='store_const',
- const=spack.test_path,
+ const=spack.paths.test_path,
help="edit the test with the supplied name")
excl_args.add_argument(
'-m', '--module', dest='path', action='store_const',
- const=spack.module_path,
+ const=spack.paths.module_path,
help="edit the main spack module with the supplied name")
# Options for editing packages
@@ -110,14 +110,14 @@ def edit(parser, args):
name = args.name
# By default, edit package files
- path = spack.packages_path
+ path = spack.paths.packages_path
# If `--command`, `--test`, or `--module` is chosen, edit those instead
if args.path:
path = args.path
if name:
# convert command names to python module name
- if path == spack.cmd.command_path:
+ if path == spack.paths.command_path:
name = spack.cmd.python_name(name)
path = os.path.join(path, name)
diff --git a/lib/spack/spack/cmd/flake8.py b/lib/spack/spack/cmd/flake8.py
index 40eac23034..c6fe19f30c 100644
--- a/lib/spack/spack/cmd/flake8.py
+++ b/lib/spack/spack/cmd/flake8.py
@@ -33,7 +33,7 @@ import argparse
from llnl.util.filesystem import working_dir, mkdirp
-import spack
+import spack.paths
from spack.util.executable import which
@@ -53,7 +53,7 @@ def is_package(f):
#: List of directories to exclude from checks.
-exclude_directories = [spack.external_path]
+exclude_directories = [spack.paths.external_path]
#: This is a dict that maps:
@@ -243,11 +243,12 @@ def flake8(parser, args):
if file_list:
def prefix_relative(path):
return os.path.relpath(
- os.path.abspath(os.path.realpath(path)), spack.prefix)
+ os.path.abspath(os.path.realpath(path)),
+ spack.paths.prefix)
file_list = [prefix_relative(p) for p in file_list]
- with working_dir(spack.prefix):
+ with working_dir(spack.paths.prefix):
if not file_list:
file_list = changed_files(args)
@@ -261,7 +262,7 @@ def flake8(parser, args):
# filter files into a temporary directory with exemptions added.
for filename in file_list:
- src_path = os.path.join(spack.prefix, filename)
+ src_path = os.path.join(spack.paths.prefix, filename)
dest_path = os.path.join(temp, filename)
filter_file(src_path, dest_path, args.output)
@@ -275,13 +276,14 @@ def flake8(parser, args):
if file_list:
output += flake8(
'--format', 'pylint',
- '--config=%s' % os.path.join(spack.prefix, '.flake8'),
+ '--config=%s' % os.path.join(spack.paths.prefix,
+ '.flake8'),
*file_list, fail_on_error=False, output=str)
returncode |= flake8.returncode
if package_file_list:
output += flake8(
'--format', 'pylint',
- '--config=%s' % os.path.join(spack.prefix,
+ '--config=%s' % os.path.join(spack.paths.prefix,
'.flake8_packages'),
*package_file_list, fail_on_error=False, output=str)
returncode |= flake8.returncode
@@ -293,7 +295,8 @@ def flake8(parser, args):
# print results relative to current working directory
def cwd_relative(path):
return '{0}: ['.format(os.path.relpath(
- os.path.join(spack.prefix, path.group(1)), os.getcwd()))
+ os.path.join(
+ spack.paths.prefix, path.group(1)), os.getcwd()))
for line in output.split('\n'):
print(re.sub(r'^(.*): \[', cwd_relative, line))
diff --git a/lib/spack/spack/cmd/gpg.py b/lib/spack/spack/cmd/gpg.py
index e23cfd25de..e6ff1510a2 100644
--- a/lib/spack/spack/cmd/gpg.py
+++ b/lib/spack/spack/cmd/gpg.py
@@ -22,10 +22,11 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
-from spack.util.gpg import Gpg
-import argparse
-import spack
import os
+import argparse
+
+import spack.paths
+from spack.util.gpg import Gpg
description = "handle GPG actions for spack"
section = "packaging"
@@ -148,7 +149,7 @@ def gpg_trust(args):
def gpg_init(args):
import_dir = args.import_dir
if import_dir is None:
- import_dir = spack.gpg_keys_path
+ import_dir = spack.paths.gpg_keys_path
for root, _, filenames in os.walk(import_dir):
for filename in filenames:
diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py
index 36459afd64..05998b0815 100644
--- a/lib/spack/spack/cmd/install.py
+++ b/lib/spack/spack/cmd/install.py
@@ -30,7 +30,7 @@ import sys
import llnl.util.filesystem as fs
import llnl.util.tty as tty
-import spack
+import spack.paths
import spack.build_environment
import spack.cmd
import spack.cmd.common.arguments as arguments
@@ -137,7 +137,7 @@ def default_log_file(spec):
"""
fmt = 'test-{x.name}-{x.version}-{hash}.xml'
basename = fmt.format(x=spec, hash=spec.dag_hash())
- dirname = fs.join_path(spack.var_path, 'junit-report')
+ dirname = fs.join_path(spack.paths.var_path, 'junit-report')
fs.mkdirp(dirname)
return fs.join_path(dirname, basename)
diff --git a/lib/spack/spack/cmd/location.py b/lib/spack/spack/cmd/location.py
index 719a4699db..ab3faef7f5 100644
--- a/lib/spack/spack/cmd/location.py
+++ b/lib/spack/spack/cmd/location.py
@@ -27,7 +27,7 @@ from __future__ import print_function
import argparse
import llnl.util.tty as tty
-import spack
+import spack.paths
import spack.cmd
description = "print out locations of various directories used by Spack"
@@ -73,16 +73,16 @@ def setup_parser(subparser):
def location(parser, args):
if args.module_dir:
- print(spack.module_path)
+ print(spack.paths.module_path)
elif args.spack_root:
- print(spack.prefix)
+ print(spack.paths.prefix)
elif args.packages:
print(spack.repo.first_repo().root)
elif args.stages:
- print(spack.stage_path)
+ print(spack.paths.stage_path)
else:
specs = spack.cmd.parse_specs(args.spec)
diff --git a/lib/spack/spack/cmd/pkg.py b/lib/spack/spack/cmd/pkg.py
index ec48bf0c55..cdb4e92682 100644
--- a/lib/spack/spack/cmd/pkg.py
+++ b/lib/spack/spack/cmd/pkg.py
@@ -31,7 +31,7 @@ import llnl.util.tty as tty
from llnl.util.tty.colify import colify
from llnl.util.filesystem import working_dir
-import spack
+import spack.paths
from spack.util.executable import which
from spack.cmd import spack_is_git_repo
@@ -78,11 +78,11 @@ def setup_parser(subparser):
def list_packages(rev):
- pkgpath = os.path.join(spack.packages_path, 'packages')
- relpath = pkgpath[len(spack.prefix + os.path.sep):] + os.path.sep
+ pkgpath = os.path.join(spack.paths.packages_path, 'packages')
+ relpath = pkgpath[len(spack.paths.prefix + os.path.sep):] + os.path.sep
git = which('git', required=True)
- with working_dir(spack.prefix):
+ with working_dir(spack.paths.prefix):
output = git('ls-tree', '--full-tree', '--name-only', rev, relpath,
output=str)
return sorted(line[len(relpath):] for line in output.split('\n') if line)
@@ -96,8 +96,8 @@ def pkg_add(args):
pkg_name, filename)
git = which('git', required=True)
- with working_dir(spack.prefix):
- git('-C', spack.packages_path, 'add', filename)
+ with working_dir(spack.paths.prefix):
+ git('-C', spack.paths.packages_path, 'add', filename)
def pkg_list(args):
diff --git a/lib/spack/spack/cmd/test.py b/lib/spack/spack/cmd/test.py
index 9fd53d8ae9..9d4d9e6bc8 100644
--- a/lib/spack/spack/cmd/test.py
+++ b/lib/spack/spack/cmd/test.py
@@ -34,7 +34,7 @@ from six import StringIO
from llnl.util.filesystem import working_dir
from llnl.util.tty.colify import colify
-import spack
+import spack.paths
description = "run spack's unit tests"
section = "developer"
@@ -97,7 +97,7 @@ def test(parser, args, unknown_args):
return
# pytest.ini lives in the root of the spack repository.
- with working_dir(spack.prefix):
+ with working_dir(spack.paths.prefix):
# --list and --long-list print the test output better.
if args.list or args.long_list:
do_list(args, unknown_args)
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py
index bf3a11fa2f..d83941c161 100644
--- a/lib/spack/spack/compilers/__init__.py
+++ b/lib/spack/spack/compilers/__init__.py
@@ -25,12 +25,12 @@
"""This module contains functions related to finding compilers on the
system and configuring Spack to use multiple compilers.
"""
+import os
import imp
from llnl.util.lang import list_modules
-from llnl.util.filesystem import join_path
-import spack
+import spack.paths
import spack.error
import spack.spec
import spack.config
@@ -204,7 +204,8 @@ def supported_compilers():
See available_compilers() to get a list of all the available
versions of supported compilers.
"""
- return sorted(name for name in list_modules(spack.compilers_path))
+ return sorted(
+ name for name in list_modules(spack.paths.compilers_path))
@_auto_compiler_spec
@@ -357,7 +358,7 @@ def class_for_compiler_name(compiler_name):
"""Given a compiler module name, get the corresponding Compiler class."""
assert(supported(compiler_name))
- file_path = join_path(spack.compilers_path, compiler_name + ".py")
+ file_path = os.path.join(spack.paths.compilers_path, compiler_name + ".py")
compiler_mod = imp.load_source(_imported_compilers_module, file_path)
cls = getattr(compiler_mod, mod_to_class(compiler_name))
diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py
index 81dbadfd69..ce54e49c79 100644
--- a/lib/spack/spack/compilers/clang.py
+++ b/lib/spack/spack/compilers/clang.py
@@ -29,7 +29,7 @@ from shutil import copytree, ignore_patterns
import llnl.util.tty as tty
-import spack
+import spack.paths
from spack.compiler import Compiler, _version_cache
from spack.util.executable import Executable
from spack.version import ver
@@ -48,7 +48,7 @@ class Clang(Compiler):
# Subclasses use possible names of Fortran 90 compiler
fc_names = ['flang', 'gfortran']
- # Named wrapper links within spack.build_env_path
+ # Named wrapper links within lib/spack/env
link_paths = {'cc': 'clang/clang',
'cxx': 'clang/clang++'}
@@ -228,7 +228,7 @@ class Clang(Compiler):
raise OSError(msg)
real_root = os.path.dirname(os.path.dirname(real_root))
- developer_root = os.path.join(spack.stage_path,
+ developer_root = os.path.join(spack.paths.stage_path,
'xcode-select',
self.name,
str(self.version))
@@ -267,8 +267,9 @@ class Clang(Compiler):
for fname in os.listdir(dev_dir):
if fname in bins:
os.unlink(os.path.join(dev_dir, fname))
- os.symlink(os.path.join(spack.build_env_path, 'cc'),
- os.path.join(dev_dir, fname))
+ os.symlink(
+ os.path.join(spack.paths.build_env_path, 'cc'),
+ os.path.join(dev_dir, fname))
os.symlink(developer_root, xcode_link)
diff --git a/lib/spack/spack/compilers/gcc.py b/lib/spack/spack/compilers/gcc.py
index 71ae6187ea..e52dd5c047 100644
--- a/lib/spack/spack/compilers/gcc.py
+++ b/lib/spack/spack/compilers/gcc.py
@@ -24,7 +24,7 @@
##############################################################################
import llnl.util.tty as tty
-import spack
+import spack.compilers.clang
from spack.compiler import Compiler, get_compiler_version
from spack.version import ver
@@ -47,7 +47,7 @@ class Gcc(Compiler):
# Old compatibility versions may contain XY suffixes.
suffixes = [r'-mp-\d\.\d', r'-\d\.\d', r'-\d', r'\d\d']
- # Named wrapper links within spack.build_env_path
+ # Named wrapper links within build_env_path
link_paths = {'cc': 'gcc/gcc',
'cxx': 'gcc/g++',
'f77': 'gcc/gfortran',
diff --git a/lib/spack/spack/compilers/intel.py b/lib/spack/spack/compilers/intel.py
index e18a30587e..0c5ba3ab40 100644
--- a/lib/spack/spack/compilers/intel.py
+++ b/lib/spack/spack/compilers/intel.py
@@ -41,7 +41,7 @@ class Intel(Compiler):
# Subclasses use possible names of Fortran 90 compiler
fc_names = ['ifort']
- # Named wrapper links within spack.build_env_path
+ # Named wrapper links within build_env_path
link_paths = {'cc': 'intel/icc',
'cxx': 'intel/icpc',
'f77': 'intel/ifort',
diff --git a/lib/spack/spack/compilers/nag.py b/lib/spack/spack/compilers/nag.py
index 1204218b8a..dbe7ae55cf 100644
--- a/lib/spack/spack/compilers/nag.py
+++ b/lib/spack/spack/compilers/nag.py
@@ -38,7 +38,7 @@ class Nag(Compiler):
# Subclasses use possible names of Fortran 90 compiler
fc_names = ['nagfor']
- # Named wrapper links within spack.build_env_path
+ # Named wrapper links within build_env_path
# Use default wrappers for C and C++, in case provided in compilers.yaml
link_paths = {
'cc': 'cc',
diff --git a/lib/spack/spack/compilers/pgi.py b/lib/spack/spack/compilers/pgi.py
index c33589e092..3693b3a4a6 100644
--- a/lib/spack/spack/compilers/pgi.py
+++ b/lib/spack/spack/compilers/pgi.py
@@ -38,7 +38,7 @@ class Pgi(Compiler):
# Subclasses use possible names of Fortran 90 compiler
fc_names = ['pgfortran', 'pgf95', 'pgf90']
- # Named wrapper links within spack.build_env_path
+ # Named wrapper links within build_env_path
link_paths = {'cc': 'pgi/pgcc',
'cxx': 'pgi/pgc++',
'f77': 'pgi/pgfortran',
diff --git a/lib/spack/spack/compilers/xl.py b/lib/spack/spack/compilers/xl.py
index 1e5ca52d33..7b5bd3994b 100644
--- a/lib/spack/spack/compilers/xl.py
+++ b/lib/spack/spack/compilers/xl.py
@@ -41,7 +41,7 @@ class Xl(Compiler):
# Subclasses use possible names of Fortran 90 compiler
fc_names = ['xlf90', 'xlf95', 'xlf2003', 'xlf2008']
- # Named wrapper links within spack.build_env_path
+ # Named wrapper links within build_env_path
link_paths = {'cc': 'xl/xlc',
'cxx': 'xl/xlc++',
'f77': 'xl/xlf',
diff --git a/lib/spack/spack/compilers/xl_r.py b/lib/spack/spack/compilers/xl_r.py
index 717d631873..774db363af 100644
--- a/lib/spack/spack/compilers/xl_r.py
+++ b/lib/spack/spack/compilers/xl_r.py
@@ -42,7 +42,7 @@ class XlR(Compiler):
# Subclasses use possible names of Fortran 90 compiler
fc_names = ['xlf90_r', 'xlf95_r', 'xlf2003_r', 'xlf2008_r']
- # Named wrapper links within spack.build_env_path
+ # Named wrapper links within build_env_path
link_paths = {'cc': 'xl_r/xlc_r',
'cxx': 'xl_r/xlc++_r',
'f77': 'xl_r/xlf_r',
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py
index a83eaf4fb6..ba08977e72 100644
--- a/lib/spack/spack/config.py
+++ b/lib/spack/spack/config.py
@@ -64,7 +64,7 @@ from jsonschema import Draft4Validator, validators
import llnl.util.tty as tty
from llnl.util.filesystem import mkdirp
-import spack
+import spack.paths
import spack.architecture
import spack.schema
from spack.error import SpackError
@@ -218,24 +218,24 @@ _platform = spack.architecture.platform().name
#: Default configuration scope is the lowest-level scope. These are
#: versioned with Spack and can be overridden by systems, sites or users.
-_defaults_path = os.path.join(spack.etc_path, 'spack', 'defaults')
+_defaults_path = os.path.join(spack.paths.etc_path, 'spack', 'defaults')
ConfigScope('defaults', _defaults_path)
ConfigScope('defaults/%s' % _platform, os.path.join(_defaults_path, _platform))
#: System configuration is per machine.
#: No system-level configs should be checked into spack by default
-_system_path = os.path.join(spack.system_etc_path, 'spack')
+_system_path = os.path.join(spack.paths.system_etc_path, 'spack')
ConfigScope('system', _system_path)
ConfigScope('system/%s' % _platform, os.path.join(_system_path, _platform))
#: Site configuration is per spack instance, for sites or projects.
#: No site-level configs should be checked into spack by default.
-_site_path = os.path.join(spack.etc_path, 'spack')
+_site_path = os.path.join(spack.paths.etc_path, 'spack')
ConfigScope('site', _site_path)
ConfigScope('site/%s' % _platform, os.path.join(_site_path, _platform))
#: User configuration can override both spack defaults and site config.
-_user_path = spack.user_config_path
+_user_path = spack.paths.user_config_path
ConfigScope('user', _user_path)
ConfigScope('user/%s' % _platform, os.path.join(_user_path, _platform))
diff --git a/lib/spack/spack/hooks/__init__.py b/lib/spack/spack/hooks/__init__.py
index 4d36719aeb..66386c6d22 100644
--- a/lib/spack/spack/hooks/__init__.py
+++ b/lib/spack/spack/hooks/__init__.py
@@ -43,7 +43,7 @@
"""
import imp
-import spack
+import spack.paths
from llnl.util.filesystem import join_path
from llnl.util.lang import memoized, list_modules
@@ -51,9 +51,9 @@ from llnl.util.lang import memoized, list_modules
@memoized
def all_hook_modules():
modules = []
- for name in list_modules(spack.hooks_path):
+ for name in list_modules(spack.paths.hooks_path):
mod_name = __name__ + '.' + name
- path = join_path(spack.hooks_path, name) + ".py"
+ path = join_path(spack.paths.hooks_path, name) + ".py"
mod = imp.load_source(mod_name, path)
modules.append(mod)
diff --git a/lib/spack/spack/hooks/sbang.py b/lib/spack/spack/hooks/sbang.py
index 412aa5c083..0fdb77e1a9 100644
--- a/lib/spack/spack/hooks/sbang.py
+++ b/lib/spack/spack/hooks/sbang.py
@@ -28,7 +28,7 @@ import re
import llnl.util.tty as tty
-import spack
+import spack.paths
import spack.modules
# Character limit for shebang line. Using Linux's 127 characters
@@ -56,7 +56,7 @@ def filter_shebang(path):
original = original_file.read()
# This line will be prepended to file
- new_sbang_line = '#!/bin/bash %s/bin/sbang\n' % spack.spack_root
+ new_sbang_line = '#!/bin/bash %s/bin/sbang\n' % spack.paths.prefix
# Skip files that are already using sbang.
if original.startswith(new_sbang_line):
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py
index 7e2b447501..c8ccf2447e 100644
--- a/lib/spack/spack/main.py
+++ b/lib/spack/spack/main.py
@@ -41,28 +41,29 @@ import llnl.util.tty as tty
from llnl.util.tty.log import log_output
import spack
+import spack.paths
from spack.error import SpackError
-# names of profile statistics
+#: names of profile statistics
stat_names = pstats.Stats.sort_arg_dict_default
-# help levels in order of detail (i.e., number of commands shown)
+#: help levels in order of detail (i.e., number of commands shown)
levels = ['short', 'long']
-# intro text for help at different levels
+#: intro text for help at different levels
intro_by_level = {
'short': 'These are common spack commands:',
'long': 'Complete list of spack commands:',
}
-# control top-level spack options shown in basic vs. advanced help
+#: control top-level spack options shown in basic vs. advanced help
options_by_level = {
'short': ['h', 'k', 'V', 'color'],
'long': 'all'
}
-# Longer text for each section, to show in help
+#: Longer text for each section, to show in help
section_descriptions = {
'admin': 'administration',
'basic': 'query packages',
@@ -76,8 +77,8 @@ section_descriptions = {
'system': 'system',
}
-# preferential command order for some sections (e.g., build pipeline is
-# in execution order, not alphabetical)
+#: preferential command order for some sections (e.g., build pipeline is
+#: in execution order, not alphabetical)
section_order = {
'basic': ['list', 'info', 'find'],
'build': ['fetch', 'stage', 'patch', 'configure', 'build', 'restage',
@@ -85,17 +86,21 @@ section_order = {
'packaging': ['create', 'edit']
}
-# Properties that commands are required to set.
+#: Properties that commands are required to set.
required_command_properties = ['level', 'section', 'description']
+#: Recorded directory where spack command was originally invoked
+spack_working_dir = None
+
def set_working_dir():
"""Change the working directory to getcwd, or spack prefix if no cwd."""
+ global spack_working_dir
try:
- spack.spack_working_dir = os.getcwd()
+ spack_working_dir = os.getcwd()
except OSError:
- os.chdir(spack.spack_prefix)
- spack.spack_working_dir = spack.spack_prefix
+ os.chdir(spack.paths.prefix)
+ spack_working_dir = spack.paths.prefix
def add_all_commands(parser):
@@ -347,7 +352,7 @@ def setup_main_options(args):
if args.mock:
from spack.repository import RepoPath
- spack.repo.swap(RepoPath(spack.mock_packages_path))
+ spack.repo.swap(RepoPath(spack.paths.mock_packages_path))
# If the user asked for it, don't check ssl certs.
if args.insecure:
diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py
index c77678903b..dfb5e6ab24 100644
--- a/lib/spack/spack/modules/common.py
+++ b/lib/spack/spack/modules/common.py
@@ -56,7 +56,8 @@ import re
import six
import llnl.util.filesystem
import llnl.util.tty as tty
-import spack
+
+import spack.paths
import spack.build_environment as build_environment
import spack.environment
import spack.tengine as tengine
@@ -229,7 +230,7 @@ def root_path(name):
Returns:
root folder for module file installation
"""
- path = roots.get(name, os.path.join(spack.share_path, name))
+ path = roots.get(name, os.path.join(spack.paths.share_path, name))
return spack.util.path.canonicalize_path(path)
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index c7313e956a..0fdb544b8f 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -52,7 +52,9 @@ from six import string_types
from six import with_metaclass
import llnl.util.tty as tty
+
import spack
+import spack.paths
import spack.store
import spack.compilers
import spack.directives
@@ -67,7 +69,7 @@ import spack.util.web
import spack.multimethod
import spack.binary_distribution as binary_distribution
-from llnl.util.filesystem import mkdirp, join_path, touch, ancestor
+from llnl.util.filesystem import mkdirp, join_path, touch
from llnl.util.filesystem import working_dir, install_tree, install
from llnl.util.lang import memoized
from llnl.util.link_tree import LinkTree
@@ -688,8 +690,7 @@ class PackageBase(with_metaclass(PackageMeta, object)):
def global_license_dir(self):
"""Returns the directory where global license files for all
packages are stored."""
- spack_root = ancestor(__file__, 4)
- return join_path(spack_root, 'etc', 'spack', 'licenses')
+ return os.path.join(spack.paths.prefix, 'etc', 'spack', 'licenses')
@property
def global_license_file(self):
@@ -697,8 +698,8 @@ class PackageBase(with_metaclass(PackageMeta, object)):
particular package should be stored."""
if not self.license_files:
return
- return join_path(self.global_license_dir, self.name,
- os.path.basename(self.license_files[0]))
+ return os.path.join(self.global_license_dir, self.name,
+ os.path.basename(self.license_files[0]))
@property
def version(self):
@@ -1107,9 +1108,9 @@ class PackageBase(with_metaclass(PackageMeta, object)):
# Construct paths to special files in the archive dir used to
# keep track of whether patches were successfully applied.
archive_dir = self.stage.source_path
- good_file = join_path(archive_dir, '.spack_patched')
- no_patches_file = join_path(archive_dir, '.spack_no_patches')
- bad_file = join_path(archive_dir, '.spack_patch_failed')
+ good_file = os.path.join(archive_dir, '.spack_patched')
+ no_patches_file = os.path.join(archive_dir, '.spack_no_patches')
+ bad_file = os.path.join(archive_dir, '.spack_patch_failed')
# If we encounter an archive that failed to patch, restage it
# so that we can apply all the patches again.
@@ -1619,7 +1620,7 @@ class PackageBase(with_metaclass(PackageMeta, object)):
partial = True
stage_is_managed_in_spack = self.stage.path.startswith(
- spack.stage_path)
+ spack.paths.stage_path)
if restage and stage_is_managed_in_spack:
self.stage.destroy()
self.stage.create()
diff --git a/lib/spack/spack/paths.py b/lib/spack/spack/paths.py
new file mode 100644
index 0000000000..f1954cda74
--- /dev/null
+++ b/lib/spack/spack/paths.py
@@ -0,0 +1,80 @@
+##############################################################################
+# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
+# LLNL-CODE-647188
+#
+# For details, see https://github.com/spack/spack
+# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License (as
+# published by the Free Software Foundation) version 2.1, February 1999.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
+# conditions of the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##############################################################################
+"""Defines paths that are part of Spack's directory structure.
+
+Do not import other ``spack`` modules here. This module is used
+throughout Spack and should bring in a minimal number of external
+dependencies.
+"""
+import os
+from llnl.util.filesystem import ancestor
+
+
+#: This file lives in $prefix/lib/spack/spack/__file__
+prefix = ancestor(__file__, 4)
+
+#: synonym for prefix
+spack_root = prefix
+
+#: bin directory in the spack prefix
+bin_path = os.path.join(prefix, "bin")
+
+#: The spack script itself
+spack_script = os.path.join(bin_path, "spack")
+
+# spack directory hierarchy
+lib_path = os.path.join(prefix, "lib", "spack")
+external_path = os.path.join(lib_path, "external")
+build_env_path = os.path.join(lib_path, "env")
+module_path = os.path.join(lib_path, "spack")
+command_path = os.path.join(module_path, "cmd")
+platform_path = os.path.join(module_path, 'platforms')
+compilers_path = os.path.join(module_path, "compilers")
+build_systems_path = os.path.join(module_path, 'build_systems')
+operating_system_path = os.path.join(module_path, 'operating_systems')
+test_path = os.path.join(module_path, "test")
+hooks_path = os.path.join(module_path, "hooks")
+var_path = os.path.join(prefix, "var", "spack")
+stage_path = os.path.join(var_path, "stage")
+repos_path = os.path.join(var_path, "repos")
+share_path = os.path.join(prefix, "share", "spack")
+
+# Paths to built-in Spack repositories.
+packages_path = os.path.join(repos_path, "builtin")
+mock_packages_path = os.path.join(repos_path, "builtin.mock")
+
+#: User configuration location
+user_config_path = os.path.expanduser('~/.spack')
+
+
+opt_path = os.path.join(prefix, "opt")
+etc_path = os.path.join(prefix, "etc")
+system_etc_path = '/etc'
+
+# GPG paths.
+gpg_keys_path = os.path.join(var_path, "gpg")
+mock_gpg_data_path = os.path.join(var_path, "gpg.mock", "data")
+mock_gpg_keys_path = os.path.join(var_path, "gpg.mock", "keys")
+gpg_path = os.path.join(opt_path, "spack", "gpg")
diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py
index 78c8ef377f..92f2254429 100644
--- a/lib/spack/spack/platforms/cray.py
+++ b/lib/spack/spack/platforms/cray.py
@@ -25,7 +25,7 @@
import os
import re
import llnl.util.tty as tty
-from spack import build_env_path
+from spack.paths import build_env_path
from spack.util.executable import which
from spack.architecture import Platform, Target, NoPlatformError
from spack.operating_systems.cray_frontend import CrayFrontend
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 59df9e3867..72b83440df 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -115,6 +115,7 @@ from llnl.util.lang import check_kwargs
from llnl.util.tty.color import cwrite, colorize, cescape, get_color_when
import spack
+
import spack.architecture
import spack.compilers as compilers
import spack.error
@@ -3090,7 +3091,7 @@ class Spec(object):
if self.dependencies:
out.write(fmt % token_transform(str(self.dag_hash(7))))
elif named_str == 'SPACK_ROOT':
- out.write(fmt % token_transform(spack.prefix))
+ out.write(fmt % token_transform(spack.paths.prefix))
elif named_str == 'SPACK_INSTALL':
out.write(fmt % token_transform(spack.store.root))
elif named_str == 'PREFIX':
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index b771e046b5..d282786370 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -38,7 +38,7 @@ import llnl.util.lock
from llnl.util.filesystem import mkdirp, join_path, can_access
from llnl.util.filesystem import remove_if_dead_link, remove_linked_tree
-import spack
+import spack.paths
import spack.config
import spack.error
import spack.fetch_strategy as fs
@@ -93,7 +93,7 @@ def get_tmp_root():
raise StageError("No accessible stage paths in %s", candidates)
# Return None to indicate we're using a local staging area.
- if path == canonicalize_path(spack.stage_path):
+ if path == canonicalize_path(spack.paths.stage_path):
_use_tmp_stage = False
return None
@@ -147,7 +147,7 @@ class Stage(object):
If spack.use_tmp_stage is True, spack will attempt to create
stages in a tmp directory. Otherwise, stages are created directly
- in spack.stage_path.
+ in spack.paths.stage_path.
There are two kinds of stages: named and unnamed. Named stages
can persist between runs of spack, e.g. if you fetched a tarball
@@ -216,7 +216,7 @@ class Stage(object):
if path is not None:
self.path = path
else:
- self.path = join_path(spack.stage_path, self.name)
+ self.path = join_path(spack.paths.stage_path, self.name)
# Flag to decide whether to delete the stage folder on exit or not
self.keep = keep
@@ -229,7 +229,7 @@ class Stage(object):
if self.name not in Stage.stage_locks:
sha1 = hashlib.sha1(self.name.encode('utf-8')).digest()
lock_id = prefix_bits(sha1, bit_length(sys.maxsize))
- stage_lock_path = join_path(spack.stage_path, '.lock')
+ stage_lock_path = join_path(spack.paths.stage_path, '.lock')
Stage.stage_locks[self.name] = llnl.util.lock.Lock(
stage_lock_path, lock_id, 1)
@@ -478,17 +478,17 @@ class Stage(object):
"""Creates the stage directory.
If get_tmp_root() is None, the stage directory is created
- directly under spack.stage_path, otherwise this will attempt to
+ directly under spack.paths.stage_path, otherwise this will attempt to
create a stage in a temporary directory and link it into
- spack.stage_path.
+ spack.paths.stage_path.
Spack will use the first writable location in spack.tmp_dirs
to create a stage. If there is no valid location in tmp_dirs,
- fall back to making the stage inside spack.stage_path.
+ fall back to making the stage inside spack.paths.stage_path.
"""
# Create the top-level stage directory
- mkdirp(spack.stage_path)
+ mkdirp(spack.paths.stage_path)
remove_if_dead_link(self.path)
# If a tmp_root exists then create a directory there and then link it
@@ -655,7 +655,7 @@ def _get_mirrors():
return [val for name, val in iteritems(config)]
-def ensure_access(file=spack.stage_path):
+def ensure_access(file=spack.paths.stage_path):
"""Ensure we can access a directory and die with an error if we can't."""
if not can_access(file):
tty.die("Insufficient permissions for %s" % file)
@@ -663,9 +663,9 @@ def ensure_access(file=spack.stage_path):
def purge():
"""Remove all build directories in the top-level stage path."""
- if os.path.isdir(spack.stage_path):
- for stage_dir in os.listdir(spack.stage_path):
- stage_path = join_path(spack.stage_path, stage_dir)
+ if os.path.isdir(spack.paths.stage_path):
+ for stage_dir in os.listdir(spack.paths.stage_path):
+ stage_path = join_path(spack.paths.stage_path, stage_dir)
remove_linked_tree(stage_path)
diff --git a/lib/spack/spack/store.py b/lib/spack/spack/store.py
index 2e86b9dd83..5b16fd45d6 100644
--- a/lib/spack/spack/store.py
+++ b/lib/spack/spack/store.py
@@ -43,7 +43,7 @@ configuration.
"""
import os
-import spack
+import spack.paths
import spack.config
from spack.util.path import canonicalize_path
from spack.database import Database
@@ -62,7 +62,7 @@ config = spack.config.get_config("config")
# Set up the install path
#
root = canonicalize_path(
- config.get('install_tree', os.path.join(spack.opt_path, 'spack')))
+ config.get('install_tree', os.path.join(spack.paths.opt_path, 'spack')))
#
# Set up the installed packages database
diff --git a/lib/spack/spack/test/build_environment.py b/lib/spack/spack/test/build_environment.py
index f0aa1b1fc6..653a283b1b 100644
--- a/lib/spack/spack/test/build_environment.py
+++ b/lib/spack/spack/test/build_environment.py
@@ -25,7 +25,7 @@
import os
import pytest
-import spack
+from spack.paths import build_env_path
from llnl.util.filesystem import join_path
from spack.build_environment import dso_suffix, _static_to_shared_library
from spack.util.executable import Executable
@@ -33,9 +33,9 @@ from spack.util.executable import Executable
@pytest.fixture
def build_environment():
- cc = Executable(join_path(spack.build_env_path, "cc"))
- cxx = Executable(join_path(spack.build_env_path, "c++"))
- fc = Executable(join_path(spack.build_env_path, "fc"))
+ cc = Executable(join_path(build_env_path, "cc"))
+ cxx = Executable(join_path(build_env_path, "c++"))
+ fc = Executable(join_path(build_env_path, "fc"))
realcc = "/bin/mycc"
prefix = "/spack-test-prefix"
diff --git a/lib/spack/spack/test/cc.py b/lib/spack/spack/test/cc.py
index 8290020662..25bb01cd05 100644
--- a/lib/spack/spack/test/cc.py
+++ b/lib/spack/spack/test/cc.py
@@ -31,7 +31,7 @@ import unittest
import tempfile
import shutil
-import spack
+from spack.paths import build_env_path
from llnl.util.filesystem import mkdirp, join_path
from spack.util.executable import Executable
@@ -54,11 +54,11 @@ test_command = [
class CompilerWrapperTest(unittest.TestCase):
def setUp(self):
- self.cc = Executable(join_path(spack.build_env_path, "cc"))
- self.ld = Executable(join_path(spack.build_env_path, "ld"))
- self.cpp = Executable(join_path(spack.build_env_path, "cpp"))
- self.cxx = Executable(join_path(spack.build_env_path, "c++"))
- self.fc = Executable(join_path(spack.build_env_path, "fc"))
+ self.cc = Executable(join_path(build_env_path, "cc"))
+ self.ld = Executable(join_path(build_env_path, "ld"))
+ self.cpp = Executable(join_path(build_env_path, "cpp"))
+ self.cxx = Executable(join_path(build_env_path, "c++"))
+ self.fc = Executable(join_path(build_env_path, "fc"))
self.realcc = "/bin/mycc"
self.prefix = "/spack-test-prefix"
diff --git a/lib/spack/spack/test/cmd/blame.py b/lib/spack/spack/test/cmd/blame.py
index ea56cd327a..7c793f0694 100644
--- a/lib/spack/spack/test/cmd/blame.py
+++ b/lib/spack/spack/test/cmd/blame.py
@@ -26,7 +26,7 @@ import pytest
from llnl.util.filesystem import working_dir
-import spack
+import spack.paths
import spack.cmd
from spack.main import SpackCommand
from spack.util.executable import which
@@ -56,7 +56,7 @@ def test_blame_by_percent(builtin_mock):
def test_blame_file(builtin_mock):
"""Sanity check the blame command to make sure it works."""
- with working_dir(spack.prefix):
+ with working_dir(spack.paths.prefix):
out = blame('bin/spack')
assert 'LAST_COMMIT' in out
assert 'AUTHOR' in out
diff --git a/lib/spack/spack/test/cmd/flake8.py b/lib/spack/spack/test/cmd/flake8.py
index 8d77f2300f..646568117b 100644
--- a/lib/spack/spack/test/cmd/flake8.py
+++ b/lib/spack/spack/test/cmd/flake8.py
@@ -29,7 +29,7 @@ import sys
from llnl.util.filesystem import FileFilter
-import spack
+import spack.paths
from spack.cmd.flake8 import flake8, setup_parser, changed_files
from spack.repository import Repo
from spack.util.executable import which
@@ -50,7 +50,7 @@ def flake8_package():
mock package, yields the filename, then undoes the
change on cleanup.
"""
- repo = Repo(spack.mock_packages_path)
+ repo = Repo(spack.paths.mock_packages_path)
filename = repo.filename_for_package_name('flake8')
package = FileFilter(filename)
@@ -69,7 +69,7 @@ def test_changed_files(parser, flake8_package):
# changed_files returns file paths relative to the root
# directory of Spack. Convert to absolute file paths.
files = changed_files(args)
- files = [os.path.join(spack.spack_root, path) for path in files]
+ files = [os.path.join(spack.paths.prefix, path) for path in files]
# There will likely be other files that have changed
# when these tests are run
diff --git a/lib/spack/spack/test/cmd/gpg.py b/lib/spack/spack/test/cmd/gpg.py
index a3d4cff837..f4e4fc4ec6 100644
--- a/lib/spack/spack/test/cmd/gpg.py
+++ b/lib/spack/spack/test/cmd/gpg.py
@@ -25,7 +25,8 @@
import os
import pytest
-import spack
+
+from spack.paths import mock_gpg_data_path, mock_gpg_keys_path
import spack.util.gpg as gpg_util
from spack.main import SpackCommand
from spack.util.executable import ProcessError
@@ -58,10 +59,10 @@ def has_gnupg2():
def test_gpg(gpg, tmpdir, testing_gpg_directory):
# Verify a file with an empty keyring.
with pytest.raises(ProcessError):
- gpg('verify', os.path.join(spack.mock_gpg_data_path, 'content.txt'))
+ gpg('verify', os.path.join(mock_gpg_data_path, 'content.txt'))
# Import the default key.
- gpg('init', '--from', spack.mock_gpg_keys_path)
+ gpg('init', '--from', mock_gpg_keys_path)
# List the keys.
# TODO: Test the output here.
@@ -69,14 +70,14 @@ def test_gpg(gpg, tmpdir, testing_gpg_directory):
gpg('list', '--signing')
# Verify the file now that the key has been trusted.
- gpg('verify', os.path.join(spack.mock_gpg_data_path, 'content.txt'))
+ gpg('verify', os.path.join(mock_gpg_data_path, 'content.txt'))
# Untrust the default key.
gpg('untrust', 'Spack testing')
# Now that the key is untrusted, verification should fail.
with pytest.raises(ProcessError):
- gpg('verify', os.path.join(spack.mock_gpg_data_path, 'content.txt'))
+ gpg('verify', os.path.join(mock_gpg_data_path, 'content.txt'))
# Create a file to test signing.
test_path = tmpdir.join('to-sign.txt')
diff --git a/lib/spack/spack/test/cmd/url.py b/lib/spack/spack/test/cmd/url.py
index a12880728b..6347f636af 100644
--- a/lib/spack/spack/test/cmd/url.py
+++ b/lib/spack/spack/test/cmd/url.py
@@ -44,8 +44,9 @@ def test_name_parsed_correctly():
assert name_parsed_correctly(MyPackage('r-devtools', []), 'devtools')
assert name_parsed_correctly(MyPackage('py-numpy', []), 'numpy')
assert name_parsed_correctly(MyPackage('octave-splines', []), 'splines')
- assert name_parsed_correctly(MyPackage('imagemagick', []), 'ImageMagick') # noqa
assert name_parsed_correctly(MyPackage('th-data', []), 'TH.data')
+ assert name_parsed_correctly(
+ MyPackage('imagemagick', []), 'ImageMagick')
# Expected False
assert not name_parsed_correctly(MyPackage('', []), 'hdf5')
@@ -53,7 +54,8 @@ def test_name_parsed_correctly():
assert not name_parsed_correctly(MyPackage('yaml-cpp', []), 'yamlcpp')
assert not name_parsed_correctly(MyPackage('yamlcpp', []), 'yaml-cpp')
assert not name_parsed_correctly(MyPackage('r-py-parser', []), 'parser')
- assert not name_parsed_correctly(MyPackage('oce', []), 'oce-0.18.0') # noqa
+ assert not name_parsed_correctly(
+ MyPackage('oce', []), 'oce-0.18.0')
def test_version_parsed_correctly():
@@ -70,7 +72,8 @@ def test_version_parsed_correctly():
assert not version_parsed_correctly(MyPackage('', ['1.2.3']), '1.2.4')
assert not version_parsed_correctly(MyPackage('', ['3.4a']), '3.4')
assert not version_parsed_correctly(MyPackage('', ['3.4']), '3.4b')
- assert not version_parsed_correctly(MyPackage('', ['0.18.0']), 'oce-0.18.0') # noqa
+ assert not version_parsed_correctly(
+ MyPackage('', ['0.18.0']), 'oce-0.18.0')
def test_url_parse():
@@ -120,8 +123,10 @@ def test_url_summary():
(total_urls, correct_names, correct_versions,
name_count_dict, version_count_dict) = url_summary(None)
- assert 0 < correct_names <= sum(name_count_dict.values()) <= total_urls # noqa
- assert 0 < correct_versions <= sum(version_count_dict.values()) <= total_urls # noqa
+ assert (0 < correct_names <=
+ sum(name_count_dict.values()) <= total_urls)
+ assert (0 < correct_versions <=
+ sum(version_count_dict.values()) <= total_urls)
# make sure it agrees with the actual command.
out = url('summary')
diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py
index 5188af5465..270161cfa8 100644
--- a/lib/spack/spack/test/config.py
+++ b/lib/spack/spack/test/config.py
@@ -22,17 +22,18 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
+import os
import collections
import getpass
-import os
import tempfile
-import spack.util.ordereddict
import pytest
-import spack
-import spack.config
import yaml
+
+import spack.paths
+import spack.config
from spack.util.path import canonicalize_path
+from spack.util.ordereddict import OrderedDict
# Some sample compiler config data
a_comps = {
@@ -242,7 +243,7 @@ def config(tmpdir):
"""Mocks the configuration scope."""
spack.config.clear_config_caches()
real_scope = spack.config.config_scopes
- spack.config.config_scopes = spack.util.ordereddict.OrderedDict()
+ spack.config.config_scopes = OrderedDict()
for priority in ['low', 'high']:
spack.config.ConfigScope(priority, str(tmpdir.join(priority)))
Config = collections.namedtuple('Config', ['real', 'mock'])
@@ -336,14 +337,14 @@ class TestConfig(object):
expected + path)
def test_substitute_config_variables(self):
- prefix = spack.prefix.lstrip('/')
+ prefix = spack.paths.prefix.lstrip('/')
assert os.path.join(
'/foo/bar/baz', prefix
) == canonicalize_path('/foo/bar/baz/$spack')
assert os.path.join(
- spack.prefix, 'foo/bar/baz'
+ spack.paths.prefix, 'foo/bar/baz'
) == canonicalize_path('$spack/foo/bar/baz/')
assert os.path.join(
@@ -355,7 +356,7 @@ class TestConfig(object):
) == canonicalize_path('/foo/bar/baz/${spack}')
assert os.path.join(
- spack.prefix, 'foo/bar/baz'
+ spack.paths.prefix, 'foo/bar/baz'
) == canonicalize_path('${spack}/foo/bar/baz/')
assert os.path.join(
@@ -432,7 +433,7 @@ def test_keys_are_ordered():
config_scope = spack.config.ConfigScope(
'modules',
- os.path.join(spack.test_path, 'data', 'config')
+ os.path.join(spack.paths.test_path, 'data', 'config')
)
data = config_scope.get_section('modules')
diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py
index 3cee46cbf2..311c57a4ce 100644
--- a/lib/spack/spack/test/conftest.py
+++ b/lib/spack/spack/test/conftest.py
@@ -36,6 +36,7 @@ import pytest
from llnl.util.filesystem import remove_linked_tree
import spack
+import spack.paths
import spack.architecture
import spack.database
import spack.directory_layout
@@ -77,11 +78,11 @@ def no_chdir():
@pytest.fixture(scope='session', autouse=True)
def mock_stage(tmpdir_factory):
"""Mocks up a fake stage directory for use by tests."""
- stage_path = spack.stage_path
+ stage_path = spack.paths.stage_path
new_stage = str(tmpdir_factory.mktemp('mock_stage'))
- spack.stage_path = new_stage
+ spack.paths.stage_path = new_stage
yield new_stage
- spack.stage_path = stage_path
+ spack.paths.stage_path = stage_path
@pytest.fixture(scope='session')
@@ -118,14 +119,14 @@ def check_for_leftover_stage_files(request, mock_stage, _ignore_stage_files):
yield
files_in_stage = set()
- if os.path.exists(spack.stage_path):
+ if os.path.exists(spack.paths.stage_path):
files_in_stage = set(
- os.listdir(spack.stage_path)) - _ignore_stage_files
+ os.listdir(spack.paths.stage_path)) - _ignore_stage_files
if 'disable_clean_stage_check' in request.keywords:
# clean up after tests that are expected to be dirty
for f in files_in_stage:
- path = os.path.join(spack.stage_path, f)
+ path = os.path.join(spack.paths.stage_path, f)
remove_whatever_it_is(path)
else:
_ignore_stage_files |= files_in_stage
@@ -134,7 +135,7 @@ def check_for_leftover_stage_files(request, mock_stage, _ignore_stage_files):
@pytest.fixture(autouse=True)
def mock_fetch_cache(monkeypatch):
- """Substitutes spack.fetch_cache with a mock object that does nothing
+ """Substitutes spack.paths.fetch_cache with a mock object that does nothing
and raises on fetch.
"""
class MockCache(object):
@@ -171,7 +172,7 @@ spack.architecture.platform = lambda: spack.platforms.test.Test()
@pytest.fixture(scope='session')
def repo_path():
"""Session scoped RepoPath object pointing to the mock repository"""
- return spack.repository.RepoPath(spack.mock_packages_path)
+ return spack.repository.RepoPath(spack.paths.mock_packages_path)
@pytest.fixture(scope='module')
@@ -216,7 +217,7 @@ def configuration_dir(tmpdir_factory, linux_os):
"""
tmpdir = tmpdir_factory.mktemp('configurations')
# Name of the yaml files in the test/data folder
- test_path = py.path.local(spack.test_path)
+ test_path = py.path.local(spack.paths.test_path)
compilers_yaml = test_path.join('data', 'compilers.yaml')
packages_yaml = test_path.join('data', 'packages.yaml')
config_yaml = test_path.join('data', 'config.yaml')
diff --git a/lib/spack/spack/test/directory_layout.py b/lib/spack/spack/test/directory_layout.py
index 269f98b49c..0adbf12aaa 100644
--- a/lib/spack/spack/test/directory_layout.py
+++ b/lib/spack/spack/test/directory_layout.py
@@ -31,6 +31,7 @@ import pytest
from llnl.util.filesystem import join_path
import spack
+import spack.paths
from spack.directory_layout import YamlDirectoryLayout
from spack.directory_layout import InvalidDirectoryLayoutParametersError
from spack.repository import RepoPath
@@ -186,7 +187,7 @@ def test_handle_unknown_package(
or query them again if the package goes away.
"""
layout, _ = layout_and_dir
- mock_db = RepoPath(spack.mock_packages_path)
+ mock_db = RepoPath(spack.paths.mock_packages_path)
not_in_mock = set.difference(
set(spack.repo.all_package_names()),
diff --git a/lib/spack/spack/test/environment.py b/lib/spack/spack/test/environment.py
index 6f4af17e1c..bc1b6da3a8 100644
--- a/lib/spack/spack/test/environment.py
+++ b/lib/spack/spack/test/environment.py
@@ -26,7 +26,7 @@ import os
import pytest
import spack.environment as environment
-from spack import spack_root
+from spack.paths import spack_root
from spack.environment import EnvironmentModifications
from spack.environment import RemovePath, PrependPath, AppendPath
from spack.environment import SetEnv, UnsetEnv
diff --git a/lib/spack/spack/test/llnl/util/file_list.py b/lib/spack/spack/test/llnl/util/file_list.py
index 9d000da5be..5671661435 100644
--- a/lib/spack/spack/test/llnl/util/file_list.py
+++ b/lib/spack/spack/test/llnl/util/file_list.py
@@ -22,16 +22,17 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
-
-import fnmatch
import os
+import fnmatch
-import pytest
import six
-import spack
+import pytest
+
from llnl.util.filesystem import LibraryList, HeaderList
from llnl.util.filesystem import find_libraries, find_headers, find
+import spack.paths
+
@pytest.fixture()
def library_list():
@@ -211,7 +212,7 @@ class TestHeaderList(object):
#: Directory where the data for the test below is stored
-search_dir = os.path.join(spack.test_path, 'data', 'directory_search')
+search_dir = os.path.join(spack.paths.test_path, 'data', 'directory_search')
@pytest.mark.parametrize('search_fn,search_list,root,kwargs', [
diff --git a/lib/spack/spack/test/modules/conftest.py b/lib/spack/spack/test/modules/conftest.py
index 28b672879a..b08a943c72 100644
--- a/lib/spack/spack/test/modules/conftest.py
+++ b/lib/spack/spack/test/modules/conftest.py
@@ -22,16 +22,17 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
-
+import os.path
import collections
import contextlib
import inspect
-import os.path
-import yaml
-from six import StringIO
+import yaml
import pytest
-import spack
+from six import StringIO
+
+import spack.paths
+import spack.spec
import spack.modules.common
import spack.util.path
@@ -110,7 +111,7 @@ def patch_configuration(monkeypatch, request):
writer_key = str(writer_mod.__name__).split('.')[-1]
# Root folder for configuration
root_for_conf = os.path.join(
- spack.test_path, 'data', 'modules', writer_key
+ spack.paths.test_path, 'data', 'modules', writer_key
)
def _impl(filename):
diff --git a/lib/spack/spack/test/package_sanity.py b/lib/spack/spack/test/package_sanity.py
index fc27f831c3..30c6794c2a 100644
--- a/lib/spack/spack/test/package_sanity.py
+++ b/lib/spack/spack/test/package_sanity.py
@@ -23,12 +23,12 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
"""This test does sanity checks on Spack's builtin package database."""
-
import re
import pytest
import spack
+from spack.paths import mock_packages_path
from spack.repository import RepoPath
@@ -46,7 +46,7 @@ def test_get_all_packages():
def test_get_all_mock_packages():
"""Get the mock packages once each too."""
- db = RepoPath(spack.mock_packages_path)
+ db = RepoPath(mock_packages_path)
spack.repo.swap(db)
check_db()
spack.repo.swap(db)
diff --git a/lib/spack/spack/test/packages.py b/lib/spack/spack/test/packages.py
index 0ef76ae355..2d99b20788 100644
--- a/lib/spack/spack/test/packages.py
+++ b/lib/spack/spack/test/packages.py
@@ -22,10 +22,12 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
-import spack
import pytest
from llnl.util.filesystem import join_path
+
+import spack
+from spack.paths import mock_packages_path
from spack.repository import Repo
from spack.util.naming import mod_to_class
from spack.spec import Spec
@@ -42,20 +44,20 @@ class TestPackage(object):
assert pkg.name == 'mpich'
def test_package_filename(self):
- repo = Repo(spack.mock_packages_path)
+ repo = Repo(mock_packages_path)
filename = repo.filename_for_package_name('mpich')
assert filename == join_path(
- spack.mock_packages_path,
+ mock_packages_path,
'packages',
'mpich',
'package.py'
)
def test_nonexisting_package_filename(self):
- repo = Repo(spack.mock_packages_path)
+ repo = Repo(mock_packages_path)
filename = repo.filename_for_package_name('some-nonexisting-package')
assert filename == join_path(
- spack.mock_packages_path,
+ mock_packages_path,
'packages',
'some-nonexisting-package',
'package.py'
diff --git a/lib/spack/spack/test/packaging.py b/lib/spack/spack/test/packaging.py
index a58d9f274e..3cedec3955 100644
--- a/lib/spack/spack/test/packaging.py
+++ b/lib/spack/spack/test/packaging.py
@@ -39,6 +39,7 @@ import spack.store
import spack.binary_distribution as bindist
import spack.cmd.buildcache as buildcache
from spack.spec import Spec
+from spack.paths import mock_gpg_keys_path
from spack.fetch_strategy import URLFetchStrategy, FetchStrategyComposite
from spack.util.executable import ProcessError
from spack.relocate import needs_binary_relocation, needs_text_relocation
@@ -201,7 +202,7 @@ echo $PATH"""
buildcache.buildcache(parser, args)
# Copy a key to the mirror to have something to download
- shutil.copyfile(spack.mock_gpg_keys_path + '/external.key',
+ shutil.copyfile(mock_gpg_keys_path + '/external.key',
mirror_path + '/external.key')
args = parser.parse_args(['keys'])
diff --git a/lib/spack/spack/test/patch.py b/lib/spack/spack/test/patch.py
index 1a03199ca0..e9c92235af 100644
--- a/lib/spack/spack/test/patch.py
+++ b/lib/spack/spack/test/patch.py
@@ -29,7 +29,7 @@ import pytest
from llnl.util.filesystem import working_dir, mkdirp
-import spack
+import spack.paths
import spack.util.compression
from spack.stage import Stage
from spack.spec import Spec
@@ -39,11 +39,11 @@ from spack.spec import Spec
def mock_stage(tmpdir, monkeypatch):
# don't disrupt the spack install directory with tests.
mock_path = str(tmpdir)
- monkeypatch.setattr(spack, 'stage_path', mock_path)
+ monkeypatch.setattr(spack.paths, 'stage_path', mock_path)
return mock_path
-data_path = os.path.join(spack.test_path, 'data', 'patch')
+data_path = os.path.join(spack.paths.test_path, 'data', 'patch')
@pytest.mark.parametrize('filename, sha256, archive_sha256', [
diff --git a/lib/spack/spack/test/python_version.py b/lib/spack/spack/test/python_version.py
index 36fc138ae2..312e6ce37a 100644
--- a/lib/spack/spack/test/python_version.py
+++ b/lib/spack/spack/test/python_version.py
@@ -40,7 +40,10 @@ import re
import pytest
import llnl.util.tty as tty
-import spack
+
+import spack.paths
+from spack.paths import lib_path as spack_lib_path
+
#
# This test uses pyqver, by Greg Hewgill, which is a dual-source module.
@@ -55,10 +58,10 @@ if sys.version_info[0] < 3:
exclude_paths = [
# Jinja 2 has some 'async def' functions that are not treated correctly
# by pyqver.py
- os.path.join(spack.lib_path, 'external', 'jinja2', 'asyncfilters.py'),
- os.path.join(spack.lib_path, 'external', 'jinja2', 'asyncsupport.py'),
- os.path.join(spack.lib_path, 'external', 'yaml', 'lib3'),
- os.path.join(spack.lib_path, 'external', 'pyqver3.py')]
+ os.path.join(spack_lib_path, 'external', 'jinja2', 'asyncfilters.py'),
+ os.path.join(spack_lib_path, 'external', 'jinja2', 'asyncsupport.py'),
+ os.path.join(spack_lib_path, 'external', 'yaml', 'lib3'),
+ os.path.join(spack_lib_path, 'external', 'pyqver3.py')]
else:
import pyqver3 as pyqver
@@ -68,10 +71,10 @@ else:
exclude_paths = [
# Jinja 2 has some 'async def' functions that are not treated correctly
# by pyqver.py
- os.path.join(spack.lib_path, 'external', 'jinja2', 'asyncfilters.py'),
- os.path.join(spack.lib_path, 'external', 'jinja2', 'asyncsupport.py'),
- os.path.join(spack.lib_path, 'external', 'yaml', 'lib'),
- os.path.join(spack.lib_path, 'external', 'pyqver2.py')]
+ os.path.join(spack_lib_path, 'external', 'jinja2', 'asyncfilters.py'),
+ os.path.join(spack_lib_path, 'external', 'jinja2', 'asyncsupport.py'),
+ os.path.join(spack_lib_path, 'external', 'yaml', 'lib'),
+ os.path.join(spack_lib_path, 'external', 'pyqver2.py')]
def pyfiles(search_paths, exclude=()):
@@ -85,7 +88,7 @@ def pyfiles(search_paths, exclude=()):
python files in the search path.
"""
# first file is the spack script.
- yield spack.spack_file
+ yield spack.paths.spack_script
# Iterate through the whole spack source tree.
for path in search_paths:
@@ -135,8 +138,8 @@ def check_python_versions(files):
messages = []
for path in sorted(all_issues[v].keys()):
short_path = path
- if path.startswith(spack.prefix):
- short_path = path[len(spack.prefix):]
+ if path.startswith(spack.paths.prefix):
+ short_path = path[len(spack.paths.prefix):]
reasons = [r for r in set(all_issues[v][path]) if r]
for lineno, cause in reasons:
@@ -159,10 +162,11 @@ def check_python_versions(files):
@pytest.mark.maybeslow
def test_core_module_compatibility():
"""Test that all core spack modules work with supported Python versions."""
- check_python_versions(pyfiles([spack.lib_path], exclude=exclude_paths))
+ check_python_versions(
+ pyfiles([spack_lib_path], exclude=exclude_paths))
@pytest.mark.maybeslow
def test_package_module_compatibility():
"""Test that all spack packages work with supported Python versions."""
- check_python_versions(pyfiles([spack.packages_path]))
+ check_python_versions(pyfiles([spack.paths.packages_path]))
diff --git a/lib/spack/spack/test/repo.py b/lib/spack/spack/test/repo.py
index 570bd0c469..27b5830d98 100644
--- a/lib/spack/spack/test/repo.py
+++ b/lib/spack/spack/test/repo.py
@@ -22,17 +22,18 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
-import spack
-
import pytest
+import spack.repository
+import spack.paths
+
# Unlike the repo_path fixture defined in conftest, this has a test-level
# scope rather than a session level scope, since we want to edit the
# given RepoPath
@pytest.fixture()
def repo_for_test():
- return spack.repository.RepoPath(spack.mock_packages_path)
+ return spack.repository.RepoPath(spack.paths.mock_packages_path)
@pytest.fixture()
diff --git a/lib/spack/spack/test/sbang.py b/lib/spack/spack/test/sbang.py
index ffa99428ed..71212afabd 100644
--- a/lib/spack/spack/test/sbang.py
+++ b/lib/spack/spack/test/sbang.py
@@ -34,7 +34,7 @@ import filecmp
from llnl.util.filesystem import mkdirp
-import spack
+import spack.paths
from spack.hooks.sbang import shebang_too_long, filter_shebangs_in_directory
from spack.util.executable import which
@@ -47,7 +47,7 @@ lua_line_patched = "--!/this/" + ('x' * 200) + "/is/lua\n"
node_line = "#!/this/" + ('x' * 200) + "/is/node\n"
node_in_text = ("line\n") * 100 + "lua\n" + ("line\n" * 100)
node_line_patched = "//!/this/" + ('x' * 200) + "/is/node\n"
-sbang_line = '#!/bin/bash %s/bin/sbang\n' % spack.spack_root
+sbang_line = '#!/bin/bash %s/bin/sbang\n' % spack.paths.prefix
last_line = "last!\n"
diff --git a/lib/spack/spack/test/stage.py b/lib/spack/spack/test/stage.py
index 1fb3aada77..966c97ab5f 100644
--- a/lib/spack/spack/test/stage.py
+++ b/lib/spack/spack/test/stage.py
@@ -23,13 +23,14 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
"""Test that the Stage class works correctly."""
-import collections
import os
+import collections
+
+import pytest
from llnl.util.filesystem import join_path, working_dir
-import pytest
-import spack
+import spack.paths
import spack.stage
import spack.util.executable
from spack.stage import Stage
@@ -101,18 +102,18 @@ def get_stage_path(stage, stage_name):
"""
if stage_name is not None:
# If it is a named stage, we know where the stage should be
- return join_path(spack.stage_path, stage_name)
+ return os.path.join(spack.paths.stage_path, stage_name)
else:
# If it's unnamed, ensure that we ran mkdtemp in the right spot.
assert stage.path is not None
- assert stage.path.startswith(spack.stage_path)
+ assert stage.path.startswith(spack.paths.stage_path)
return stage.path
@pytest.fixture()
def tmpdir_for_stage(mock_archive):
"""Uses a temporary directory for staging"""
- current = spack.stage_path
+ current = spack.paths.stage_path
spack.config.update_config(
'config',
{'build_stage': [str(mock_archive.test_tmp_dir)]},
diff --git a/lib/spack/spack/test/web.py b/lib/spack/spack/test/web.py
index 6d9b106ea1..82f9b9bbdc 100644
--- a/lib/spack/spack/test/web.py
+++ b/lib/spack/spack/test/web.py
@@ -25,12 +25,12 @@
"""Tests for web.py."""
import os
-import spack
+import spack.paths
from spack.util.web import spider, find_versions_of_archive
from spack.version import ver
-web_data_path = os.path.join(spack.test_path, 'data', 'web')
+web_data_path = os.path.join(spack.paths.test_path, 'data', 'web')
root = 'file://' + web_data_path + '/index.html'
root_tarball = 'file://' + web_data_path + '/foo-0.0.0.tar.gz'
diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py
index 35d43cec65..e80848b882 100644
--- a/lib/spack/spack/util/executable.py
+++ b/lib/spack/spack/util/executable.py
@@ -29,7 +29,7 @@ from six import string_types
import sys
import llnl.util.tty as tty
-import spack
+
import spack.error
__all__ = ['Executable', 'which', 'ProcessError']
diff --git a/lib/spack/spack/util/gpg.py b/lib/spack/spack/util/gpg.py
index 09e7ded412..62f9bd76ef 100644
--- a/lib/spack/spack/util/gpg.py
+++ b/lib/spack/spack/util/gpg.py
@@ -22,14 +22,13 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
-
import os
-import spack
+import spack.paths
from spack.util.executable import Executable
-GNUPGHOME = spack.gpg_path
+GNUPGHOME = spack.paths.gpg_path
class Gpg(object):
diff --git a/lib/spack/spack/util/naming.py b/lib/spack/spack/util/naming.py
index 1dd95fbcde..98d4081868 100644
--- a/lib/spack/spack/util/naming.py
+++ b/lib/spack/spack/util/naming.py
@@ -29,7 +29,7 @@ import itertools
import re
from six import StringIO
-import spack
+import spack.error
__all__ = [
'mod_to_class',
diff --git a/lib/spack/spack/util/path.py b/lib/spack/spack/util/path.py
index a030c1160b..91126e5d31 100644
--- a/lib/spack/spack/util/path.py
+++ b/lib/spack/spack/util/path.py
@@ -28,17 +28,19 @@ TODO: this is really part of spack.config. Consolidate it.
"""
import os
import re
-import spack
import getpass
import tempfile
+import spack.paths
+
+
__all__ = [
'substitute_config_variables',
'canonicalize_path']
# Substitutions to perform
replacements = {
- 'spack': spack.prefix,
+ 'spack': spack.paths.prefix,
'user': getpass.getuser(),
'tempdir': tempfile.gettempdir(),
}
diff --git a/var/spack/repos/builtin.mock/packages/url-list-test/package.py b/var/spack/repos/builtin.mock/packages/url-list-test/package.py
index 75377873b7..fff04d7a9e 100644
--- a/var/spack/repos/builtin.mock/packages/url-list-test/package.py
+++ b/var/spack/repos/builtin.mock/packages/url-list-test/package.py
@@ -25,14 +25,14 @@
from spack import *
import os
-import spack
+import spack.paths
class UrlListTest(Package):
"""Mock package with url_list."""
homepage = "http://www.url-list-example.com"
- web_data_path = os.path.join(spack.test_path, 'data', 'web')
+ web_data_path = os.path.join(spack.paths.test_path, 'data', 'web')
url = 'file://' + web_data_path + '/foo-0.0.0.tar.gz'
list_url = 'file://' + web_data_path + '/index.html'
list_depth = 3
diff --git a/var/spack/repos/builtin/packages/cbtf-krell/package.py b/var/spack/repos/builtin/packages/cbtf-krell/package.py
index 7e7facc93a..15ea33dd79 100644
--- a/var/spack/repos/builtin/packages/cbtf-krell/package.py
+++ b/var/spack/repos/builtin/packages/cbtf-krell/package.py
@@ -41,7 +41,6 @@
##########################################################################
from spack import *
-import spack
import spack.store
diff --git a/var/spack/repos/builtin/packages/gobject-introspection/package.py b/var/spack/repos/builtin/packages/gobject-introspection/package.py
index 350105af32..436949290c 100644
--- a/var/spack/repos/builtin/packages/gobject-introspection/package.py
+++ b/var/spack/repos/builtin/packages/gobject-introspection/package.py
@@ -23,7 +23,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
from spack import *
-from spack import spack_root
+from spack.paths import spack_root
class GobjectIntrospection(Package):
diff --git a/var/spack/repos/builtin/packages/openspeedshop/package.py b/var/spack/repos/builtin/packages/openspeedshop/package.py
index 7347280159..237784e42d 100644
--- a/var/spack/repos/builtin/packages/openspeedshop/package.py
+++ b/var/spack/repos/builtin/packages/openspeedshop/package.py
@@ -42,7 +42,6 @@
from spack import *
-import spack
import spack.store
import os
diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py
index 332b5121e7..1759c15d86 100644
--- a/var/spack/repos/builtin/packages/perl/package.py
+++ b/var/spack/repos/builtin/packages/perl/package.py
@@ -30,12 +30,14 @@
# Author: Justin Too <justin@doubleotoo.com>
# Date: September 6, 2015
#
-from spack import *
import os
from contextlib import contextmanager
-import spack
+
from llnl.util.lang import match_predicate
+import spack.store
+from spack import *
+
class Perl(Package): # Perl doesn't use Autotools, it should subclass Package
"""Perl 5 is a highly capable, feature-rich programming language with over
diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py
index 30774332fd..34e1e0ea6d 100644
--- a/var/spack/repos/builtin/packages/python/package.py
+++ b/var/spack/repos/builtin/packages/python/package.py
@@ -32,11 +32,11 @@ import llnl.util.tty as tty
from llnl.util.lang import match_predicate
from llnl.util.filesystem import force_remove
-import spack
-from spack import *
+import spack.store
+import spack.util.spack_json as sjson
from spack.util.environment import is_system_path
from spack.util.prefix import Prefix
-import spack.util.spack_json as sjson
+from spack import *
class Python(AutotoolsPackage):