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.
This commit is contained in:
Todd Gamblin 2016-12-08 11:08:58 -08:00 committed by becker33
parent 65df417444
commit be300eb6d5
4 changed files with 23 additions and 9 deletions

View file

@ -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')

View file

@ -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')

View file

@ -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)

View file

@ -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')