Fix spack versions behavior when no URL (#8967)
* Fix spack versions behavior when no URL * Unit test packages without URLs or safe versions
This commit is contained in:
parent
ead9363bee
commit
ac6d929897
@ -42,20 +42,27 @@ def setup_parser(subparser):
|
|||||||
def versions(parser, args):
|
def versions(parser, args):
|
||||||
pkg = spack.repo.get(args.package)
|
pkg = spack.repo.get(args.package)
|
||||||
|
|
||||||
|
tty.msg('Safe versions (already checksummed):')
|
||||||
|
|
||||||
safe_versions = pkg.versions
|
safe_versions = pkg.versions
|
||||||
|
|
||||||
|
if not safe_versions:
|
||||||
|
print(' Found no versions for {0}'.format(pkg.name))
|
||||||
|
tty.debug('Manually add versions to the package.')
|
||||||
|
else:
|
||||||
|
colify(sorted(safe_versions, reverse=True), indent=2)
|
||||||
|
|
||||||
|
tty.msg('Remote versions (not yet checksummed):')
|
||||||
|
|
||||||
fetched_versions = pkg.fetch_remote_versions()
|
fetched_versions = pkg.fetch_remote_versions()
|
||||||
remote_versions = set(fetched_versions).difference(safe_versions)
|
remote_versions = set(fetched_versions).difference(safe_versions)
|
||||||
|
|
||||||
tty.msg("Safe versions (already checksummed):")
|
|
||||||
colify(sorted(safe_versions, reverse=True), indent=2)
|
|
||||||
|
|
||||||
tty.msg("Remote versions (not yet checksummed):")
|
|
||||||
if not remote_versions:
|
if not remote_versions:
|
||||||
if not fetched_versions:
|
if not fetched_versions:
|
||||||
print(" Found no versions for %s" % pkg.name)
|
print(' Found no versions for {0}'.format(pkg.name))
|
||||||
tty.debug("Check the list_url and list_depth attribute on the "
|
tty.debug('Check the list_url and list_depth attributes of the '
|
||||||
"package to help Spack find versions.")
|
'package to help Spack find versions.')
|
||||||
else:
|
else:
|
||||||
print(" Found no unchecksummed versions for %s" % pkg.name)
|
print(' Found no unchecksummed versions for {0}'.format(pkg.name))
|
||||||
else:
|
else:
|
||||||
colify(sorted(remote_versions, reverse=True), indent=2)
|
colify(sorted(remote_versions, reverse=True), indent=2)
|
||||||
|
@ -2063,8 +2063,15 @@ def format_doc(self, **kwargs):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def all_urls(self):
|
def all_urls(self):
|
||||||
|
"""A list of all URLs in a package.
|
||||||
|
|
||||||
|
Check both class-level and version-specific URLs.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list: a list of URLs
|
||||||
|
"""
|
||||||
urls = []
|
urls = []
|
||||||
if self.url:
|
if hasattr(self, 'url') and self.url:
|
||||||
urls.append(self.url)
|
urls.append(self.url)
|
||||||
|
|
||||||
for args in self.versions.values():
|
for args in self.versions.values():
|
||||||
@ -2073,10 +2080,15 @@ def all_urls(self):
|
|||||||
return urls
|
return urls
|
||||||
|
|
||||||
def fetch_remote_versions(self):
|
def fetch_remote_versions(self):
|
||||||
"""Try to find remote versions of this package using the
|
"""Find remote versions of this package.
|
||||||
list_url and any other URLs described in the package file."""
|
|
||||||
|
Uses ``list_url`` and any other URLs listed in the package file.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: a dictionary mapping versions to URLs
|
||||||
|
"""
|
||||||
if not self.all_urls:
|
if not self.all_urls:
|
||||||
raise spack.util.web.VersionFetchError(self.__class__)
|
return {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return spack.util.web.find_versions_of_archive(
|
return spack.util.web.find_versions_of_archive(
|
||||||
|
@ -48,3 +48,17 @@ def test_no_unchecksummed_versions():
|
|||||||
"""Test a package for which no unchecksummed versions are available."""
|
"""Test a package for which no unchecksummed versions are available."""
|
||||||
|
|
||||||
versions('bzip2')
|
versions('bzip2')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.network
|
||||||
|
def test_versions_no_url():
|
||||||
|
"""Test a package with versions but without a ``url`` attribute."""
|
||||||
|
|
||||||
|
versions('graphviz')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.network
|
||||||
|
def test_no_versions_no_url():
|
||||||
|
"""Test a package without versions or a ``url`` attribute."""
|
||||||
|
|
||||||
|
versions('opengl')
|
||||||
|
Loading…
Reference in New Issue
Block a user