diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2014-09-27 15:32:44 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2014-09-27 15:32:44 -0700 |
commit | 608191bd8ccbdca6f9fd2bd638d7a278a652dd36 (patch) | |
tree | ec34d66eddaff5ef720a4aea472acc6d7a196aba | |
parent | 2de2d4bea7689f4421beee526c6ded9199740b6d (diff) | |
download | spack-608191bd8ccbdca6f9fd2bd638d7a278a652dd36.tar.gz spack-608191bd8ccbdca6f9fd2bd638d7a278a652dd36.tar.bz2 spack-608191bd8ccbdca6f9fd2bd638d7a278a652dd36.tar.xz spack-608191bd8ccbdca6f9fd2bd638d7a278a652dd36.zip |
Find custom list_urls depending on the archive URL (e.g. github releases)
-rw-r--r-- | lib/spack/spack/package.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/url.py | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 9644aa43d3..0d6c400bd8 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -859,7 +859,7 @@ def find_versions_of_archive(archive_url, **kwargs): list_depth = kwargs.get('list_depth', 1) if not list_url: - list_url = os.path.dirname(archive_url) + list_url = url.find_list_url(archive_url) # This creates a regex from the URL with a capture group for the # version part of the URL. The capture group is converted to a diff --git a/lib/spack/spack/url.py b/lib/spack/spack/url.py index 902ce9817d..e2fbb19f5d 100644 --- a/lib/spack/spack/url.py +++ b/lib/spack/spack/url.py @@ -78,6 +78,26 @@ class UndetectableNameError(UrlParseError): "Couldn't parse package name in: " + path, path) +def find_list_url(url): + """Finds a good list URL for the supplied URL. This depends on + the site. By default, just assumes that a good list URL is the + dirname of an archive path. For github URLs, this returns the + URL of the project's releases page. + """ + + url_types = [ + # e.g. https://github.com/scalability-llnl/callpath/archive/v1.0.1.tar.gz + (r'^(https://github.com/[^/]+/[^/]+)/archive/', lambda m: m.group(1) + '/releases') + ] + + for pattern, fun in url_types: + match = re.search(pattern, url) + if match: + return fun(match) + else: + return os.path.dirname(url) + + def parse_version_string_with_indices(path): """Try to extract a version string from a filename or URL. This is taken largely from Homebrew's Version class.""" |