use os.path.join instead of join_path in core

- Spack core has long used llnl.util.filesystem.join_path, but
  os.path.join is pretty much the same thing, and is more efficient.

- Use os.path.join in the core Spack code from now on.
This commit is contained in:
Todd Gamblin 2018-05-17 11:19:48 -07:00 committed by scheibelp
parent f202198777
commit e9a3e3bfbb
34 changed files with 143 additions and 158 deletions

View File

@ -80,7 +80,6 @@
import platform as py_platform
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.paths
@ -271,7 +270,7 @@ def find_compilers(self, *paths):
filtered_path.append(p)
# Check for a bin directory, add it if it exists
bin = join_path(p, 'bin')
bin = os.path.join(p, 'bin')
if os.path.isdir(bin):
filtered_path.append(os.path.realpath(bin))

View File

@ -35,7 +35,7 @@
import yaml
import llnl.util.tty as tty
from llnl.util.filesystem import mkdirp, join_path, install_tree
from llnl.util.filesystem import mkdirp, install_tree
import spack
import spack.cmd
@ -264,9 +264,9 @@ def build_tarball(spec, outdir, force=False, rel=False, unsigned=False,
"""
# set up some paths
tarfile_name = tarball_name(spec, '.tar.gz')
tarfile_dir = join_path(outdir, "build_cache",
tarball_directory_name(spec))
tarfile_path = join_path(tarfile_dir, tarfile_name)
tarfile_dir = os.path.join(outdir, "build_cache",
tarball_directory_name(spec))
tarfile_path = os.path.join(tarfile_dir, tarfile_name)
mkdirp(tarfile_dir)
spackfile_path = os.path.join(
outdir, "build_cache", tarball_path_name(spec, '.spack'))
@ -278,18 +278,18 @@ def build_tarball(spec, outdir, force=False, rel=False, unsigned=False,
# need to copy the spec file so the build cache can be downloaded
# without concretizing with the current spack packages
# and preferences
spec_file = join_path(spec.prefix, ".spack", "spec.yaml")
spec_file = os.path.join(spec.prefix, ".spack", "spec.yaml")
specfile_name = tarball_name(spec, '.spec.yaml')
specfile_path = os.path.realpath(
join_path(outdir, "build_cache", specfile_name))
indexfile_path = join_path(outdir, "build_cache", "index.html")
os.path.join(outdir, "build_cache", specfile_name))
indexfile_path = os.path.join(outdir, "build_cache", "index.html")
if os.path.exists(specfile_path):
if force:
os.remove(specfile_path)
else:
raise NoOverwriteException(str(specfile_path))
# make a copy of the install directory to work with
workdir = join_path(tempfile.mkdtemp(), os.path.basename(spec.prefix))
workdir = os.path.join(tempfile.mkdtemp(), os.path.basename(spec.prefix))
install_tree(spec.prefix, workdir, symlinks=True)
# create info for later relocation and create tar
@ -512,7 +512,7 @@ def extract_tarball(spec, filename, allow_root=False, unsigned=False,
# the base of the install prefix is used when creating the tarball
# so the pathname should be the same now that the directory layout
# is confirmed
workdir = join_path(tmpdir, os.path.basename(spec.prefix))
workdir = os.path.join(tmpdir, os.path.basename(spec.prefix))
# cleanup
os.remove(tarfile_path)

View File

@ -32,7 +32,7 @@
from subprocess import check_call
import llnl.util.tty as tty
from llnl.util.filesystem import working_dir, join_path, force_remove
from llnl.util.filesystem import working_dir, force_remove
from spack.package import PackageBase, run_after, run_before
from spack.util.executable import Executable
@ -177,7 +177,7 @@ def configure_directory(self):
@property
def configure_abs_path(self):
# Absolute path to configure
configure_abs_path = join_path(
configure_abs_path = os.path.join(
os.path.abspath(self.configure_directory), 'configure'
)
return configure_abs_path
@ -220,7 +220,7 @@ def autoreconf(self, spec, prefix):
if 'pkgconfig' in spec:
autoreconf_args += [
'-I',
join_path(spec['pkgconfig'].prefix, 'share', 'aclocal'),
os.path.join(spec['pkgconfig'].prefix, 'share', 'aclocal'),
]
autoreconf_args += self.autoreconf_extra_args
m.autoreconf(*autoreconf_args)

View File

@ -28,7 +28,7 @@
import platform
import spack.build_environment
from llnl.util.filesystem import working_dir, join_path
from llnl.util.filesystem import working_dir
from spack.util.environment import filter_system_paths
from spack.directives import depends_on, variant
from spack.package import PackageBase, InstallError, run_after
@ -208,7 +208,7 @@ def build_directory(self):
:return: directory where to build the package
"""
return join_path(self.stage.source_path, 'spack-build')
return os.path.join(self.stage.source_path, 'spack-build')
def cmake_args(self):
"""Produces a list containing all the arguments that must be passed to

View File

@ -26,7 +26,7 @@
import os
import xml.etree.ElementTree as ET
from llnl.util.filesystem import install, join_path
from llnl.util.filesystem import install
from spack.package import PackageBase, run_after
from spack.util.executable import Executable
@ -109,8 +109,8 @@ def global_license_file(self):
All Intel software shares the same license, so we store it in a
common 'intel' directory."""
return join_path(self.global_license_dir, 'intel',
os.path.basename(self.license_files[0]))
return os.path.join(self.global_license_dir, 'intel',
os.path.basename(self.license_files[0]))
def configure(self, spec, prefix):
"""Writes the ``silent.cfg`` file used to configure the installation.
@ -186,7 +186,7 @@ def install(self, spec, prefix):
@run_after('install')
def save_silent_cfg(self):
"""Copies the silent.cfg configuration file to ``<prefix>/.spack``."""
install('silent.cfg', join_path(self.prefix, '.spack'))
install('silent.cfg', os.path.join(self.prefix, '.spack'))
# Check that self.prefix is there after installation
run_after('install')(PackageBase.sanity_check_prefix)

View File

@ -26,7 +26,6 @@
import inspect
import os
from llnl.util.filesystem import join_path
from spack.directives import depends_on, extends
from spack.package import PackageBase, run_after
from spack.util.executable import Executable
@ -88,7 +87,7 @@ def configure(self, spec, prefix):
elif os.path.isfile('Build.PL'):
self.build_method = 'Build.PL'
self.build_executable = Executable(
join_path(self.stage.source_path, 'Build'))
os.path.join(self.stage.source_path, 'Build'))
else:
raise RuntimeError('Unknown build_method for perl package')

View File

@ -135,9 +135,9 @@ 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.paths.var_path, 'junit-report')
dirname = fs.os.path.join(spack.paths.var_path, 'junit-report')
fs.mkdirp(dirname)
return fs.join_path(dirname, basename)
return fs.os.path.join(dirname, basename)
def install_spec(cli_args, kwargs, spec):

View File

@ -27,7 +27,6 @@
import itertools
import llnl.util.tty as tty
from llnl.util.filesystem import join_path
import spack.error
import spack.spec
@ -270,7 +269,7 @@ def _find_matches_in_path(cls, compiler_names, detect_version, *path):
files = os.listdir(directory)
for exe in files:
full_path = join_path(directory, exe)
full_path = os.path.join(directory, exe)
prod = itertools.product(prefixes, compiler_names, suffixes)
for pre, name, suf in prod:

View File

@ -51,7 +51,7 @@
from yaml.error import MarkedYAMLError, YAMLError
import llnl.util.tty as tty
from llnl.util.filesystem import join_path, mkdirp
from llnl.util.filesystem import mkdirp
from llnl.util.lock import Lock, WriteTransaction, ReadTransaction
import spack.store
@ -184,18 +184,18 @@ def __init__(self, root, db_dir=None):
if db_dir is None:
# If the db_dir is not provided, default to within the db root.
self._db_dir = join_path(self.root, _db_dirname)
self._db_dir = os.path.join(self.root, _db_dirname)
else:
# Allow customizing the database directory location for testing.
self._db_dir = db_dir
# Set up layout of database files within the db dir
self._old_yaml_index_path = join_path(self._db_dir, 'index.yaml')
self._index_path = join_path(self._db_dir, 'index.json')
self._lock_path = join_path(self._db_dir, 'lock')
self._old_yaml_index_path = os.path.join(self._db_dir, 'index.yaml')
self._index_path = os.path.join(self._db_dir, 'index.json')
self._lock_path = os.path.join(self._db_dir, 'lock')
# This is for other classes to use to lock prefix directories.
self.prefix_lock_path = join_path(self._db_dir, 'prefix_lock')
self.prefix_lock_path = os.path.join(self._db_dir, 'prefix_lock')
# Create needed directories and files
if not os.path.exists(self._db_dir):

View File

@ -54,7 +54,6 @@ class OpenMpi(Package):
from six import string_types
import llnl.util.lang
from llnl.util.filesystem import join_path
import spack
import spack.error
@ -530,7 +529,7 @@ def _execute_resource(pkg):
# Check if the path falls within the main package stage area
test_path = 'stage_folder_root'
normalized_destination = os.path.normpath(
join_path(test_path, destination)
os.path.join(test_path, destination)
) # Normalized absolute path
if test_path not in normalized_destination:

View File

@ -29,7 +29,7 @@
import yaml
import re
from llnl.util.filesystem import join_path, mkdirp
from llnl.util.filesystem import mkdirp
import spack.config
import spack.spec
@ -239,22 +239,22 @@ def read_spec(self, path):
def spec_file_path(self, spec):
"""Gets full path to spec file"""
_check_concrete(spec)
return join_path(self.metadata_path(spec), self.spec_file_name)
return os.path.join(self.metadata_path(spec), self.spec_file_name)
def metadata_path(self, spec):
return join_path(self.path_for_spec(spec), self.metadata_dir)
return os.path.join(self.path_for_spec(spec), self.metadata_dir)
def build_log_path(self, spec):
return join_path(self.path_for_spec(spec), self.metadata_dir,
self.build_log_name)
return os.path.join(self.path_for_spec(spec), self.metadata_dir,
self.build_log_name)
def build_env_path(self, spec):
return join_path(self.path_for_spec(spec), self.metadata_dir,
self.build_env_name)
return os.path.join(self.path_for_spec(spec), self.metadata_dir,
self.build_env_name)
def build_packages_path(self, spec):
return join_path(self.path_for_spec(spec), self.metadata_dir,
self.packages_dir)
return os.path.join(self.path_for_spec(spec), self.metadata_dir,
self.packages_dir)
def create_install_directory(self, spec):
_check_concrete(spec)
@ -302,7 +302,7 @@ def all_specs(self):
path_elems = ["*"] * len(self.path_scheme.split(os.sep))
path_elems += [self.metadata_dir, self.spec_file_name]
pattern = join_path(self.root, *path_elems)
pattern = os.path.join(self.root, *path_elems)
spec_files = glob.glob(pattern)
return [self.read_spec(s) for s in spec_files]
@ -356,8 +356,8 @@ def check_activated(self, spec, ext_spec):
def extension_file_path(self, spec):
"""Gets full path to an installed package's extension file"""
_check_concrete(spec)
return join_path(self.layout.metadata_path(spec),
self.extension_file_name)
return os.path.join(self.layout.metadata_path(spec),
self.extension_file_name)
def extension_map(self, spec):
"""Defensive copying version of _extension_map() for external API."""
@ -446,8 +446,8 @@ class YamlViewExtensionsLayout(YamlExtensionsLayout):
def extension_file_path(self, spec):
"""Gets the full path to an installed package's extension file."""
_check_concrete(spec)
return join_path(self.root, self.layout.metadata_dir, spec.name,
self.extension_file_name)
return os.path.join(self.root, self.layout.metadata_dir, spec.name,
self.extension_file_name)
def extendee_target_directory(self, extendee):
return self.root

View File

@ -49,7 +49,7 @@
from six import string_types, with_metaclass
import llnl.util.tty as tty
from llnl.util.filesystem import working_dir, mkdirp, join_path
from llnl.util.filesystem import working_dir, mkdirp
import spack.config
import spack.error
@ -1035,12 +1035,12 @@ def store(self, fetcher, relativeDst):
if isinstance(fetcher, CacheURLFetchStrategy):
return
dst = join_path(self.root, relativeDst)
dst = os.path.join(self.root, relativeDst)
mkdirp(os.path.dirname(dst))
fetcher.archive(dst)
def fetcher(self, targetPath, digest, **kwargs):
path = join_path(self.root, targetPath)
path = os.path.join(self.root, targetPath)
return CacheURLFetchStrategy(path, digest, **kwargs)
def destroy(self):

View File

@ -28,7 +28,6 @@
import shutil
import sys
from llnl.util.filesystem import join_path
from llnl.util.link_tree import LinkTree
from llnl.util import tty
@ -390,8 +389,8 @@ def remove_standalone(self, spec):
tty.info(self._croot + 'Removed package: %s' % colorize_spec(spec))
def get_all_specs(self):
dotspack = join_path(self.root,
spack.store.layout.metadata_dir)
dotspack = os.path.join(self.root,
spack.store.layout.metadata_dir)
if os.path.exists(dotspack):
return list(filter(None, map(self.get_spec, os.listdir(dotspack))))
else:
@ -408,14 +407,14 @@ def get_conflicts(self, *specs):
def get_path_meta_folder(self, spec):
"Get path to meta folder for either spec or spec name."
return join_path(self.root,
spack.store.layout.metadata_dir,
getattr(spec, "name", spec))
return os.path.join(self.root,
spack.store.layout.metadata_dir,
getattr(spec, "name", spec))
def get_spec(self, spec):
dotspack = self.get_path_meta_folder(spec)
filename = join_path(dotspack,
spack.store.layout.spec_file_name)
filename = os.path.join(dotspack,
spack.store.layout.spec_file_name)
try:
with open(filename, "r") as f:

View File

@ -42,9 +42,9 @@
features.
"""
import imp
import os.path
import spack.paths
from llnl.util.filesystem import join_path
from llnl.util.lang import memoized, list_modules
@ -53,7 +53,7 @@ def all_hook_modules():
modules = []
for name in list_modules(spack.paths.hooks_path):
mod_name = __name__ + '.' + name
path = join_path(spack.paths.hooks_path, name) + ".py"
path = os.path.join(spack.paths.hooks_path, name) + ".py"
mod = imp.load_source(mod_name, path)
modules.append(mod)

View File

@ -26,7 +26,7 @@
import spack
import llnl.util.tty as tty
from llnl.util.filesystem import join_path, mkdirp
from llnl.util.filesystem import mkdirp
def pre_install(spec):
@ -156,7 +156,7 @@ def symlink_license(pkg):
"""Create local symlinks that point to the global license file."""
target = pkg.global_license_file
for filename in pkg.license_files:
link_name = join_path(pkg.prefix, filename)
link_name = os.path.join(pkg.prefix, filename)
link_name = os.path.abspath(link_name)
license_dir = os.path.dirname(link_name)
if not os.path.exists(license_dir):

View File

@ -33,7 +33,7 @@
import sys
import os
import llnl.util.tty as tty
from llnl.util.filesystem import mkdirp, join_path
from llnl.util.filesystem import mkdirp
import spack.config
import spack.error
@ -97,7 +97,7 @@ def mirror_archive_filename(spec, fetcher, resourceId=None):
def mirror_archive_path(spec, fetcher, resourceId=None):
"""Get the relative path to the spec's archive within a mirror."""
return join_path(
return os.path.join(
spec.name, mirror_archive_filename(spec, fetcher, resourceId))
@ -222,12 +222,12 @@ def add_single_spec(spec, mirror_root, categories, **kwargs):
fetcher = stage.fetcher
if ii == 0:
# create a subdirectory for the current package@version
archive_path = os.path.abspath(join_path(
archive_path = os.path.abspath(os.path.join(
mirror_root, mirror_archive_path(spec, fetcher)))
name = spec.cformat("$_$@")
else:
resource = stage.resource
archive_path = os.path.abspath(join_path(
archive_path = os.path.abspath(os.path.join(
mirror_root,
mirror_archive_path(spec, fetcher, resource.name)))
name = "{resource} ({pkg}).".format(

View File

@ -69,7 +69,7 @@
import spack.multimethod
import spack.binary_distribution as binary_distribution
from llnl.util.filesystem import mkdirp, join_path, touch
from llnl.util.filesystem import mkdirp, touch
from llnl.util.filesystem import working_dir, install_tree, install
from llnl.util.lang import memoized
from llnl.util.link_tree import LinkTree
@ -1226,17 +1226,17 @@ def do_fake_install(self):
# Install fake command
mkdirp(self.prefix.bin)
touch(join_path(self.prefix.bin, command))
chmod('+x', join_path(self.prefix.bin, command))
touch(os.path.join(self.prefix.bin, command))
chmod('+x', os.path.join(self.prefix.bin, command))
# Install fake header file
mkdirp(self.prefix.include)
touch(join_path(self.prefix.include, header + '.h'))
touch(os.path.join(self.prefix.include, header + '.h'))
# Install fake shared and static libraries
mkdirp(self.prefix.lib)
for suffix in [dso_suffix, '.a']:
touch(join_path(self.prefix.lib, library + suffix))
touch(os.path.join(self.prefix.lib, library + suffix))
# Install fake man page
mkdirp(self.prefix.man.man1)
@ -1516,7 +1516,7 @@ def build_process():
else:
source_path = self.stage.source_path
if install_source and os.path.isdir(source_path):
src_target = join_path(
src_target = os.path.join(
self.spec.prefix, 'share', self.name, 'src')
tty.msg('Copying source to {0}'.format(src_target))
install_tree(self.stage.source_path, src_target)
@ -1762,7 +1762,7 @@ def build_log_path(self):
if self.installed:
return spack.store.layout.build_log_path(self.spec)
else:
return join_path(self.stage.source_path, 'spack-build.out')
return os.path.join(self.stage.source_path, 'spack-build.out')
@property
def module(self):
@ -2305,7 +2305,7 @@ def dump_packages(spec, path):
# Locate the dependency package in the install tree and find
# its provenance information.
source = spack.store.layout.build_packages_path(node)
source_repo_root = join_path(source, node.namespace)
source_repo_root = os.path.join(source, node.namespace)
# There's no provenance installed for the source package. Skip it.
# User can always get something current from the builtin repo.
@ -2322,7 +2322,7 @@ def dump_packages(spec, path):
node.name)
# Create a destination repository
dest_repo_root = join_path(path, node.namespace)
dest_repo_root = os.path.join(path, node.namespace)
if not os.path.exists(dest_repo_root):
spack.repo.create_repo(dest_repo_root)
repo = spack.repo.Repo(dest_repo_root)

View File

@ -30,7 +30,6 @@
from spack.architecture import Platform, Target, NoPlatformError
from spack.operating_systems.cray_frontend import CrayFrontend
from spack.operating_systems.cnl import Cnl
from llnl.util.filesystem import join_path
from spack.util.module_cmd import get_module_cmd, unload_module
@ -110,7 +109,7 @@ def setup_platform_environment(cls, pkg, env):
unload_module(module)
env.set('CRAYPE_LINK_TYPE', 'dynamic')
cray_wrapper_names = join_path(build_env_path, 'cray')
cray_wrapper_names = os.path.join(build_env_path, 'cray')
if os.path.isdir(cray_wrapper_names):
env.prepend_path('PATH', cray_wrapper_names)

View File

@ -47,7 +47,7 @@
import llnl.util.lang
import llnl.util.tty as tty
from llnl.util.filesystem import mkdirp, join_path, install
from llnl.util.filesystem import mkdirp, install
import spack
import spack.config
@ -142,7 +142,7 @@ def _create_new_cache(self):
cache = {}
for pkg_name in os.listdir(self.packages_path):
# Skip non-directories in the package root.
pkg_dir = join_path(self.packages_path, pkg_name)
pkg_dir = os.path.join(self.packages_path, pkg_name)
# Warn about invalid names that look like packages.
if not valid_module_name(pkg_name):
@ -635,18 +635,18 @@ def check(condition, msg):
raise BadRepoError(msg)
# Validate repository layout.
self.config_file = join_path(self.root, repo_config_name)
self.config_file = os.path.join(self.root, repo_config_name)
check(os.path.isfile(self.config_file),
"No %s found in '%s'" % (repo_config_name, root))
self.packages_path = join_path(self.root, packages_dir_name)
self.packages_path = os.path.join(self.root, packages_dir_name)
check(os.path.isdir(self.packages_path),
"No directory '%s' found in '%s'" % (repo_config_name, root))
# Read configuration and validate namespace
config = self._read_config()
check('namespace' in config, '%s must define a namespace.'
% join_path(root, repo_config_name))
% os.path.join(root, repo_config_name))
self.namespace = config['namespace']
check(re.match(r'[a-zA-Z][a-zA-Z0-9_.]+', self.namespace),
@ -899,7 +899,7 @@ def dirname_for_package_name(self, spec):
"""Get the directory name for a particular package. This is the
directory that contains its package.py file."""
self._check_namespace(spec)
return join_path(self.packages_path, spec.name)
return os.path.join(self.packages_path, spec.name)
@_autospec
def filename_for_package_name(self, spec):
@ -913,7 +913,7 @@ def filename_for_package_name(self, spec):
"""
self._check_namespace(spec)
pkg_dir = self.dirname_for_package_name(spec.name)
return join_path(pkg_dir, package_file_name)
return os.path.join(pkg_dir, package_file_name)
@property
def _pkg_checker(self):

View File

@ -35,7 +35,7 @@
import llnl.util.tty as tty
import llnl.util.lock
from llnl.util.filesystem import mkdirp, join_path, can_access
from llnl.util.filesystem import mkdirp, can_access
from llnl.util.filesystem import remove_if_dead_link, remove_linked_tree
import spack.paths
@ -216,7 +216,7 @@ def __init__(
if path is not None:
self.path = path
else:
self.path = join_path(spack.paths.stage_path, self.name)
self.path = os.path.join(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 @@ def __init__(
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.paths.stage_path, '.lock')
stage_lock_path = os.path.join(spack.paths.stage_path, '.lock')
Stage.stage_locks[self.name] = llnl.util.lock.Lock(
stage_lock_path, lock_id, 1)
@ -546,7 +546,7 @@ def _add_to_root_stage(self):
if not isinstance(placement, dict):
placement = {'': placement}
target_path = join_path(
target_path = os.path.join(
root_stage.source_path, resource.destination)
try:
@ -558,8 +558,8 @@ def _add_to_root_stage(self):
raise
for key, value in iteritems(placement):
destination_path = join_path(target_path, value)
source_path = join_path(self.source_path, key)
destination_path = os.path.join(target_path, value)
source_path = os.path.join(self.source_path, key)
if not os.path.exists(destination_path):
tty.info('Moving resource stage\n\tsource : '
@ -665,7 +665,7 @@ def purge():
"""Remove all build directories in the top-level stage path."""
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)
stage_path = os.path.join(spack.paths.stage_path, stage_dir)
remove_linked_tree(stage_path)

View File

@ -26,16 +26,15 @@
import pytest
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
@pytest.fixture
def build_environment():
cc = Executable(join_path(build_env_path, "cc"))
cxx = Executable(join_path(build_env_path, "c++"))
fc = Executable(join_path(build_env_path, "fc"))
cc = Executable(os.path.join(build_env_path, "cc"))
cxx = Executable(os.path.join(build_env_path, "c++"))
fc = Executable(os.path.join(build_env_path, "fc"))
realcc = "/bin/mycc"
prefix = "/spack-test-prefix"

View File

@ -32,7 +32,7 @@
import shutil
from spack.paths import build_env_path
from llnl.util.filesystem import mkdirp, join_path
from llnl.util.filesystem import mkdirp
from spack.util.executable import Executable
# Complicated compiler test command
@ -54,11 +54,11 @@
class CompilerWrapperTest(unittest.TestCase):
def setUp(self):
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.cc = Executable(os.path.join(build_env_path, "cc"))
self.ld = Executable(os.path.join(build_env_path, "ld"))
self.cpp = Executable(os.path.join(build_env_path, "cpp"))
self.cxx = Executable(os.path.join(build_env_path, "c++"))
self.fc = Executable(os.path.join(build_env_path, "fc"))
self.realcc = "/bin/mycc"
self.prefix = "/spack-test-prefix"
@ -82,20 +82,20 @@ def setUp(self):
# Make some fake dependencies
self.tmp_deps = tempfile.mkdtemp()
self.dep1 = join_path(self.tmp_deps, 'dep1')
self.dep2 = join_path(self.tmp_deps, 'dep2')
self.dep3 = join_path(self.tmp_deps, 'dep3')
self.dep4 = join_path(self.tmp_deps, 'dep4')
self.dep1 = os.path.join(self.tmp_deps, 'dep1')
self.dep2 = os.path.join(self.tmp_deps, 'dep2')
self.dep3 = os.path.join(self.tmp_deps, 'dep3')
self.dep4 = os.path.join(self.tmp_deps, 'dep4')
mkdirp(join_path(self.dep1, 'include'))
mkdirp(join_path(self.dep1, 'lib'))
mkdirp(os.path.join(self.dep1, 'include'))
mkdirp(os.path.join(self.dep1, 'lib'))
mkdirp(join_path(self.dep2, 'lib64'))
mkdirp(os.path.join(self.dep2, 'lib64'))
mkdirp(join_path(self.dep3, 'include'))
mkdirp(join_path(self.dep3, 'lib64'))
mkdirp(os.path.join(self.dep3, 'include'))
mkdirp(os.path.join(self.dep3, 'lib64'))
mkdirp(join_path(self.dep4, 'include'))
mkdirp(os.path.join(self.dep4, 'include'))
if 'SPACK_DEPENDENCIES' in os.environ:
del os.environ['SPACK_DEPENDENCIES']

View File

@ -318,7 +318,7 @@ def test_junit_output_with_failures(tmpdir, exc_typename, msg):
@pytest.mark.disable_clean_stage_check
@pytest.mark.parametrize('exc_typename,msg', [
# ('RuntimeError', 'something weird happened'),
('RuntimeError', 'something weird happened'),
('KeyboardInterrupt', 'Ctrl-C strikes again')
])
def test_junit_output_with_errors(

View File

@ -28,8 +28,6 @@
import os
import pytest
from llnl.util.filesystem import join_path
import spack.paths
import spack.repo
from spack.directory_layout import YamlDirectoryLayout
@ -213,7 +211,7 @@ def test_handle_unknown_package(
# enough to read a spec from the spec file.
for spec, path in installed_specs.items():
spec_from_file = layout.read_spec(
join_path(path, '.spack', 'spec.yaml'))
os.path.join(path, '.spack', 'spec.yaml'))
# To satisfy these conditions, directory layouts need to
# read in concrete specs from their install dirs somehow.

View File

@ -26,7 +26,7 @@
import pytest
from llnl.util.filesystem import working_dir, join_path, touch
from llnl.util.filesystem import working_dir, touch
import spack.repo
import spack.config
@ -103,7 +103,7 @@ def test_fetch(type_of_test,
with working_dir(pkg.stage.source_path):
assert h('HEAD') == h(t.revision)
file_path = join_path(pkg.stage.source_path, t.file)
file_path = os.path.join(pkg.stage.source_path, t.file)
assert os.path.isdir(pkg.stage.source_path)
assert os.path.isfile(file_path)

View File

@ -26,7 +26,7 @@
import pytest
from llnl.util.filesystem import working_dir, join_path, touch
from llnl.util.filesystem import working_dir, touch
import spack.repo
import spack.config
@ -75,7 +75,7 @@ def test_fetch(
with working_dir(pkg.stage.source_path):
assert h() == t.revision
file_path = join_path(pkg.stage.source_path, t.file)
file_path = os.path.join(pkg.stage.source_path, t.file)
assert os.path.isdir(pkg.stage.source_path)
assert os.path.isfile(file_path)

View File

@ -72,7 +72,7 @@
import pytest
from llnl.util.filesystem import join_path, touch
from llnl.util.filesystem import touch
from spack.util.multiproc import Barrier
from llnl.util.lock import Lock, WriteTransaction, ReadTransaction, LockError
@ -180,7 +180,7 @@ def private_lock_path(lock_dir):
For other modes, it is the same as a shared lock.
"""
lock_file = join_path(lock_dir, 'lockfile')
lock_file = os.path.join(lock_dir, 'lockfile')
if mpi:
lock_file += '.%s' % comm.rank
yield lock_file
@ -189,7 +189,7 @@ def private_lock_path(lock_dir):
@pytest.fixture
def lock_path(lock_dir):
"""This lock is shared among all processes in a multiproc test."""
lock_file = join_path(lock_dir, 'lockfile')
lock_file = os.path.join(lock_dir, 'lockfile')
yield lock_file

View File

@ -32,7 +32,6 @@
import tempfile
import unittest
from llnl.util.filesystem import join_path
from spack.build_environment import MakeExecutable
from spack.util.environment import path_put_first
@ -42,7 +41,7 @@ class MakeExecutableTest(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp()
make_exe = join_path(self.tmpdir, 'make')
make_exe = os.path.join(self.tmpdir, 'make')
with open(make_exe, 'w') as f:
f.write('#!/bin/sh\n')
f.write('echo "$@"')

View File

@ -26,8 +26,6 @@
import os
import pytest
from llnl.util.filesystem import join_path
import spack.repo
import spack.mirror
import spack.util.executable
@ -66,7 +64,7 @@ def set_up_package(name, repository, url_attr):
def check_mirror():
with Stage('spack-mirror-test') as stage:
mirror_root = join_path(stage.path, 'test-mirror')
mirror_root = os.path.join(stage.path, 'test-mirror')
# register mirror with spack config
mirrors = {'spack-mirror-test': 'file://' + mirror_root}
spack.config.set('mirrors', mirrors)
@ -77,7 +75,7 @@ def check_mirror():
# check that there are subdirs for each package
for name in repos:
subdir = join_path(mirror_root, name)
subdir = os.path.join(mirror_root, name)
assert os.path.isdir(subdir)
files = os.listdir(subdir)
@ -96,7 +94,7 @@ def check_mirror():
original_path = mock_repo.path
if 'svn' in name:
# have to check out the svn repo to compare.
original_path = join_path(
original_path = os.path.join(
mock_repo.path, 'checked_out')
svn = which('svn', required=True)

View File

@ -22,10 +22,9 @@
# 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 pytest
from llnl.util.filesystem import join_path
import spack.repo
from spack.paths import mock_packages_path
from spack.util.naming import mod_to_class
@ -45,7 +44,7 @@ def test_package_name(self):
def test_package_filename(self):
repo = spack.repo.Repo(mock_packages_path)
filename = repo.filename_for_package_name('mpich')
assert filename == join_path(
assert filename == os.path.join(
mock_packages_path,
'packages',
'mpich',
@ -55,7 +54,7 @@ def test_package_filename(self):
def test_nonexisting_package_filename(self):
repo = spack.repo.Repo(mock_packages_path)
filename = repo.filename_for_package_name('some-nonexisting-package')
assert filename == join_path(
assert filename == os.path.join(
mock_packages_path,
'packages',
'some-nonexisting-package',

View File

@ -28,7 +28,7 @@
import pytest
from llnl.util.filesystem import join_path, working_dir
from llnl.util.filesystem import working_dir
import spack.paths
import spack.stage
@ -43,9 +43,9 @@ def check_expand_archive(stage, stage_name, mock_archive):
assert archive_name in os.listdir(stage_path)
assert archive_dir in os.listdir(stage_path)
assert join_path(stage_path, archive_dir) == stage.source_path
assert os.path.join(stage_path, archive_dir) == stage.source_path
readme = join_path(stage_path, archive_dir, 'README.txt')
readme = os.path.join(stage_path, archive_dir, 'README.txt')
assert os.path.isfile(readme)
with open(readme) as file:
'hello world!\n' == file.read()
@ -55,7 +55,7 @@ def check_fetch(stage, stage_name):
archive_name = 'test-files.tar.gz'
stage_path = get_stage_path(stage, stage_name)
assert archive_name in os.listdir(stage_path)
assert join_path(stage_path, archive_name) == stage.fetcher.archive_file
assert os.path.join(stage_path, archive_name) == stage.fetcher.archive_file
def check_destroy(stage, stage_name):

View File

@ -26,7 +26,7 @@
import pytest
from llnl.util.filesystem import join_path, touch, working_dir
from llnl.util.filesystem import touch, working_dir
import spack.repo
import spack.config
@ -75,7 +75,7 @@ def test_fetch(
with working_dir(pkg.stage.source_path):
assert h() == t.revision
file_path = join_path(pkg.stage.source_path, t.file)
file_path = os.path.join(pkg.stage.source_path, t.file)
assert os.path.isdir(pkg.stage.source_path)
assert os.path.isfile(file_path)

View File

@ -22,15 +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 spack
from llnl.util.filesystem import join_path
from spack.directory_layout import YamlDirectoryLayout
from spack.filesystem_view import YamlFilesystemView
import os
import pytest
import spack
from spack.directory_layout import YamlDirectoryLayout
from spack.filesystem_view import YamlFilesystemView
class FakeExtensionPackage(object):
def __init__(self, name, prefix):
@ -97,7 +95,7 @@ def python_and_extension_dirs(tmpdir):
create_dir_structure(ext_prefix, ext_dirs)
easy_install_location = 'lib/python2.7/site-packages/easy-install.pth'
with open(join_path(ext_prefix, easy_install_location), 'w') as F:
with open(str(ext_prefix.join(easy_install_location)), 'w') as F:
F.write("""path/to/ext1.egg
path/to/setuptools.egg""")
@ -137,10 +135,10 @@ def test_python_activation_with_files(tmpdir, python_and_extension_dirs):
python_pkg = python_spec.package
python_pkg.activate(ext_pkg)
assert os.path.exists(join_path(python_prefix, 'bin/py-ext-tool'))
assert os.path.exists(os.path.join(python_prefix, 'bin/py-ext-tool'))
easy_install_location = 'lib/python2.7/site-packages/easy-install.pth'
with open(join_path(python_prefix, easy_install_location), 'r') as F:
with open(os.path.join(python_prefix, easy_install_location), 'r') as F:
easy_install_contents = F.read()
assert 'ext1.egg' in easy_install_contents
@ -163,9 +161,9 @@ def test_python_activation_view(tmpdir, python_and_extension_dirs):
python_pkg = python_spec.package
python_pkg.activate(ext_pkg, extensions_layout=view.extensions_layout)
assert not os.path.exists(join_path(python_prefix, 'bin/py-ext-tool'))
assert not os.path.exists(os.path.join(python_prefix, 'bin/py-ext-tool'))
assert os.path.exists(join_path(view_dir, 'bin/py-ext-tool'))
assert os.path.exists(os.path.join(view_dir, 'bin/py-ext-tool'))
@pytest.fixture()
@ -247,7 +245,7 @@ def test_perl_activation_with_files(tmpdir, perl_and_extension_dirs):
perl_pkg = perl_spec.package
perl_pkg.activate(ext_pkg)
assert os.path.exists(join_path(perl_prefix, 'bin/perl-ext-tool'))
assert os.path.exists(os.path.join(perl_prefix, 'bin/perl-ext-tool'))
def test_perl_activation_view(tmpdir, perl_and_extension_dirs):
@ -266,6 +264,6 @@ def test_perl_activation_view(tmpdir, perl_and_extension_dirs):
perl_pkg = perl_spec.package
perl_pkg.activate(ext_pkg, extensions_layout=view.extensions_layout)
assert not os.path.exists(join_path(perl_prefix, 'bin/perl-ext-tool'))
assert not os.path.exists(os.path.join(perl_prefix, 'bin/perl-ext-tool'))
assert os.path.exists(join_path(view_dir, 'bin/perl-ext-tool'))
assert os.path.exists(os.path.join(view_dir, 'bin/perl-ext-tool'))

View File

@ -25,7 +25,7 @@
import os
import shutil
from llnl.util.filesystem import mkdirp, join_path
from llnl.util.filesystem import mkdirp
from llnl.util.lock import Lock, ReadTransaction, WriteTransaction
from spack.error import SpackError
@ -57,7 +57,7 @@ def __init__(self, root):
def destroy(self):
"""Remove all files under the cache root."""
for f in os.listdir(self.root):
path = join_path(self.root, f)
path = os.path.join(self.root, f)
if os.path.isdir(path):
shutil.rmtree(path, True)
else:
@ -65,14 +65,14 @@ def destroy(self):
def cache_path(self, key):
"""Path to the file in the cache for a particular key."""
return join_path(self.root, key)
return os.path.join(self.root, key)
def _lock_path(self, key):
"""Path to the file in the cache for a particular key."""
keyfile = os.path.basename(key)
keydir = os.path.dirname(key)
return join_path(self.root, keydir, '.' + keyfile + '.lock')
return os.path.join(self.root, keydir, '.' + keyfile + '.lock')
def _get_lock(self, key):
"""Create a lock for a key, if necessary, and return a lock object."""