Sane self.url for packages (reflects current version)
This commit is contained in:
		@@ -33,6 +33,12 @@ def __init__(self, message, long_message=None):
 | 
			
		||||
        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):
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -368,12 +368,19 @@ def ensure_has_dict(attr_name):
 | 
			
		||||
        # 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 @@ def nearest_url(self, version):
 | 
			
		||||
           *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 @@ def nearest_url(self, version):
 | 
			
		||||
        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 @@ def fetcher(self, f):
 | 
			
		||||
    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 @@ def do_install(self, **kwargs):
 | 
			
		||||
            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()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -257,7 +257,8 @@ def fetch(self):
 | 
			
		||||
                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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user