spack checksum: warn if version is deprecated (#32438)
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
parent
7bb4b58b8b
commit
3ec7304699
5 changed files with 42 additions and 2 deletions
|
@ -206,6 +206,8 @@ def setup(sphinx):
|
|||
# Spack classes that are private and we don't want to expose
|
||||
("py:class", "spack.provider_index._IndexBase"),
|
||||
("py:class", "spack.repo._PrependFileLoader"),
|
||||
# Spack classes that intersphinx is unable to resolve
|
||||
("py:class", "spack.version.VersionBase"),
|
||||
]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import spack.spec
|
||||
import spack.stage
|
||||
import spack.util.crypto
|
||||
from spack.package_base import preferred_version
|
||||
from spack.package_base import deprecated_version, preferred_version
|
||||
from spack.util.naming import valid_fully_qualified_module_name
|
||||
from spack.version import VersionBase, ver
|
||||
|
||||
|
@ -81,6 +81,9 @@ def checksum(parser, args):
|
|||
if versions:
|
||||
remote_versions = None
|
||||
for version in versions:
|
||||
if deprecated_version(pkg, version):
|
||||
tty.warn("Version {0} is deprecated".format(version))
|
||||
|
||||
version = ver(version)
|
||||
if not isinstance(version, VersionBase):
|
||||
tty.die(
|
||||
|
@ -101,7 +104,7 @@ def checksum(parser, args):
|
|||
url_dict = pkg.fetch_remote_versions()
|
||||
|
||||
if not url_dict:
|
||||
tty.die("Could not find any versions for {0}".format(pkg.name))
|
||||
tty.die("Could not find any remote versions for {0}".format(pkg.name))
|
||||
|
||||
version_lines = spack.stage.get_checksums_for_versions(
|
||||
url_dict,
|
||||
|
|
|
@ -100,6 +100,23 @@
|
|||
is_windows = sys.platform == "win32"
|
||||
|
||||
|
||||
def deprecated_version(pkg, version):
|
||||
"""Return True if the version is deprecated, False otherwise.
|
||||
|
||||
Arguments:
|
||||
pkg (Package): The package whose version is to be checked.
|
||||
version (str or spack.version.VersionBase): The version being checked
|
||||
"""
|
||||
if not isinstance(version, VersionBase):
|
||||
version = Version(version)
|
||||
|
||||
for k, v in pkg.versions.items():
|
||||
if version == k and v.get("deprecated", False):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def preferred_version(pkg):
|
||||
"""
|
||||
Returns a sorted list of the preferred versions of the package.
|
||||
|
|
|
@ -68,3 +68,13 @@ def test_checksum_versions(mock_packages, mock_fetch, mock_stage):
|
|||
output = spack_checksum("preferred-test", versions[0])
|
||||
assert "Found 1 version" in output
|
||||
assert "version(" in output
|
||||
|
||||
|
||||
def test_checksum_missing_version(mock_packages, mock_fetch, mock_stage):
|
||||
output = spack_checksum("preferred-test", "99.99.99", fail_on_error=False)
|
||||
assert "Could not find any remote versions" in output
|
||||
|
||||
|
||||
def test_checksum_deprecated_version(mock_packages, mock_fetch, mock_stage):
|
||||
output = spack_checksum("deprecated-versions", "1.1.0", fail_on_error=False)
|
||||
assert "Version 1.1.0 is deprecated" in output
|
||||
|
|
|
@ -321,3 +321,11 @@ def test_has_test_method_fails(capsys):
|
|||
|
||||
captured = capsys.readouterr()[1]
|
||||
assert "is not a class" in captured
|
||||
|
||||
|
||||
def test_package_deprecated_version(mock_packages, mock_fetch, mock_stage):
|
||||
spec = Spec("deprecated-versions")
|
||||
pkg_cls = spack.repo.path.get_pkg_class(spec.name)
|
||||
|
||||
assert spack.package_base.deprecated_version(pkg_cls, "1.1.0")
|
||||
assert not spack.package_base.deprecated_version(pkg_cls, "1.0.0")
|
||||
|
|
Loading…
Reference in a new issue