diff options
author | Jonathan Ringer <jonringer117@gmail.com> | 2022-01-13 15:42:16 -0800 |
---|---|---|
committer | Jonathan Ringer <jonringer@users.noreply.github.com> | 2022-01-13 18:55:44 -0800 |
commit | b316efff4b10d79d49f8e8fe63bbc93fbedefe9f (patch) | |
tree | ee45ec5609b03bc014ea439a9dd6dc97160b8945 /pkgs/development/interpreters/python | |
parent | ce0a90773077a52e2ce7fd6094078b075dd76867 (diff) |
update-python-libraries: skip replacing 'rev' when set to variable
It's common for fetchFromGitHub to have `rev = version;`, in which it will inherit the version. So no replacement is required.
Diffstat (limited to 'pkgs/development/interpreters/python')
-rwxr-xr-x | pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py b/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py index 59336cfae4a07..ee610b2620268 100755 --- a/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py +++ b/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py @@ -350,9 +350,19 @@ def _update_package(path, target): text = _replace_value('hash', sri_hash, text) if fetcher == 'fetchFromGitHub': - text = _replace_value('rev', f"{prefix}${{version}}", text) - # incase there's no prefix, just rewrite without interpolation - text = text.replace('"${version}";', 'version;') + # in the case of fetchFromGitHub, it's common to see `rev = version;` + # in which no string value is meant to be substituted. + # Verify that the attribute is set to a variable + regex = '(rev\s+=\s+([_a-zA-Z][_a-zA-Z0-9\.]*);)' + regex = re.compile(regex) + value = regex.findall(text) + n = len(value) + + if n == 0: + # value is set to a string, e.g. `rev = "v${version}";` + text = _replace_value('rev', f"{prefix}${{version}}", text) + # incase there's no prefix, just rewrite without interpolation + text = text.replace('"${version}";', 'version;') with open(path, 'w') as f: f.write(text) |