Skip to content

Commit f411224

Browse files
committed
Downloader for packages in the General registry.
This is a hacky script to download the latest version of all packages registered in the General registry, for testing the parser.
1 parent d335c65 commit f411224

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tools/registry_download.jl

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Hacky script to download the latest version of all packages registered in the
2+
# General registry for testing the parser.
3+
#
4+
# This uses internal Pkg APIs and seems to work on Julia 1.7
5+
6+
using Pkg
7+
using Downloads
8+
9+
registry = only(filter(r->r.name == "General", Pkg.Registry.reachable_registries()))
10+
11+
packages = []
12+
13+
for (uuid,pkg) in registry
14+
versions = collect(Pkg.Registry.registry_info(pkg).version_info)
15+
latest_ver, ver_info = last(sort(versions, by=first))
16+
if ver_info.yanked
17+
continue
18+
end
19+
20+
push!(packages, (; uuid, pkg.name, version=latest_ver, ver_info.git_tree_sha1))
21+
22+
end
23+
24+
server = Pkg.pkg_server()
25+
output_dir = "pkgs"
26+
mkpath(output_dir)
27+
28+
asyncmap(packages, ntasks=5) do pkg
29+
url = "$server/package/$(pkg.uuid)/$(pkg.git_tree_sha1)"
30+
outfile_path = joinpath(output_dir, "$(pkg.name)_$(pkg.version).tgz")
31+
if isfile(outfile_path)
32+
@info "Skipping package" pkg
33+
return outfile_path
34+
else
35+
@info "Download package" url outfile_path
36+
for i=1:5
37+
try
38+
Downloads.download(url, outfile_path)
39+
break
40+
catch
41+
@error "Error downloading" pkg exception=current_exceptions()
42+
end
43+
sleep(i)
44+
end
45+
end
46+
end

0 commit comments

Comments
 (0)