move package_hash from util to main library

This commit is contained in:
Gregory Becker 2024-02-14 13:41:07 -08:00
parent 6e24ea55ea
commit 4516b742dd
6 changed files with 18 additions and 15 deletions

View File

@ -499,7 +499,7 @@ def _ensure_packages_are_pickeleable(pkgs, error_cls):
@package_properties @package_properties
def _ensure_packages_are_unparseable(pkgs, error_cls): def _ensure_packages_are_unparseable(pkgs, error_cls):
"""Ensure that all packages can unparse and that unparsed code is valid Python""" """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 = [] errors = []
for pkg_name in pkgs: for pkg_name in pkgs:
@ -646,9 +646,11 @@ def _linting_package_file(pkgs, error_cls):
if pkg_cls.homepage.startswith("http://"): if pkg_cls.homepage.startswith("http://"):
https = re.sub("http", "https", pkg_cls.homepage, 1) https = re.sub("http", "https", pkg_cls.homepage, 1)
try: try:
response = urlopen(https, response = urlopen(
verify_ssl=spack.config.get("config:verify_ssl", True), https,
timeout=spack.config.get("config:connect_timeout", 10)) verify_ssl=spack.config.get("config:verify_ssl", True),
timeout=spack.config.get("config:connect_timeout", 10),
)
except Exception as e: except Exception as e:
msg = 'Error with attempting https for "{0}": ' msg = 'Error with attempting https for "{0}": '
errors.append(error_cls(msg.format(pkg_cls.name), [str(e)])) errors.append(error_cls(msg.format(pkg_cls.name), [str(e)]))

View File

@ -12,10 +12,10 @@
from llnl.util.tty.colify import colify from llnl.util.tty.colify import colify
import spack.cmd import spack.cmd
import spack.package_hash as ph
import spack.paths import spack.paths
import spack.repo import spack.repo
import spack.util.executable as exe import spack.util.executable as exe
import spack.util.package_hash as ph
from spack.cmd.common import arguments from spack.cmd.common import arguments
description = "query packages associated with particular git revisions" description = "query packages associated with particular git revisions"

View File

@ -4,7 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
# flake8: noqa: F401 # 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. Everything in this module is automatically imported into Spack package files.
""" """

View File

@ -63,9 +63,9 @@
install_test_root, install_test_root,
) )
from spack.installer import InstallError, PackageInstaller 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.stage import DIYStage, ResourceStage, Stage, StageComposite, compute_stage_name
from spack.util.executable import ProcessError, which from spack.util.executable import ProcessError, which
from spack.util.package_hash import package_hash
from spack.version import GitVersion, StandardVersion, Version from spack.version import GitVersion, StandardVersion, Version
FLAG_HANDLER_RETURN_TYPE = Tuple[ FLAG_HANDLER_RETURN_TYPE = Tuple[
@ -829,8 +829,9 @@ def name(cls):
@classproperty @classproperty
def global_license_dir(cls): def global_license_dir(cls):
"""Returns the directory where license files for all packages are stored.""" """Returns the directory where license files for all packages are stored."""
return spack.util.path.canonicalize_path(spack.config.get("config:license_dir"), return spack.util.path.canonicalize_path(
replacements=spack.paths.path_replacements()) spack.config.get("config:license_dir"), replacements=spack.paths.path_replacements()
)
@property @property
def global_license_file(self): def global_license_file(self):
@ -987,11 +988,11 @@ def find_valid_url_for_version(self, version):
for u in urls: for u in urls:
if spack.util.web.url_exists( if spack.util.web.url_exists(
u, u,
fetch_method=spack.config.get('config:url_fetch_method', 'urllib'), fetch_method=spack.config.get("config:url_fetch_method", "urllib"),
verify_ssl=spack.config.get('config:verify_ssl'), verify_ssl=spack.config.get("config:verify_ssl"),
timeout=spack.config.get('config:connect_timeout', 10) timeout=spack.config.get("config:connect_timeout", 10),
): ):
return u return u
return None return None

View File

@ -9,9 +9,9 @@
import pytest import pytest
import spack.directives import spack.directives
import spack.package_hash as ph
import spack.paths import spack.paths
import spack.repo import spack.repo
import spack.util.package_hash as ph
from spack.spec import Spec from spack.spec import Spec
from spack.util.unparse import unparse from spack.util.unparse import unparse