From be300eb6d55776581da9a4abafc69a4c3ca9fe74 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Thu, 8 Dec 2016 11:08:58 -0800 Subject: [PATCH] Add support for parsing R-XML URL versions. (#2525) * Add support for parsing R-XML URL versions. * Better url-parse debug output. - just print the debug stuff all the time. * fix R-XML versions. --- lib/spack/spack/cmd/url_parse.py | 10 +++++++--- lib/spack/spack/test/url_parse.py | 5 +++++ lib/spack/spack/url.py | 14 +++++++++----- var/spack/repos/builtin/packages/r-xml/package.py | 3 ++- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/spack/spack/cmd/url_parse.py b/lib/spack/spack/cmd/url_parse.py index b8c7c95040..2af9671459 100644 --- a/lib/spack/spack/cmd/url_parse.py +++ b/lib/spack/spack/cmd/url_parse.py @@ -53,15 +53,19 @@ def print_name_and_version(url): def url_parse(parser, args): url = args.url - ver, vs, vl = spack.url.parse_version_offset(url) - name, ns, nl = spack.url.parse_name_offset(url, ver) + ver, vs, vl = spack.url.parse_version_offset(url, debug=True) + name, ns, nl = spack.url.parse_name_offset(url, ver, debug=True) + print - tty.msg("Parsing URL:") + tty.msg("Detected:") try: print_name_and_version(url) except spack.url.UrlParseError as e: tty.error(str(e)) + print ' name: %s' % name + print ' version: %s' % ver + print tty.msg("Substituting version 9.9.9b:") newurl = spack.url.substitute_version(url, '9.9.9b') diff --git a/lib/spack/spack/test/url_parse.py b/lib/spack/spack/test/url_parse.py index 368532038f..818903c909 100644 --- a/lib/spack/spack/test/url_parse.py +++ b/lib/spack/spack/test/url_parse.py @@ -326,3 +326,8 @@ def test_github_raw_url(self): self.check( 'powerparser', '2.0.7', 'https://github.com/losalamos/CLAMR/blob/packages/PowerParser_v2.0.7.tgz?raw=true') + + def test_r_xml_version(self): + self.check( + 'xml', '3.98-1.4', + 'https://cran.r-project.org/src/contrib/XML_3.98-1.4.tar.gz') diff --git a/lib/spack/spack/url.py b/lib/spack/spack/url.py index 117f8488ee..d377a88bcc 100644 --- a/lib/spack/spack/url.py +++ b/lib/spack/spack/url.py @@ -163,7 +163,7 @@ def determine_url_file_extension(path): return ext -def parse_version_offset(path): +def parse_version_offset(path, debug=False): """Try to extract a version string from a filename or URL. This is taken largely from Homebrew's Version class.""" original_path = path @@ -209,8 +209,8 @@ def parse_version_offset(path): # e.g. lame-398-1 (r'-((\d)+-\d)', stem), - # e.g. foobar_1.2-3 - (r'_((\d+\.)+\d+(-\d+)?[a-z]?)', stem), + # e.g. foobar_1.2-3 or 3.98-1.4 + (r'_((\d+\.)+\d+(-(\d+(\.\d+)?))?[a-z]?)', stem), # e.g. foobar-4.5.1 (r'-((\d+\.)*\d+)$', stem), @@ -246,6 +246,10 @@ def parse_version_offset(path): regex, match_string = vtype match = re.search(regex, match_string) if match and match.group(1) is not None: + if debug: + tty.msg("Parsing URL: %s" % path, + " Matched regex %d: r'%s'" % (i, regex)) + version = match.group(1) start = match.start(1) @@ -266,9 +270,9 @@ def parse_version(path): return Version(ver) -def parse_name_offset(path, v=None): +def parse_name_offset(path, v=None, debug=False): if v is None: - v = parse_version(path) + v = parse_version(path, debug=debug) path, ext, suffix = split_url_extension(path) diff --git a/var/spack/repos/builtin/packages/r-xml/package.py b/var/spack/repos/builtin/packages/r-xml/package.py index 591c887f32..5affe7f08a 100644 --- a/var/spack/repos/builtin/packages/r-xml/package.py +++ b/var/spack/repos/builtin/packages/r-xml/package.py @@ -34,7 +34,8 @@ class RXml(Package): url = "https://cran.r-project.org/src/contrib/XML_3.98-1.4.tar.gz" list_url = "https://cran.r-project.org/src/contrib/Archive/XML" - version('3.98-1', '1a7f3ce6f264eeb109bfa57bedb26c14') + version('3.98-1.5', 'd1cfcd56f7aec96a84ffca91aea507ee') + version('3.98-1.4', '1a7f3ce6f264eeb109bfa57bedb26c14') extends('R')