def test_otf2_url_substitution(self): base = "http://www.vi-hps.org/upload/packages/otf2/otf2-1.4.tar.gz" self.assertEqual(url.substitute_version(base, '1.4'), base) self.assertEqual( url.substitute_version(base, '1.3.1'), "http://www.vi-hps.org/upload/packages/otf2/otf2-1.3.1.tar.gz") self.assertEqual( url.substitute_version(base, '1.2.1'), "http://www.vi-hps.org/upload/packages/otf2/otf2-1.2.1.tar.gz")
def test_hypre_url_substitution(self): base = "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-2.9.0b.tar.gz" self.assertEqual(url.substitute_version(base, '2.9.0b'), base) self.assertEqual( url.substitute_version(base, '2.8.0b'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-2.8.0b.tar.gz" ) self.assertEqual( url.substitute_version(base, '2.7.0b'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-2.7.0b.tar.gz" ) self.assertEqual( url.substitute_version(base, '2.6.0b'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-2.6.0b.tar.gz" ) self.assertEqual( url.substitute_version(base, '1.14.0b'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-1.14.0b.tar.gz" ) self.assertEqual( url.substitute_version(base, '1.13.0b'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-1.13.0b.tar.gz" ) self.assertEqual( url.substitute_version(base, '2.0.0'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-2.0.0.tar.gz" ) self.assertEqual( url.substitute_version(base, '1.6.0'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-1.6.0.tar.gz" )
def test_hypre_url_substitution(self): base = "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-2.9.0b.tar.gz" self.assertEqual(url.substitute_version(base, '2.9.0b'), base) self.assertEqual( url.substitute_version(base, '2.8.0b'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-2.8.0b.tar.gz") self.assertEqual( url.substitute_version(base, '2.7.0b'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-2.7.0b.tar.gz") self.assertEqual( url.substitute_version(base, '2.6.0b'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-2.6.0b.tar.gz") self.assertEqual( url.substitute_version(base, '1.14.0b'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-1.14.0b.tar.gz") self.assertEqual( url.substitute_version(base, '1.13.0b'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-1.13.0b.tar.gz") self.assertEqual( url.substitute_version(base, '2.0.0'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-2.0.0.tar.gz") self.assertEqual( url.substitute_version(base, '1.6.0'), "https://computation-rnd.llnl.gov/linear_solvers/download/hypre-1.6.0.tar.gz")
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) def nearest_url(version): """Finds the URL for the next lowest version with a URL. If there is no lower version with a URL, uses the package url property. If that isn't there, uses a *higher* URL, and if that isn't there raises an error. """ url = getattr(self, 'url', None) for v in sorted(self.versions): if v > version and url: break if self.versions[v].url: url = self.versions[v].url return url if version in self.versions: vdesc = self.versions[version] if not vdesc.url: base_url = nearest_url(version) vdesc.url = url.substitute_version(base_url, self.url_version(version)) return vdesc.url else: return nearest_url(version)
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) def nearest_url(version): """Finds the URL for the next lowest version with a URL. If there is no lower version with a URL, uses the package url property. If that isn't there, uses a *higher* URL, and if that isn't there raises an error. """ url = getattr(self, 'url', None) for v in sorted(self.versions): if v > version and url: break if self.versions[v].url: url = self.versions[v].url return url if version in self.versions: vdesc = self.versions[version] if not vdesc.url: base_url = nearest_url(version) vdesc.url = url.substitute_version( base_url, self.url_version(version)) return vdesc.url else: return nearest_url(version)
def test_url_parse_name_and_version(name, version, url): # Make sure correct name and version are extracted. parsed_name, parsed_version = parse_name_and_version(url) assert parsed_name == name assert parsed_version == Version(version) # Make sure Spack formulates the right URL when we try to # build one with a specific version. assert url == substitute_version(url, version)
def test_hypre_url_substitution(self): self.assertEqual(url.substitute_version(base, '2.9.0b'), base) self.assertEqual( url.substitute_version(base, '2.8.0b'), stem + "2.8.0b.tar.gz") self.assertEqual( url.substitute_version(base, '2.7.0b'), stem + "2.7.0b.tar.gz") self.assertEqual( url.substitute_version(base, '2.6.0b'), stem + "2.6.0b.tar.gz") self.assertEqual( url.substitute_version(base, '1.14.0b'), stem + "1.14.0b.tar.gz") self.assertEqual( url.substitute_version(base, '1.13.0b'), stem + "1.13.0b.tar.gz") self.assertEqual( url.substitute_version(base, '2.0.0'), stem + "2.0.0.tar.gz") self.assertEqual( url.substitute_version(base, '1.6.0'), stem + "1.6.0.tar.gz")
def check(self, name, v, string, **kwargs): # Make sure correct name and version are extracted. parsed_name, parsed_v = url.parse_name_and_version(string) self.assertEqual(parsed_name, name) self.assertEqual(parsed_v, url.Version(v)) # Some URLs (like boost) are special and need to override the # built-in functionality. if kwargs.get('no_check_url', False): return # Make sure Spack formulates the right URL when we try to # build one with a specific version. self.assertEqual(string, url.substitute_version(string, v))
def url_parse(args): url = args.url tty.msg('Parsing URL: {0}'.format(url)) print() ver, vs, vl, vi, vregex = parse_version_offset(url) tty.msg('Matched version regex {0:>2}: r{1!r}'.format(vi, vregex)) name, ns, nl, ni, nregex = parse_name_offset(url, ver) tty.msg('Matched name regex {0:>2}: r{1!r}'.format(ni, nregex)) print() tty.msg('Detected:') try: print_name_and_version(url) except UrlParseError as e: tty.error(str(e)) print(' name: {0}'.format(name)) print(' version: {0}'.format(ver)) print() tty.msg('Substituting version 9.9.9b:') newurl = substitute_version(url, '9.9.9b') print_name_and_version(newurl) if args.spider: print() tty.msg('Spidering for versions:') versions = find_versions_of_archive(url) if not versions: print(' Found no versions for {0}'.format(name)) return max_len = max(len(str(v)) for v in versions) for v in sorted(versions): print('{0:{1}} {2}'.format(v, max_len, versions[v]))
def url_for_version(self, version): """Gives a URL that you can download a new version of this package from.""" if self.force_url: return self.url return url.substitute_version(self.__class__.url, self.url_version(version))
def check_url(self, base, version, new_url): self.assertEqual(url.substitute_version(base, version), new_url)