summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-11-01 14:58:13 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2014-11-01 15:01:01 -0700
commit3db22a4e3317cb58e711efef71850eac85c4c48a (patch)
treeed4f4c2ec679b174ddd801295f8abd0e6d626564 /lib
parent85a14b68b75ef4e024cc84ab8ebdc4e9de4a23e1 (diff)
downloadspack-3db22a4e3317cb58e711efef71850eac85c4c48a.tar.gz
spack-3db22a4e3317cb58e711efef71850eac85c4c48a.tar.bz2
spack-3db22a4e3317cb58e711efef71850eac85c4c48a.tar.xz
spack-3db22a4e3317cb58e711efef71850eac85c4c48a.zip
Sane self.url for packages (reflects current version)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/error.py6
-rw-r--r--lib/spack/spack/fetch_strategy.py2
-rw-r--r--lib/spack/spack/package.py35
-rw-r--r--lib/spack/spack/stage.py3
4 files changed, 28 insertions, 18 deletions
diff --git a/lib/spack/spack/error.py b/lib/spack/spack/error.py
index 8bcbd83c28..e483ea613b 100644
--- a/lib/spack/spack/error.py
+++ b/lib/spack/spack/error.py
@@ -33,6 +33,12 @@ class SpackError(Exception):
self.long_message = long_message
+ def __str__(self):
+ msg = self.message
+ if self.long_message:
+ msg += "\n %s" % self.long_message
+ return msg
+
class UnsupportedPlatformError(SpackError):
"""Raised by packages when a platform is not supported"""
def __init__(self, message):
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index 98c78c2e08..80e2cdf413 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -580,7 +580,7 @@ def for_package_version(pkg, version):
version() in the package description."""
# If it's not a known version, extrapolate one.
if not version in pkg.versions:
- url = pkg.url_for_verison(version)
+ url = pkg.url_for_version(version)
if not url:
raise InvalidArgsError(pkg, version)
return URLFetchStrategy(url)
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 649e772a10..7cf94ed1ef 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -368,12 +368,19 @@ class Package(object):
# stage used to build this package.
self._stage = None
- # If there's no default URL provided, set this package's url to None
- if not hasattr(self, 'url'):
- self.url = None
-
- # Init fetch strategy to None
+ # Init fetch strategy and url to None
self._fetcher = None
+ self.url = None
+
+ # Fix up self.url if this package fetches with a URLFetchStrategy.
+ # This makes self.url behave sanely.
+ if self.spec.versions.concrete:
+ # TODO: this is a really roundabout way of determining the type of fetch to do.
+ # TODO: figure out a more sane fetch strategy/package init order
+ # TODO: (right now it's conflated with stage, package, and the tests make assumptions)
+ f = fs.for_package_version(self, self.version)
+ if isinstance(f, fs.URLFetchStrategy):
+ self.url = self.url_for_version(self.spec.version)
# Set a default list URL (place to find available versions)
if not hasattr(self, 'list_url'):
@@ -410,7 +417,7 @@ class Package(object):
*higher* URL, and if that isn't there raises an error.
"""
version_urls = self.version_urls()
- url = self.url
+ url = getattr(self.__class__, 'url', None)
for v in version_urls:
if v > version and url:
@@ -420,21 +427,15 @@ class Package(object):
return url
- def has_url(self):
- """Returns whether there is a URL available for this package.
- If there isn't, it's probably fetched some other way (version
- control, etc.)"""
- return self.url or self.version_urls()
-
-
# TODO: move this out of here and into some URL extrapolation module?
def url_for_version(self, version):
"""Returns a URL that you can download a new version of this package from."""
if not isinstance(version, Version):
version = Version(version)
- if not self.has_url():
- raise NoURLError(self.__class__)
+ cls = self.__class__
+ if not (hasattr(cls, 'url') or self.version_urls()):
+ raise NoURLError(cls)
# If we have a specific URL for this version, don't extrapolate.
version_urls = self.version_urls()
@@ -477,7 +478,7 @@ class Package(object):
def mirror_path(self):
"""Get path to this package's archive in a mirror."""
filename = "%s-%s." % (self.name, self.version)
- filename += extension(self.url) if self.has_url() else "tar.gz"
+ filename += extension(self.url) if self.url else "tar.gz"
return "%s/%s" % (self.name, filename)
@@ -709,6 +710,8 @@ class Package(object):
tty.msg("%s is already installed in %s." % (self.name, self.prefix))
return
+ tty.msg("Installing %s" % self.name)
+
if not ignore_deps:
self.do_install_dependencies()
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index b371761785..f09346ab9b 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -257,7 +257,8 @@ class Stage(object):
fetcher.fetch()
break
except spack.error.SpackError, e:
- tty.msg("Fetching %s failed." % fetcher)
+ tty.msg("Fetching from %s failed." % fetcher)
+ tty.debug(e)
continue