New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
maintainers/scripts/update-python-libraries: support fetchFromGitHub #41149
Conversation
Regarding releases vs tags, there are very difficult cases. E.g., mail-parser has some versions as releases, but some only as tags: https://github.com/SpamScope/mail-parser/releases |
4df7af8
to
c663436
Compare
version = tag[1:] | ||
else: | ||
version = tag | ||
sha256 = nix_prefetch_github(owner=owner, repo=repo, rev=tag)['sha256'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is nix_prefetch_github
needed? The API does not offer sha256? Or is it because it does the choosing between zip and git?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the hash for fetchFromGitHub
the hash of the unpacked archive? To calculate it, I think I'd need to download and unpack it. That's what I use nix_prefetch_github
for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When fetchFromGitHub
picks an archive, it uses fetchzip
and for that nix-prefetch-url --unpack
can be used to determine the hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can use that if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for that. I was just hoping we could use the API instead of having to perform a download :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the requests limits for downloading without token is quite low so you would likely to run into limits.
@@ -60,10 +64,19 @@ def _get_values(attribute, text): | |||
|
|||
:returns: List of matches. | |||
""" | |||
# Find occurences of 'attribute = "string";' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the following changes needed? Could you update the docstring to describe what this function does.
@@ -169,7 +182,24 @@ def _get_latest_version_pypi(package, extension, current_version, target): | |||
return version, sha256 | |||
|
|||
|
|||
def _get_latest_version_github(package, extension, current_version, target): | |||
def _get_latest_version_github(text, package, extension, current_version, target): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a docstring, and explain in it how this function roughly works (that is, combination of PyGithub
and nix-prefetch-github
).
Thank you for your contributions.
|
@@ -36,6 +38,8 @@ PRERELEASES = False | |||
import logging | |||
logging.basicConfig(level=logging.INFO) | |||
|
|||
github = Github() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should accept a github token or it runs into rate limits quick.
@@ -20811,7 +20811,7 @@ with pkgs; | |||
|
|||
nix-pin = callPackage ../tools/package-management/nix-pin { }; | |||
|
|||
nix-prefetch-github = callPackage ../build-support/nix-prefetch-github {}; | |||
nix-prefetch-github = with python3.pkgs; toPythonApplication nix-prefetch-github; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way we also have nix-prefetch, which can handle a lot more.
Closing this as there are solutions such as https://github.com/Mic92/nix-update. |
Motivation for this change
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)cc @seppeljordan