diff --git a/lib/spack/spack/bootstrap/config.py b/lib/spack/spack/bootstrap/config.py index f3aa87c73fc..795accf2411 100644 --- a/lib/spack/spack/bootstrap/config.py +++ b/lib/spack/spack/bootstrap/config.py @@ -46,7 +46,7 @@ def root_path() -> str: """Root of all the bootstrap related folders""" return spack.util.path.canonicalize_path( spack.config.get("bootstrap:root", spack.paths.default_user_bootstrap_path), - replacements=spack.paths.path_replacements() + replacements=spack.paths.path_replacements(), ) @@ -80,14 +80,16 @@ def spack_python_interpreter() -> Generator: def _store_path() -> str: bootstrap_root_path = root_path() - return spack.util.path.canonicalize_path(os.path.join(bootstrap_root_path, "store"), - replacements=spack.paths.path_replacements()) + return spack.util.path.canonicalize_path( + os.path.join(bootstrap_root_path, "store"), replacements=spack.paths.path_replacements() + ) def _config_path() -> str: bootstrap_root_path = root_path() - return spack.util.path.canonicalize_path(os.path.join(bootstrap_root_path, "config"), - replacements=spack.paths.path_replacements()) + return spack.util.path.canonicalize_path( + os.path.join(bootstrap_root_path, "config"), replacements=spack.paths.path_replacements() + ) @contextlib.contextmanager diff --git a/lib/spack/spack/bootstrap/core.py b/lib/spack/spack/bootstrap/core.py index a3f0aeb7647..40deccd412c 100644 --- a/lib/spack/spack/bootstrap/core.py +++ b/lib/spack/spack/bootstrap/core.py @@ -93,8 +93,7 @@ def __init__(self, conf: ConfigDictionary) -> None: self.conf = conf self.name = conf["name"] self.metadata_dir = spack.util.path.canonicalize_path( - conf["metadata"], - replacements=spack.paths.path_replacements() + conf["metadata"], replacements=spack.paths.path_replacements() ) # Promote (relative) paths to file urls @@ -589,8 +588,7 @@ def bootstrapping_sources(scope: Optional[str] = None): for entry in source_configs: current = copy.copy(entry) metadata_dir = spack.util.path.canonicalize_path( - entry["metadata"], - replacements=spack.paths.path_replacements() + entry["metadata"], replacements=spack.paths.path_replacements() ) metadata_yaml = os.path.join(metadata_dir, METADATA_YAML_FILENAME) with open(metadata_yaml, encoding="utf-8") as stream: diff --git a/lib/spack/spack/caches.py b/lib/spack/spack/caches.py index 9f18f356755..78f9fb3c399 100644 --- a/lib/spack/spack/caches.py +++ b/lib/spack/spack/caches.py @@ -26,8 +26,7 @@ def misc_cache_location(): providers and for which packages provide which tags. """ path = spack.config.get("config:misc_cache", spack.paths.default_misc_cache_path) - return spack.util.path.canonicalize_path(path, - replacements=spack.paths.path_replacements()) + return spack.util.path.canonicalize_path(path, replacements=spack.paths.path_replacements()) def _misc_cache(): @@ -50,8 +49,7 @@ def fetch_cache_location(): path = spack.config.get("config:source_cache") if not path: path = spack.paths.default_fetch_cache_path - path = spack.util.path.canonicalize_path(path, - replacements=spack.paths.path_replacements()) + path = spack.util.path.canonicalize_path(path, replacements=spack.paths.path_replacements()) return path diff --git a/lib/spack/spack/cmd/bootstrap.py b/lib/spack/spack/cmd/bootstrap.py index 7a578ab8449..b7f32ff2bc7 100644 --- a/lib/spack/spack/cmd/bootstrap.py +++ b/lib/spack/spack/cmd/bootstrap.py @@ -192,8 +192,9 @@ def _root(args): root = spack.config.get("bootstrap:root", default=None, scope=args.scope) if root: - root = spack.util.path.canonicalize_path(root, - replacements=spack.paths.path_replacements()) + root = spack.util.path.canonicalize_path( + root, replacements=spack.paths.path_replacements() + ) print(root) @@ -337,8 +338,9 @@ def _add(args): raise RuntimeError(msg.format(args.name)) # Check that the metadata file exists - metadata_dir = spack.util.path.canonicalize_path(args.metadata_dir, - replacements=spack.paths.path_replacements()) + metadata_dir = spack.util.path.canonicalize_path( + args.metadata_dir, replacements=spack.paths.path_replacements() + ) if not os.path.exists(metadata_dir) or not os.path.isdir(metadata_dir): raise RuntimeError('the directory "{0}" does not exist'.format(args.metadata_dir)) @@ -387,8 +389,9 @@ def _remove(args): def _mirror(args): - mirror_dir = spack.util.path.canonicalize_path(os.path.join(args.root_dir, LOCAL_MIRROR_DIR), - replacements=spack.paths.path_replacements()) + mirror_dir = spack.util.path.canonicalize_path( + os.path.join(args.root_dir, LOCAL_MIRROR_DIR), replacements=spack.paths.path_replacements() + ) # TODO: Here we are adding gnuconfig manually, but this can be fixed # TODO: as soon as we have an option to add to a mirror all the possible @@ -438,19 +441,22 @@ def write_metadata(subdir, metadata): if args.binary_packages: abs_directory, rel_directory = write_metadata(subdir="binaries", metadata=BINARY_METADATA) shutil.copy( - spack.util.path.canonicalize_path(CLINGO_JSON, - replacements=spack.paths.path_replacements()), - abs_directory + spack.util.path.canonicalize_path( + CLINGO_JSON, replacements=spack.paths.path_replacements() + ), + abs_directory, ) shutil.copy( - spack.util.path.canonicalize_path(GNUPG_JSON, - replacements=spack.paths.path_replacements()), - abs_directory + spack.util.path.canonicalize_path( + GNUPG_JSON, replacements=spack.paths.path_replacements() + ), + abs_directory, ) shutil.copy( - spack.util.path.canonicalize_path(PATCHELF_JSON, - replacements=spack.paths.path_replacements()), - abs_directory + spack.util.path.canonicalize_path( + PATCHELF_JSON, replacements=spack.paths.path_replacements() + ), + abs_directory, ) instructions += cmd.format("local-binaries", rel_directory) print(instructions) diff --git a/lib/spack/spack/cmd/checksum.py b/lib/spack/spack/cmd/checksum.py index 8a03ebc12c2..545f12834a8 100644 --- a/lib/spack/spack/cmd/checksum.py +++ b/lib/spack/spack/cmd/checksum.py @@ -276,4 +276,4 @@ def add_versions_to_package(pkg: PackageBase, version_lines: str): tty.msg(f"Open {filename} to review the additions.") if sys.stdout.isatty(): - editor(filename, debug=spack.config.get('config:debug')) + editor(filename, debug=spack.config.get("config:debug")) diff --git a/lib/spack/spack/cmd/clean.py b/lib/spack/spack/cmd/clean.py index 6b642953632..de9251c6977 100644 --- a/lib/spack/spack/cmd/clean.py +++ b/lib/spack/spack/cmd/clean.py @@ -135,8 +135,7 @@ def clean(parser, args): if args.bootstrap: bootstrap_prefix = spack.util.path.canonicalize_path( - spack.config.get("bootstrap:root"), - replacements=spack.paths.path_replacements() + spack.config.get("bootstrap:root"), replacements=spack.paths.path_replacements() ) msg = 'Removing bootstrapped software and configuration in "{0}"' tty.msg(msg.format(bootstrap_prefix)) diff --git a/lib/spack/spack/cmd/config.py b/lib/spack/spack/cmd/config.py index 7458088fd11..28016f561d3 100644 --- a/lib/spack/spack/cmd/config.py +++ b/lib/spack/spack/cmd/config.py @@ -180,7 +180,7 @@ def config_edit(args): if args.print_file: print(config_file) else: - editor(config_file, debug=spack.config.get('config:debug')) + editor(config_file, debug=spack.config.get("config:debug")) def config_list(args): diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py index b5dc399e6e6..fe965c9d170 100644 --- a/lib/spack/spack/cmd/create.py +++ b/lib/spack/spack/cmd/create.py @@ -987,4 +987,4 @@ def create(parser, args): # Optionally open up the new package file in your $EDITOR if not args.skip_editor: - editor(pkg_path, debug=spack.config.get('config:debug')) + editor(pkg_path, debug=spack.config.get("config:debug")) diff --git a/lib/spack/spack/cmd/develop.py b/lib/spack/spack/cmd/develop.py index eb43a96b319..187678b122f 100644 --- a/lib/spack/spack/cmd/develop.py +++ b/lib/spack/spack/cmd/develop.py @@ -57,8 +57,7 @@ def develop(parser, args): for name, entry in env.dev_specs.items(): path = entry.get("path", name) abspath = spack.util.path.canonicalize_path( - path, default_wd=env.path, - replacements=spack.paths.path_replacements() + path, default_wd=env.path, replacements=spack.paths.path_replacements() ) if os.path.exists(abspath): @@ -90,8 +89,9 @@ def develop(parser, args): # default path is relative path to spec.name path = args.path or spec.name - abspath = spack.util.path.canonicalize_path(path, default_wd=env.path, - replacements=spack.paths.path_replacements()) + abspath = spack.util.path.canonicalize_path( + path, default_wd=env.path, replacements=spack.paths.path_replacements() + ) # clone default: only if the path doesn't exist clone = args.clone diff --git a/lib/spack/spack/cmd/edit.py b/lib/spack/spack/cmd/edit.py index 000e30dc266..e16bb0ebe35 100644 --- a/lib/spack/spack/cmd/edit.py +++ b/lib/spack/spack/cmd/edit.py @@ -46,7 +46,7 @@ def edit_package(name, repo_path, namespace): else: raise spack.repo.UnknownPackageError(spec.name) - editor(path, debug=spack.config.get('config:debug')) + editor(path, debug=spack.config.get("config:debug")) def setup_parser(subparser): diff --git a/lib/spack/spack/cmd/gpg.py b/lib/spack/spack/cmd/gpg.py index c049268f139..cf622622f60 100644 --- a/lib/spack/spack/cmd/gpg.py +++ b/lib/spack/spack/cmd/gpg.py @@ -132,9 +132,7 @@ def gpg_create(args): old_sec_keys = spack.gpg.signing_keys() # Create the new key - spack.gpg.create( - name=args.name, email=args.email, comment=args.comment, expires=args.expires - ) + spack.gpg.create(name=args.name, email=args.email, comment=args.comment, expires=args.expires) if args.export or args.secret: new_sec_keys = set(spack.gpg.signing_keys()) new_keys = new_sec_keys.difference(old_sec_keys) diff --git a/lib/spack/spack/cmd/repo.py b/lib/spack/spack/cmd/repo.py index ab2e06ab6e9..bcf36f719a4 100644 --- a/lib/spack/spack/cmd/repo.py +++ b/lib/spack/spack/cmd/repo.py @@ -84,8 +84,9 @@ def repo_add(args): path = args.path # real_path is absolute and handles substitution. - canon_path = spack.util.path.canonicalize_path(path, - replacements=spack.paths.path_replacements()) + canon_path = spack.util.path.canonicalize_path( + path, replacements=spack.paths.path_replacements() + ) # check if the path exists if not os.path.exists(canon_path): @@ -117,12 +118,12 @@ def repo_remove(args): namespace_or_path = args.namespace_or_path # If the argument is a path, remove that repository from config. - canon_path = spack.util.path.canonicalize_path(namespace_or_path, - replacements=spack.paths.path_replacements()) + canon_path = spack.util.path.canonicalize_path( + namespace_or_path, replacements=spack.paths.path_replacements() + ) for repo_path in repos: repo_canon_path = spack.util.path.canonicalize_path( - repo_path, - replacements=spack.paths.path_replacements() + repo_path, replacements=spack.paths.path_replacements() ) if canon_path == repo_canon_path: repos.remove(repo_path) diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py index 61eb4cfbdd4..7eb27769c58 100644 --- a/lib/spack/spack/concretize.py +++ b/lib/spack/spack/concretize.py @@ -92,8 +92,9 @@ def concretize_develop(self, spec): if not dev_info: return False - path = spack.util.path.canonicalize_path(dev_info["path"], default_wd=env.path, - replacements=spack.paths.path_replacements()) + path = spack.util.path.canonicalize_path( + dev_info["path"], default_wd=env.path, replacements=spack.paths.path_replacements() + ) if "dev_path" in spec.variants: assert spec.variants["dev_path"].value == path diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index 9ddf96159d5..d0c05a138c4 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -1452,9 +1452,7 @@ def _fetch_file(url): raw = raw_github_gitlab_url(url) tty.debug("Reading config from url {0}".format(raw)) return web_util.fetch_url_text( - raw, - dest_dir=dest_dir, - fetch_method=CONFIG.get('config:url_fetch_method') + raw, dest_dir=dest_dir, fetch_method=CONFIG.get("config:url_fetch_method") ) if not url: diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py index 3daf495e572..2ad6465e9c1 100644 --- a/lib/spack/spack/environment/environment.py +++ b/lib/spack/spack/environment/environment.py @@ -91,7 +91,7 @@ def env_root_path(): """Override default root path if the user specified it""" return spack.util.path.canonicalize_path( spack.config.get("config:environments_root", default=default_env_path), - replacements=spack.paths.path_replacements() + replacements=spack.paths.path_replacements(), ) @@ -480,8 +480,7 @@ def __init__( self.base = base_path self.raw_root = root self.root = spack.util.path.canonicalize_path( - root, default_wd=base_path, - replacements=spack.paths.path_replacements() + root, default_wd=base_path, replacements=spack.paths.path_replacements() ) self.projections = projections self.select = select @@ -498,8 +497,7 @@ def exclude_fn(self, spec): def update_root(self, new_path): self.raw_root = new_path self.root = spack.util.path.canonicalize_path( - new_path, default_wd=self.base, - replacements=spack.paths.path_replacements() + new_path, default_wd=self.base, replacements=spack.paths.path_replacements() ) def __eq__(self, other): @@ -992,8 +990,9 @@ def included_config_scopes(self): missing = [] for i, config_path in enumerate(reversed(includes)): # allow paths to contain spack config/environment variables, etc. - config_path = substitute_path_variables(config_path, - replacements=spack.paths.path_replacements()) + config_path = substitute_path_variables( + config_path, replacements=spack.paths.path_replacements() + ) include_url = urllib.parse.urlparse(config_path) @@ -1305,8 +1304,7 @@ def develop(self, spec: Spec, path: str, clone: bool = False) -> bool: # better if we can create the `source_path` directly into its final # destination. abspath = spack.util.path.canonicalize_path( - path, default_wd=self.path, - replacements=spack.paths.path_replacements() + path, default_wd=self.path, replacements=spack.paths.path_replacements() ) pkg_cls = spack.repo.PATH.get_pkg_class(spec.name) # We construct a package class ourselves, rather than asking for diff --git a/lib/spack/spack/hooks/licensing.py b/lib/spack/spack/hooks/licensing.py index f61d20dccca..4983f84d73b 100644 --- a/lib/spack/spack/hooks/licensing.py +++ b/lib/spack/spack/hooks/licensing.py @@ -40,7 +40,7 @@ def set_up_license(pkg): write_license_file(pkg, license_path) # use spack.util.executable so the editor does not hang on return here - ed.editor(license_path, exec_fn=ed.executable, debug=spack.config.get('config:debug')) + ed.editor(license_path, exec_fn=ed.executable, debug=spack.config.get("config:debug")) else: # Use already existing license file tty.msg("Found already existing license %s" % license_path) diff --git a/lib/spack/spack/install_test.py b/lib/spack/spack/install_test.py index 01913cf4792..6cd97842ea8 100644 --- a/lib/spack/spack/install_test.py +++ b/lib/spack/spack/install_test.py @@ -92,7 +92,7 @@ def get_test_stage_dir(): """ return spack.util.path.canonicalize_path( spack.config.get("config:test_stage", spack.paths.default_test_path), - replacements=spack.paths.path_replacements() + replacements=spack.paths.path_replacements(), ) diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py index f4db4208f33..4bc93c930c7 100644 --- a/lib/spack/spack/installer.py +++ b/lib/spack/spack/installer.py @@ -491,7 +491,7 @@ def _process_binary_cache_tarball( tty.msg(f"Extracting {package_id(pkg)} from binary cache") - padding = spack.config.get('config:install_tree:padded_length', None) + padding = spack.config.get("config:install_tree:padded_length", None) with timer.measure("install"), spack.util.path.filter_padding(padding=padding): binary_distribution.extract_tarball( pkg.spec, download_result, unsigned=unsigned, force=False, timer=timer @@ -2493,7 +2493,7 @@ def build_process(pkg: "spack.package_base.PackageBase", install_args: dict) -> installer = BuildProcessInstaller(pkg, install_args) # don't print long padded paths in executable debug output. - padding = spack.config.get('config:install_tree:padded_length', None) + padding = spack.config.get("config:install_tree:padded_length", None) with spack.util.path.filter_padding(padding=padding): return installer.run() diff --git a/lib/spack/spack/mirror.py b/lib/spack/spack/mirror.py index 247e621913c..eb8fdfa12fd 100644 --- a/lib/spack/spack/mirror.py +++ b/lib/spack/spack/mirror.py @@ -53,8 +53,9 @@ def _url_or_path_to_url(url_or_path: str) -> str: # Otherwise we interpret it as path, and we should promote it to file:// URL. return url_util.path_to_file_url( - spack.util.path.canonicalize_path(url_or_path, - replacements=spack.paths.path_replacements()) + spack.util.path.canonicalize_path( + url_or_path, replacements=spack.paths.path_replacements() + ) ) diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py index 4193e5fc9a5..8cce2e095ab 100644 --- a/lib/spack/spack/modules/common.py +++ b/lib/spack/spack/modules/common.py @@ -225,8 +225,7 @@ def root_path(name, module_set_name): roots = spack.config.merge_yaml(defaults, roots) path = roots.get(name, os.path.join(spack.paths.share_path, name)) - return spack.util.path.canonicalize_path(path, - replacements=spack.paths.path_replacements()) + return spack.util.path.canonicalize_path(path, replacements=spack.paths.path_replacements()) def generate_module_index(root, modules, overwrite=False): diff --git a/lib/spack/spack/package_prefs.py b/lib/spack/spack/package_prefs.py index d949c84c42e..ed521f15088 100644 --- a/lib/spack/spack/package_prefs.py +++ b/lib/spack/spack/package_prefs.py @@ -180,8 +180,9 @@ def _package(maybe_abstract_spec): spec_str = entry["spec"] external_path = entry.get("prefix", None) if external_path: - external_path = canonicalize_path(external_path, - replacements=spack.paths.path_replacements()) + external_path = canonicalize_path( + external_path, replacements=spack.paths.path_replacements() + ) external_modules = entry.get("modules", None) external_spec = spack.spec.Spec.from_detection( spack.spec.Spec( diff --git a/lib/spack/spack/repo.py b/lib/spack/spack/repo.py index 62751c38eaf..e6628cf6f7a 100644 --- a/lib/spack/spack/repo.py +++ b/lib/spack/spack/repo.py @@ -930,8 +930,7 @@ def __init__(self, root, cache=None): # Root directory, containing _repo.yaml and package dirs # Allow roots to by spack-relative by starting with '$spack' self.root = spack.util.path.canonicalize_path( - root, - replacements=spack.paths.path_replacements() + root, replacements=spack.paths.path_replacements() ) # check and raise BadRepoError on fail. @@ -1331,8 +1330,7 @@ def create_repo(root, namespace=None, subdir=packages_dir_name): If the namespace is not provided, use basename of root. Return the canonicalized path and namespace of the created repository. """ - root = spack.util.path.canonicalize_path(root, - replacements=spack.paths.path_replacements()) + root = spack.util.path.canonicalize_path(root, replacements=spack.paths.path_replacements()) if not namespace: namespace = os.path.basename(root) diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 26b100c6fc3..f31d720b51a 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -2604,9 +2604,10 @@ def setup( spack.spec.Spec(info["spec"]).constrained( "dev_path=%s" % spack.util.path.canonicalize_path( - info["path"], default_wd=env.path, - replacements=spack.paths.path_replacements() - ) + info["path"], + default_wd=env.path, + replacements=spack.paths.path_replacements(), + ) ) for name, info in env.dev_specs.items() ) @@ -3123,8 +3124,9 @@ def _develop_specs_from_env(spec, env): if not dev_info: return - path = spack.util.path.canonicalize_path(dev_info["path"], default_wd=env.path, - replacements=spack.paths.path_replacements()) + path = spack.util.path.canonicalize_path( + dev_info["path"], default_wd=env.path, replacements=spack.paths.path_replacements() + ) if "dev_path" in spec.variants: error_msg = ( diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py index b86b430f3a6..c10a3f58c94 100644 --- a/lib/spack/spack/stage.py +++ b/lib/spack/spack/stage.py @@ -150,8 +150,7 @@ def _resolve_paths(candidates): Adjustments involve removing extra $user from $tempdir if $tempdir includes $user and appending $user if it is not present in the path. """ - temp_path = sup.canonicalize_path("$tempdir", - replacements=spack.paths.path_replacements()) + temp_path = sup.canonicalize_path("$tempdir", replacements=spack.paths.path_replacements()) user = getpass.getuser() tmp_has_usr = user in temp_path.split(os.path.sep) @@ -163,8 +162,7 @@ def _resolve_paths(candidates): path = path.replace("/$user", "", 1) # Ensure the path is unique per user. - can_path = sup.canonicalize_path(path, - replacements=spack.paths.path_replacements()) + can_path = sup.canonicalize_path(path, replacements=spack.paths.path_replacements()) # When multiple users share a stage root, we can avoid conflicts between # them by adding a per-user subdirectory. # Avoid doing this on Windows to keep stage absolute path as short as possible. @@ -201,11 +199,10 @@ def get_stage_root(): def _mirror_roots(): mirrors = spack.config.get("mirrors") return [ - sup.substitute_path_variables(root, - replacements=spack.paths.path_replacements()) + sup.substitute_path_variables(root, replacements=spack.paths.path_replacements()) if root.endswith(os.sep) - else sup.substitute_path_variables(root, - replacemnts=spack.paths.path_replacements()) + os.sep + else sup.substitute_path_variables(root, replacemnts=spack.paths.path_replacements()) + + os.sep for root in mirrors.values() ] diff --git a/lib/spack/spack/store.py b/lib/spack/spack/store.py index 8fc419cce62..a8f184dac70 100644 --- a/lib/spack/spack/store.py +++ b/lib/spack/spack/store.py @@ -78,8 +78,7 @@ def parse_install_tree(config_dict): tty.warn("Using deprecated format for configuring install_tree") unpadded_root = install_tree unpadded_root = spack.util.path.canonicalize_path( - unpadded_root, - replacements=spack.paths.path_replacements() + unpadded_root, replacements=spack.paths.path_replacements() ) # construct projection from previous values for backwards compatibility all_projection = config_dict.get( @@ -90,8 +89,7 @@ def parse_install_tree(config_dict): else: unpadded_root = install_tree.get("root", DEFAULT_INSTALL_TREE_ROOT) unpadded_root = spack.util.path.canonicalize_path( - unpadded_root, - replacements=spack.paths.path_replacements() + unpadded_root, replacements=spack.paths.path_replacements() ) padded_length = install_tree.get("padded_length", False) @@ -273,8 +271,9 @@ def _construct_upstream_dbs_from_install_roots( for install_root in reversed(install_roots): upstream_dbs = list(accumulated_upstream_dbs) next_db = spack.database.Database( - spack.util.path.canonicalize_path(install_root, - replacements=spack.paths.path_replacements()), + spack.util.path.canonicalize_path( + install_root, replacements=spack.paths.path_replacements() + ), is_upstream=True, upstream_dbs=upstream_dbs, ) diff --git a/lib/spack/spack/tengine.py b/lib/spack/spack/tengine.py index 05612ad1ef7..f8504b33c41 100644 --- a/lib/spack/spack/tengine.py +++ b/lib/spack/spack/tengine.py @@ -78,8 +78,9 @@ def make_environment(dirs: Optional[Tuple[str, ...]] = None): builtins = spack.config.get("config:template_dirs", ["$spack/share/spack/templates"]) extensions = spack.extensions.get_template_dirs() r = spack.paths.path_replacements() - dirs = tuple(canonicalize_path(d, replacements=r) - for d in itertools.chain(builtins, extensions)) + dirs = tuple( + canonicalize_path(d, replacements=r) for d in itertools.chain(builtins, extensions) + ) # Loader for the templates loader = jinja2.FileSystemLoader(dirs) diff --git a/lib/spack/spack/test/bootstrap.py b/lib/spack/spack/test/bootstrap.py index 3e41a3f36d7..31eb9400db6 100644 --- a/lib/spack/spack/test/bootstrap.py +++ b/lib/spack/spack/test/bootstrap.py @@ -83,8 +83,7 @@ def test_store_path_customization(config_value, expected, mutable_config): # Check the store path current = spack.bootstrap.config.store_path() assert current == spack.util.path.canonicalize_path( - expected, - replacements=spack.paths.path_replacements() + expected, replacements=spack.paths.path_replacements() ) diff --git a/lib/spack/spack/test/cmd/develop.py b/lib/spack/spack/test/cmd/develop.py index cad4f04384f..7f2b45cfaa9 100644 --- a/lib/spack/spack/test/cmd/develop.py +++ b/lib/spack/spack/test/cmd/develop.py @@ -108,8 +108,7 @@ def test_develop_canonicalize_path(self, monkeypatch, config): with ev.read("test") as e: path = "../$user" abspath = spack.util.path.canonicalize_path( - path, e.path, - replacements=spack.paths.path_replacements() + path, e.path, replacements=spack.paths.path_replacements() ) def check_path(stage, dest): @@ -128,8 +127,7 @@ def test_develop_canonicalize_path_no_args(self, monkeypatch, config): with ev.read("test") as e: path = "$user" abspath = spack.util.path.canonicalize_path( - path, e.path, - replacements=spack.paths.path_replacements() + path, e.path, replacements=spack.paths.path_replacements() ) def check_path(stage, dest): diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index d9f18023e42..7ba2c3bf4fe 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -904,8 +904,9 @@ def test_env_with_included_config_var_path(tmpdir, packages_file): spack_yaml = env_path / ev.manifest_name spack_yaml.write_text(mpileaks_env_config(config_var_path)) - config_real_path = substitute_path_variables(config_var_path, - replacements=spack.paths.path_replacements()) + config_real_path = substitute_path_variables( + config_var_path, replacements=spack.paths.path_replacements() + ) shutil.move(included_file, config_real_path) assert os.path.exists(config_real_path) diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py index 7c1f87618eb..75cd64564cd 100644 --- a/lib/spack/spack/test/config.py +++ b/lib/spack/spack/test/config.py @@ -341,58 +341,48 @@ def test_substitute_config_variables(mock_low_high_config, monkeypatch): r = spack.paths.path_replacements() assert cross_plat_join( os.sep + os.path.join("foo", "bar", "baz"), prefix - ) == spack_path.canonicalize_path("/foo/bar/baz/$spack", - replacements=r) + ) == spack_path.canonicalize_path("/foo/bar/baz/$spack", replacements=r) assert cross_plat_join( spack.paths.prefix, os.path.join("foo", "bar", "baz") - ) == spack_path.canonicalize_path("$spack/foo/bar/baz/", - replacements=r) + ) == spack_path.canonicalize_path("$spack/foo/bar/baz/", replacements=r) assert cross_plat_join( os.sep + os.path.join("foo", "bar", "baz"), prefix, os.path.join("foo", "bar", "baz") - ) == spack_path.canonicalize_path("/foo/bar/baz/$spack/foo/bar/baz/", - replacements=r) + ) == spack_path.canonicalize_path("/foo/bar/baz/$spack/foo/bar/baz/", replacements=r) assert cross_plat_join( os.sep + os.path.join("foo", "bar", "baz"), prefix - ) == spack_path.canonicalize_path("/foo/bar/baz/${spack}", - replacements=r) + ) == spack_path.canonicalize_path("/foo/bar/baz/${spack}", replacements=r) assert cross_plat_join( spack.paths.prefix, os.path.join("foo", "bar", "baz") - ) == spack_path.canonicalize_path("${spack}/foo/bar/baz/", - replacements=r) + ) == spack_path.canonicalize_path("${spack}/foo/bar/baz/", replacements=r) assert cross_plat_join( os.sep + os.path.join("foo", "bar", "baz"), prefix, os.path.join("foo", "bar", "baz") - ) == spack_path.canonicalize_path("/foo/bar/baz/${spack}/foo/bar/baz/", - replacements=r) + ) == spack_path.canonicalize_path("/foo/bar/baz/${spack}/foo/bar/baz/", replacements=r) assert cross_plat_join( os.sep + os.path.join("foo", "bar", "baz"), prefix, os.path.join("foo", "bar", "baz") - ) != spack_path.canonicalize_path("/foo/bar/baz/${spack/foo/bar/baz/", - replacements=r) + ) != spack_path.canonicalize_path("/foo/bar/baz/${spack/foo/bar/baz/", replacements=r) # $env replacement is a no-op when no environment is active assert spack_path.canonicalize_path( - os.sep + os.path.join("foo", "bar", "baz", "$env"), - replacements=r + os.sep + os.path.join("foo", "bar", "baz", "$env"), replacements=r ) == os.sep + os.path.join("foo", "bar", "baz", "$env") # Fake an active environment and $env is replaced properly fake_env_path = os.sep + os.path.join("quux", "quuux") monkeypatch.setattr(ev, "active_environment", lambda: MockEnv(fake_env_path)) - assert spack_path.canonicalize_path("$env/foo/bar/baz", - replacements=r) == os.path.join( + assert spack_path.canonicalize_path("$env/foo/bar/baz", replacements=r) == os.path.join( fake_env_path, os.path.join("foo", "bar", "baz") ) # relative paths without source information are relative to cwd - assert spack_path.canonicalize_path(os.path.join("foo", "bar", "baz"), - replacements=r) == os.path.abspath( - os.path.join("foo", "bar", "baz") - ) + assert spack_path.canonicalize_path( + os.path.join("foo", "bar", "baz"), replacements=r + ) == os.path.abspath(os.path.join("foo", "bar", "baz")) # relative paths with source information are relative to the file spack.config.set( @@ -400,22 +390,19 @@ def test_substitute_config_variables(mock_low_high_config, monkeypatch): ) spack.config.CONFIG.clear_caches() path = spack.config.get("modules:default:roots:lmod") - assert spack_path.canonicalize_path(path, - replacements=r) == os.path.normpath( + assert spack_path.canonicalize_path(path, replacements=r) == os.path.normpath( os.path.join(mock_low_high_config.scopes["low"].path, os.path.join("foo", "bar", "baz")) ) # test architecture information is in replacements assert spack_path.canonicalize_path( - os.path.join("foo", "$platform", "bar"), - replacements=r + os.path.join("foo", "$platform", "bar"), replacements=r ) == os.path.abspath(os.path.join("foo", "test", "bar")) host_target = spack.platforms.host().target("default_target") host_target_family = str(host_target.microarchitecture.family) assert spack_path.canonicalize_path( - os.path.join("foo", "$target_family", "bar"), - replacements=r + os.path.join("foo", "$target_family", "bar"), replacements=r ) == os.path.abspath(os.path.join("foo", host_target_family, "bar")) @@ -453,32 +440,32 @@ def test_substitute_user(mock_low_high_config): "foo", "bar" ) + os.sep + user + os.sep + "baz" == spack_path.canonicalize_path( os.sep + os.path.join("foo", "bar", "$user", "baz"), - replacements=spack.paths.path_replacements() + replacements=spack.paths.path_replacements(), ) def test_substitute_user_cache(mock_low_high_config): user_cache_path = spack.paths.user_cache_path assert user_cache_path + os.sep + "baz" == spack_path.canonicalize_path( - os.path.join("$user_cache_path", "baz"), - replacements=spack.paths.path_replacements() + os.path.join("$user_cache_path", "baz"), replacements=spack.paths.path_replacements() ) def test_substitute_tempdir(mock_low_high_config): tempdir = tempfile.gettempdir() - assert tempdir == spack_path.canonicalize_path("$tempdir", - replacements=spack.paths.path_replacements()) + assert tempdir == spack_path.canonicalize_path( + "$tempdir", replacements=spack.paths.path_replacements() + ) assert tempdir + os.sep + os.path.join("foo", "bar", "baz") == spack_path.canonicalize_path( - os.path.join("$tempdir", "foo", "bar", "baz"), - replacements=spack.paths.path_replacements() + os.path.join("$tempdir", "foo", "bar", "baz"), replacements=spack.paths.path_replacements() ) def test_substitute_date(mock_low_high_config): test_path = os.path.join("hello", "world", "on", "$date") - new_path = spack_path.canonicalize_path(test_path, - replacements=spack.paths.path_replacements()) + new_path = spack_path.canonicalize_path( + test_path, replacements=spack.paths.path_replacements() + ) assert "$date" in test_path assert date.today().strftime("%Y-%m-%d") in new_path diff --git a/lib/spack/spack/test/stage.py b/lib/spack/spack/test/stage.py index da74c421ace..a1c789d5c98 100644 --- a/lib/spack/spack/test/stage.py +++ b/lib/spack/spack/test/stage.py @@ -734,8 +734,7 @@ def test_resolve_paths(self): assert spack.stage._resolve_paths(paths) == paths tempdir = "$tempdir" - can_tempdir = canonicalize_path(tempdir, - replacements=spack.paths.path_replacements()) + can_tempdir = canonicalize_path(tempdir, replacements=spack.paths.path_replacements()) user = getpass.getuser() temp_has_user = user in can_tempdir.split(os.sep) paths = [ diff --git a/lib/spack/spack/test/url_fetch.py b/lib/spack/spack/test/url_fetch.py index cdcf81869e4..6e0d76f0015 100644 --- a/lib/spack/spack/test/url_fetch.py +++ b/lib/spack/spack/test/url_fetch.py @@ -351,8 +351,7 @@ def _which(*args, **kwargs): def test_url_fetch_text_without_url(tmpdir): with pytest.raises(web_util.WebError, match="URL is required"): - web_util.fetch_url_text(None, - fetch_method=spack.config.get('config:url_fetch_method')) + web_util.fetch_url_text(None, fetch_method=spack.config.get("config:url_fetch_method")) def test_url_fetch_text_curl_failures(tmpdir, monkeypatch): @@ -369,8 +368,9 @@ def _which(*args, **kwargs): with spack.config.override("config:url_fetch_method", "curl"): with pytest.raises(web_util.WebError, match="Missing required curl"): - web_util.fetch_url_text("https://github.com/", - fetch_method=spack.config.get('config:url_fetch_method')) + web_util.fetch_url_text( + "https://github.com/", fetch_method=spack.config.get("config:url_fetch_method") + ) def test_url_check_curl_errors(): @@ -398,8 +398,10 @@ def _which(*args, **kwargs): with spack.config.override("config:url_fetch_method", "curl"): with pytest.raises(web_util.WebError, match="Missing required curl"): - web_util.url_exists("https://github.com/", - fetch_method=spack.config.get('config:url_fetch_method', 'urllib')) + web_util.url_exists( + "https://github.com/", + fetch_method=spack.config.get("config:url_fetch_method", "urllib"), + ) def test_url_fetch_text_urllib_bad_returncode(tmpdir, monkeypatch): @@ -414,8 +416,9 @@ def _read_from_url(*args, **kwargs): with spack.config.override("config:url_fetch_method", "urllib"): with pytest.raises(web_util.WebError, match="failed with error code"): - web_util.fetch_url_text("https://github.com/", - fetch_method=spack.config.get('config:url_fetch_method')) + web_util.fetch_url_text( + "https://github.com/", fetch_method=spack.config.get("config:url_fetch_method") + ) def test_url_fetch_text_urllib_web_error(tmpdir, monkeypatch): @@ -426,5 +429,6 @@ def _raise_web_error(*args, **kwargs): with spack.config.override("config:url_fetch_method", "urllib"): with pytest.raises(web_util.WebError, match="fetch failed to verify"): - web_util.fetch_url_text("https://github.com/", - fetch_method=spack.config.get('config:url_fetch_method')) + web_util.fetch_url_text( + "https://github.com/", fetch_method=spack.config.get("config:url_fetch_method") + ) diff --git a/lib/spack/spack/test/util/path.py b/lib/spack/spack/test/util/path.py index 13c2edd806a..943a9841876 100644 --- a/lib/spack/spack/test/util/path.py +++ b/lib/spack/spack/test/util/path.py @@ -79,7 +79,7 @@ def test_output_filtering(self, capfd, install_mockery, mutable_config): # test filtering when padding is enabled with spack.config.override("config:install_tree", {"padded_length": 256}): # tty.msg with filtering on the first argument - padding = spack.config.get('config:install_tree:padded_length', None) + padding = spack.config.get("config:install_tree:padded_length", None) with sup.filter_padding(padding=padding): tty.msg("here is a long path: %s/with/a/suffix" % long_path) out, err = capfd.readouterr() diff --git a/lib/spack/spack/util/editor.py b/lib/spack/spack/util/editor.py index a4a5d5da72e..51b2402d3bc 100644 --- a/lib/spack/spack/util/editor.py +++ b/lib/spack/spack/util/editor.py @@ -60,8 +60,9 @@ def executable(exe: str, args: List[str]) -> int: return cmd.returncode -def editor(*args: str, exec_fn: Callable[[str, List[str]], int] = os.execv, - debug: bool = False) -> bool: +def editor( + *args: str, exec_fn: Callable[[str, List[str]], int] = os.execv, debug: bool = False +) -> bool: """Invoke the user's editor. This will try to execute the following, in order: