rye icon indicating copy to clipboard operation
rye copied to clipboard

Refactor find-downloads.py

Open j178 opened this issue 1 year ago • 1 comments

Changes in this PR

  • Removed the old rye/find-downloads.py after #644.
  • Instroduces a Finder base class, and implement logic in CPythonFinder and PyPyFinder subclasses.
  • Instead of fetching xxx.sha256 for each file, fetch a single SHA256SUMS file which contains checksums for all files in the release.

Before:

❯ time rye run find-downloads > rye/src/downloads.inc
Rye download creator started.
Fetching indygreg downloads...
Fetching page 1
Fetching page 2
Fetching page 3
fetching 25 sha256s: 0/356 completed
fetching 25 sha256s: 25/356 completed
fetching 25 sha256s: 50/356 completed
fetching 25 sha256s: 75/356 completed
fetching 25 sha256s: 100/356 completed
fetching 25 sha256s: 125/356 completed
fetching 25 sha256s: 150/356 completed
fetching 25 sha256s: 175/356 completed
fetching 25 sha256s: 200/356 completed
fetching 25 sha256s: 225/356 completed
fetching 25 sha256s: 250/356 completed
fetching 25 sha256s: 275/356 completed
fetching 25 sha256s: 300/356 completed
fetching 25 sha256s: 325/356 completed
fetching 25 sha256s: 350/356 completed
Generating code and fetching sha256 of all cpython downloads.
This can be slow......

________________________________________________________
Executed in   45.78 secs    fish           external
   usr time    3.20 secs    0.15 millis    3.20 secs
   sys time    0.43 secs    1.29 millis    0.43 secs

After:

❯ time rye run find-downloads > rye/src/downloads.inc
Fetching all Python downloads and generating code.
Finding cpython downloads...
Fetching indygreg release page 1
Fetching indygreg release page 2
Fetching indygreg release page 3
Fetching indygreg checksums: 0/29
Fetching indygreg checksums: 10/29
Fetching indygreg checksums: 20/29
Finding pypy downloads...

________________________________________________________
Executed in    8.39 secs      fish           external
   usr time  575.98 millis  136.00 micros  575.85 millis
   sys time  124.18 millis  963.00 micros  123.22 millis

Planned for Future PRs

  • [ ] Regenerate the latest downloads.inc #683
  • [ ] Implement the PyPyFinder #683
  • [ ] Add an GitHub Action to run find-downloads.py daily and create PR automatically
  • [ ] ~Add more Python implementaion build, like IronPython/Jython/Anaconda/MiniAnaconda?~

Thanks @dsp for the previous work. Your review of these changes would be greatly appreciated!

j178 avatar Feb 18 '24 06:02 j178

I'm watching this as we copied the script over to uv with some small changes (https://github.com/astral-sh/uv/blob/b317e6fc56d3f03d0a68a45784aac8936c2fbc9a/scripts/bootstrap/fetch-version-metadata.py)

We'll probably just copy over the latest one once we actually have Python toolchain management though.

zanieb avatar Feb 18 '24 21:02 zanieb

@dsp Thanks for your review! I have fixed the test, and reorganized the commits to be more meaningful, hope it make the review easier.

j178 avatar Feb 19 '24 03:02 j178

Looks good to me. Thank you for the changes. It's a really nice improvement.

/cc @mitsuhiko

dsp avatar Feb 19 '24 09:02 dsp

lgtm!

mitsuhiko avatar Feb 19 '24 22:02 mitsuhiko