Commit 88bc27cd authored by zen's avatar zen

[weblate] Fix version detection in update dep script (tails#17377)

We need to account for longer version strings than the one provided by
the Pypi JSON for some packages.

In the case at hand, Pypi will return "2.1" for latest user-agents
version, but we should be looking for "2.1.0" in GitHub tags.
parent 92ab68a3
......@@ -82,6 +82,7 @@ class tails::weblate::python_modules () {
tails::pip_package_from_repo { 'importlib-metadata':
version => '1.6.1', # >=0.18
tag => 'v1.6.1',
url => 'https://gitlab.com/python-devs/importlib_metadata',
require => [Exec['pip_install_zipp']],
}
......@@ -160,7 +161,7 @@ class tails::weblate::python_modules () {
}
tails::pip_package_from_repo { 'user-agents':
version => '2.1', # >=1.1.0
version => 'v2.1.0', # >=1.1.0
url => 'https://github.com/selwin/python-user-agents',
require => [Exec['pip_install_ua-parser']],
}
......
......@@ -46,9 +46,6 @@ pip:
repo_type: hg
additional_condition:
- <3.0 # Bigger versions require Python >=3.6
user-agents:
additional_condition:
- ==2.1.0 # Current version in Pypi is "2.1" and there's no such tag in the repo.
rjsmin:
url: https://github.com/ndparker/rjsmin
translate-toolkit:
......
......@@ -178,7 +178,10 @@ class Dependency:
versions.append(self.newest_pip_version[:-2])
for v in versions:
try:
version_tag = next(filter(lambda i: i.endswith(v), ll)).split("/")[-1]
# match URLs ending in this specific version, but also account
# for a possibly longer version string.
filter_fun = lambda i: re.match('.*/v?{}[0-9.]*$'.format(v), i)
version_tag = next(filter(filter_fun, ll)).split("/")[-1]
break
except StopIteration:
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment