Sane self.url for packages (reflects current version)
This commit is contained in:
parent
85a14b68b7
commit
3db22a4e33
@ -33,6 +33,12 @@ def __init__(self, message, long_message=None):
|
|||||||
self.long_message = long_message
|
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):
|
class UnsupportedPlatformError(SpackError):
|
||||||
"""Raised by packages when a platform is not supported"""
|
"""Raised by packages when a platform is not supported"""
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
|
@ -580,7 +580,7 @@ def for_package_version(pkg, version):
|
|||||||
version() in the package description."""
|
version() in the package description."""
|
||||||
# If it's not a known version, extrapolate one.
|
# If it's not a known version, extrapolate one.
|
||||||
if not version in pkg.versions:
|
if not version in pkg.versions:
|
||||||
url = pkg.url_for_verison(version)
|
url = pkg.url_for_version(version)
|
||||||
if not url:
|
if not url:
|
||||||
raise InvalidArgsError(pkg, version)
|
raise InvalidArgsError(pkg, version)
|
||||||
return URLFetchStrategy(url)
|
return URLFetchStrategy(url)
|
||||||
|
@ -368,12 +368,19 @@ def ensure_has_dict(attr_name):
|
|||||||
# stage used to build this package.
|
# stage used to build this package.
|
||||||
self._stage = None
|
self._stage = None
|
||||||
|
|
||||||
# If there's no default URL provided, set this package's url to None
|
# Init fetch strategy and url to None
|
||||||
if not hasattr(self, 'url'):
|
self._fetcher = None
|
||||||
self.url = None
|
self.url = None
|
||||||
|
|
||||||
# Init fetch strategy to None
|
# Fix up self.url if this package fetches with a URLFetchStrategy.
|
||||||
self._fetcher = None
|
# 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)
|
# Set a default list URL (place to find available versions)
|
||||||
if not hasattr(self, 'list_url'):
|
if not hasattr(self, 'list_url'):
|
||||||
@ -410,7 +417,7 @@ def nearest_url(self, version):
|
|||||||
*higher* URL, and if that isn't there raises an error.
|
*higher* URL, and if that isn't there raises an error.
|
||||||
"""
|
"""
|
||||||
version_urls = self.version_urls()
|
version_urls = self.version_urls()
|
||||||
url = self.url
|
url = getattr(self.__class__, 'url', None)
|
||||||
|
|
||||||
for v in version_urls:
|
for v in version_urls:
|
||||||
if v > version and url:
|
if v > version and url:
|
||||||
@ -420,21 +427,15 @@ def nearest_url(self, version):
|
|||||||
return url
|
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?
|
# TODO: move this out of here and into some URL extrapolation module?
|
||||||
def url_for_version(self, version):
|
def url_for_version(self, version):
|
||||||
"""Returns a URL that you can download a new version of this package from."""
|
"""Returns a URL that you can download a new version of this package from."""
|
||||||
if not isinstance(version, Version):
|
if not isinstance(version, Version):
|
||||||
version = Version(version)
|
version = Version(version)
|
||||||
|
|
||||||
if not self.has_url():
|
cls = self.__class__
|
||||||
raise NoURLError(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.
|
# If we have a specific URL for this version, don't extrapolate.
|
||||||
version_urls = self.version_urls()
|
version_urls = self.version_urls()
|
||||||
@ -477,7 +478,7 @@ def fetcher(self, f):
|
|||||||
def mirror_path(self):
|
def mirror_path(self):
|
||||||
"""Get path to this package's archive in a mirror."""
|
"""Get path to this package's archive in a mirror."""
|
||||||
filename = "%s-%s." % (self.name, self.version)
|
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)
|
return "%s/%s" % (self.name, filename)
|
||||||
|
|
||||||
|
|
||||||
@ -709,6 +710,8 @@ def do_install(self, **kwargs):
|
|||||||
tty.msg("%s is already installed in %s." % (self.name, self.prefix))
|
tty.msg("%s is already installed in %s." % (self.name, self.prefix))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
tty.msg("Installing %s" % self.name)
|
||||||
|
|
||||||
if not ignore_deps:
|
if not ignore_deps:
|
||||||
self.do_install_dependencies()
|
self.do_install_dependencies()
|
||||||
|
|
||||||
|
@ -257,7 +257,8 @@ def fetch(self):
|
|||||||
fetcher.fetch()
|
fetcher.fetch()
|
||||||
break
|
break
|
||||||
except spack.error.SpackError, e:
|
except spack.error.SpackError, e:
|
||||||
tty.msg("Fetching %s failed." % fetcher)
|
tty.msg("Fetching from %s failed." % fetcher)
|
||||||
|
tty.debug(e)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user