-
-
Notifications
You must be signed in to change notification settings - Fork 591
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
Adds a script for updating vendored code in sunpy/extern
#6127
Conversation
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.
Hi @akash5100, thank you for working on this PR! Looking through your script, it seems that you are attempting to update the dependencies of the packages in sunpy/sunpy/extern
rather than the packages (sunpy/sunpy/extern/*.py
) themselves.
As an example, updating sunpy/sunpy/extern/appdirs.py
should download the latest released version of the upstream ActiveState/appdirs appdirs.py
. (Either using the GitHub API or pip download appdirs
for example.) Then the script should replace the old appdirs.py
file with the upstream file (and possibly run SunPy's precommit
hooks to fix any PEP8 issues etc. not enforced upstream).
Oh sorry! I misunderstood, thank you for the example @ConorMacBride. |
I think this script will fail in 2 cases (maybe more):
edit: I don't know much about release of a package, but If |
I don't think we have to worry about that.
This might be an issue.
What does |
This command will download the For example, |
Co-authored-by: Conor MacBride <[email protected]>
If we have a list of files that we need to extract, we can do this in the same function, but I need to figure out how we going to rename the files.
Something like this: PACKAGES = {
"appdirs": ["ActiveState", "appdirs", ["appdirs.py", "LICENSE.txt" ],
} Otherwise, without any change in the current function, we can make a new dictionary of LICENSE and call it once again? (But this will repeat downloading, extracting, deleting) |
We just rename it to |
Adding this does the work without changing the function, does this looks good? LICENSES = {
"appdirs_license.txt": ["ActiveState", "appdirs", "LICENSE.txt"],
"distro_license.rst": ["python-distro", "distro", "LICENSE"],
"inflect_license.txt": ["jaraco", "inflect", "LICENSE"],
"parse_license.txt": ["r1chardj0n3s", "parse", "LICENSE"],
}
for package, (user, repo, src) in LICENSES.items():
download_github_file(user, repo, src, SUNPY_EXTERN_DIR / package) |
Might need to update the dictionary keys to be |
Just seeing your new comment now. I think the separate |
But wont it download the archive twice? |
Actually, we can add PACKAGES = {
"appdirs.py": ["ActiveState", "appdirs", "appdirs.py"],
"distro.py": ["python-distro", "distro", "src/distro/distro.py"],
"inflect.py": ["jaraco", "inflect", "inflect/__init__.py"],
"parse.py": ["r1chardj0n3s", "parse", "parse.py"],
} and then for package, (user, repo, src) in PACKAGES.items():
download_github_file(user, repo, src, SUNPY_EXTERN_DIR / package) If we have the |
Oh! We don't have to download the whole repo! We should be able to just download the single file: Then we can keep |
Nice, no more zips edit: Sorry, I missed this, all these days downloading and extracting zips. But, I wonder, if this endpoint is not in the documentation how do you find it? |
In GitHub if you navigate to a file with a particular tag selected e.g. https://github.com/sunpy/sunpy/blob/v4.0.0/setup.py you can see this URL by clicking the "Raw" button. I think we should be able to rely on this? I have seen this type of URL used directly before. What do you think @nabobalis? |
Actually, that URL is documented so this should be fine. https://docs.github.com/en/repositories/creating-and-managing-repositories/about-repositories#text-limits |
Sounds good |
We get bytes as a response, Should I write the byte in the required file? |
Sure. |
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.
Seems sane to me. Thanks!
SQUASH MERGE |
Thanks for the PR @akash5100 |
PR Description
This PR is an attempt to close #6094
This PR will add a script in the
sunpy/tools
that will be used to update vendor code automatically, by the person doing a release. Executing this script will update all python files insunpy/sunpy/extern
.