From 36b8ea2f928651a53f29c0dae158f70597207173 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 9 Jun 2017 12:28:39 -0500 Subject: Add default list_url for GitLab, BitBucket, and CRAN (#4439) * Add default list_url for GitLab, BitBucket, and CRAN * Fix flake and doc tests --- lib/spack/spack/url.py | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/url.py b/lib/spack/spack/url.py index 54b3b74f1b..f20ca1f918 100644 --- a/lib/spack/spack/url.py +++ b/lib/spack/spack/url.py @@ -63,16 +63,49 @@ from spack.version import Version # "path" seemed like the most generic term. # 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. + """Finds a good list URL for the supplied URL. + + By default, returns the dirname of the archive path. + + Provides special treatment for the following websites, which have a + unique list URL different from the dirname of the download URL: + + ========= ======================================================= + GitHub https://github.com///releases + GitLab https://gitlab.\*///tags + BitBucket https://bitbucket.org///downloads/?tab=tags + CRAN https://\*.r-project.org/src/contrib/Archive/ + ========= ======================================================= + + Parameters: + url (str): The download URL for the package + + Returns: + str: The list URL for the package """ url_types = [ + # GitHub # e.g. https://github.com/llnl/callpath/archive/v1.0.1.tar.gz (r'(.*github\.com/[^/]+/[^/]+)', - lambda m: m.group(1) + '/releases')] + lambda m: m.group(1) + '/releases'), + + # GitLab + # e.g. https://gitlab.dkrz.de/k202009/libaec/uploads/631e85bcf877c2dcaca9b2e6d6526339/libaec-1.0.0.tar.gz + (r'(.*gitlab[^/]+/[^/]+/[^/]+)', + lambda m: m.group(1) + '/tags'), + + # BitBucket + # e.g. https://bitbucket.org/eigen/eigen/get/3.3.3.tar.bz2 + (r'(.*bitbucket.org/[^/]+/[^/]+)', + lambda m: m.group(1) + '/downloads/?tab=tags'), + + # CRAN + # e.g. https://cran.r-project.org/src/contrib/Rcpp_0.12.9.tar.gz + # e.g. https://cloud.r-project.org/src/contrib/rgl_0.98.1.tar.gz + (r'(.*\.r-project\.org/src/contrib)/([^_]+)', + lambda m: m.group(1) + '/Archive/' + m.group(2)), + ] for pattern, fun in url_types: match = re.search(pattern, url) -- cgit v1.2.3-70-g09d2