From 4516b742dd0d0d05f4f1c4e10a21a4f6eadb6118 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Wed, 14 Feb 2024 13:41:07 -0800 Subject: [PATCH] move package_hash from util to main library --- lib/spack/spack/audit.py | 10 ++++++---- lib/spack/spack/cmd/pkg.py | 2 +- lib/spack/spack/package.py | 2 +- lib/spack/spack/package_base.py | 17 +++++++++-------- lib/spack/spack/{util => }/package_hash.py | 0 lib/spack/spack/test/{util => }/package_hash.py | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) rename lib/spack/spack/{util => }/package_hash.py (100%) rename lib/spack/spack/test/{util => }/package_hash.py (99%) diff --git a/lib/spack/spack/audit.py b/lib/spack/spack/audit.py index d74068ac621..90aa4a9f14e 100644 --- a/lib/spack/spack/audit.py +++ b/lib/spack/spack/audit.py @@ -499,7 +499,7 @@ def _ensure_packages_are_pickeleable(pkgs, error_cls): @package_properties def _ensure_packages_are_unparseable(pkgs, error_cls): """Ensure that all packages can unparse and that unparsed code is valid Python""" - import spack.util.package_hash as ph + import spack.package_hash as ph errors = [] for pkg_name in pkgs: @@ -646,9 +646,11 @@ def _linting_package_file(pkgs, error_cls): if pkg_cls.homepage.startswith("http://"): https = re.sub("http", "https", pkg_cls.homepage, 1) try: - response = urlopen(https, - verify_ssl=spack.config.get("config:verify_ssl", True), - timeout=spack.config.get("config:connect_timeout", 10)) + response = urlopen( + https, + verify_ssl=spack.config.get("config:verify_ssl", True), + timeout=spack.config.get("config:connect_timeout", 10), + ) except Exception as e: msg = 'Error with attempting https for "{0}": ' errors.append(error_cls(msg.format(pkg_cls.name), [str(e)])) diff --git a/lib/spack/spack/cmd/pkg.py b/lib/spack/spack/cmd/pkg.py index 0f025ace253..b3985a6c438 100644 --- a/lib/spack/spack/cmd/pkg.py +++ b/lib/spack/spack/cmd/pkg.py @@ -12,10 +12,10 @@ from llnl.util.tty.colify import colify import spack.cmd +import spack.package_hash as ph import spack.paths import spack.repo import spack.util.executable as exe -import spack.util.package_hash as ph from spack.cmd.common import arguments description = "query packages associated with particular git revisions" diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 0c01f4f2ef5..dc86d19954c 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) # flake8: noqa: F401 -"""spack.util.package is a set of useful build tools and directives for packages. +"""spack.package is a set of useful build tools and directives for packages. Everything in this module is automatically imported into Spack package files. """ diff --git a/lib/spack/spack/package_base.py b/lib/spack/spack/package_base.py index 2f49a45fc07..e709987eda6 100644 --- a/lib/spack/spack/package_base.py +++ b/lib/spack/spack/package_base.py @@ -63,9 +63,9 @@ install_test_root, ) from spack.installer import InstallError, PackageInstaller +from spack.package_hash import package_hash from spack.stage import DIYStage, ResourceStage, Stage, StageComposite, compute_stage_name from spack.util.executable import ProcessError, which -from spack.util.package_hash import package_hash from spack.version import GitVersion, StandardVersion, Version FLAG_HANDLER_RETURN_TYPE = Tuple[ @@ -829,8 +829,9 @@ def name(cls): @classproperty def global_license_dir(cls): """Returns the directory where license files for all packages are stored.""" - return spack.util.path.canonicalize_path(spack.config.get("config:license_dir"), - replacements=spack.paths.path_replacements()) + return spack.util.path.canonicalize_path( + spack.config.get("config:license_dir"), replacements=spack.paths.path_replacements() + ) @property def global_license_file(self): @@ -987,11 +988,11 @@ def find_valid_url_for_version(self, version): for u in urls: if spack.util.web.url_exists( - u, - fetch_method=spack.config.get('config:url_fetch_method', 'urllib'), - verify_ssl=spack.config.get('config:verify_ssl'), - timeout=spack.config.get('config:connect_timeout', 10) - ): + u, + fetch_method=spack.config.get("config:url_fetch_method", "urllib"), + verify_ssl=spack.config.get("config:verify_ssl"), + timeout=spack.config.get("config:connect_timeout", 10), + ): return u return None diff --git a/lib/spack/spack/util/package_hash.py b/lib/spack/spack/package_hash.py similarity index 100% rename from lib/spack/spack/util/package_hash.py rename to lib/spack/spack/package_hash.py diff --git a/lib/spack/spack/test/util/package_hash.py b/lib/spack/spack/test/package_hash.py similarity index 99% rename from lib/spack/spack/test/util/package_hash.py rename to lib/spack/spack/test/package_hash.py index 047f5df09e0..d14e62dbcdb 100644 --- a/lib/spack/spack/test/util/package_hash.py +++ b/lib/spack/spack/test/package_hash.py @@ -9,9 +9,9 @@ import pytest import spack.directives +import spack.package_hash as ph import spack.paths import spack.repo -import spack.util.package_hash as ph from spack.spec import Spec from spack.util.unparse import unparse