summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2018-08-16 10:42:23 -0500
committerTodd Gamblin <tgamblin@llnl.gov>2018-08-16 08:42:23 -0700
commitac6d9298979fd5c22220c9a32710465aa88e35e8 (patch)
treede2a2a65dd14851a331cb15b81c102bcf8752f23
parentead9363bee6cc90132a5bb4888c3444b726de5a2 (diff)
downloadspack-ac6d9298979fd5c22220c9a32710465aa88e35e8.tar.gz
spack-ac6d9298979fd5c22220c9a32710465aa88e35e8.tar.bz2
spack-ac6d9298979fd5c22220c9a32710465aa88e35e8.tar.xz
spack-ac6d9298979fd5c22220c9a32710465aa88e35e8.zip
Fix spack versions behavior when no URL (#8967)
* Fix spack versions behavior when no URL * Unit test packages without URLs or safe versions
-rw-r--r--lib/spack/spack/cmd/versions.py23
-rw-r--r--lib/spack/spack/package.py20
-rw-r--r--lib/spack/spack/test/cmd/versions.py14
3 files changed, 45 insertions, 12 deletions
diff --git a/lib/spack/spack/cmd/versions.py b/lib/spack/spack/cmd/versions.py
index 8c55f83769..abb64f3747 100644
--- a/lib/spack/spack/cmd/versions.py
+++ b/lib/spack/spack/cmd/versions.py
@@ -42,20 +42,27 @@ def setup_parser(subparser):
def versions(parser, args):
pkg = spack.repo.get(args.package)
+ tty.msg('Safe versions (already checksummed):')
+
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()
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 fetched_versions:
- print(" Found no versions for %s" % pkg.name)
- tty.debug("Check the list_url and list_depth attribute on the "
- "package to help Spack find versions.")
+ print(' Found no versions for {0}'.format(pkg.name))
+ tty.debug('Check the list_url and list_depth attributes of the '
+ 'package to help Spack find versions.')
else:
- print(" Found no unchecksummed versions for %s" % pkg.name)
+ print(' Found no unchecksummed versions for {0}'.format(pkg.name))
else:
colify(sorted(remote_versions, reverse=True), indent=2)
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index cb4a6e1ac3..d3a716f552 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -2063,8 +2063,15 @@ class PackageBase(with_metaclass(PackageMeta, PackageViewMixin, object)):
@property
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 = []
- if self.url:
+ if hasattr(self, 'url') and self.url:
urls.append(self.url)
for args in self.versions.values():
@@ -2073,10 +2080,15 @@ class PackageBase(with_metaclass(PackageMeta, PackageViewMixin, object)):
return urls
def fetch_remote_versions(self):
- """Try to find remote versions of this package using the
- list_url and any other URLs described in the package file."""
+ """Find remote versions of this package.
+
+ 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:
- raise spack.util.web.VersionFetchError(self.__class__)
+ return {}
try:
return spack.util.web.find_versions_of_archive(
diff --git a/lib/spack/spack/test/cmd/versions.py b/lib/spack/spack/test/cmd/versions.py
index 69d2dae056..e1816ff230 100644
--- a/lib/spack/spack/test/cmd/versions.py
+++ b/lib/spack/spack/test/cmd/versions.py
@@ -48,3 +48,17 @@ def test_no_unchecksummed_versions():
"""Test a package for which no unchecksummed versions are available."""
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')