@@ -936,15 +936,23 @@ function download_artifacts(ctx::Context;
936936 env = ctx. env
937937 io = ctx. io
938938 fancyprint = can_fancyprint (io)
939- pkg_roots = String[]
939+ pkg_info = Tuple{ String, Union{Base . UUID, Nothing}} []
940940 for (uuid, pkg) in env. manifest
941941 pkg = manifest_info (env. manifest, uuid)
942942 pkg_root = source_path (env. manifest_file, pkg, julia_version)
943- pkg_root === nothing || push! (pkg_roots, pkg_root)
943+ pkg_root === nothing || push! (pkg_info, ( pkg_root, uuid) )
944944 end
945- push! (pkg_roots, dirname (env. project_file))
945+ push! (pkg_info, ( dirname (env. project_file), env . pkg != = nothing ? env . pkg . uuid : nothing ))
946946 download_jobs = Dict {SHA1, Function} ()
947947
948+ # Check what registries the current pkg server tracks
949+ # Disable if precompiling to not access internet
950+ server_registry_info = if Base. JLOptions (). incremental == 0
951+ Registry. pkg_server_registry_info ()
952+ else
953+ nothing
954+ end
955+
948956 print_lock = Base. ReentrantLock () # for non-fancyprint printing
949957
950958 download_states = Dict {SHA1, DownloadState} ()
@@ -958,12 +966,17 @@ function download_artifacts(ctx::Context;
958966 ansi_enablecursor = " \e [?25h"
959967 ansi_disablecursor = " \e [?25l"
960968
961- all_collected_artifacts = reduce (vcat, map (pkg_root -> collect_artifacts (pkg_root; platform, include_lazy), pkg_roots))
962- used_artifact_tomls = Set {String} (map (first, all_collected_artifacts))
963- longest_name_length = maximum (all_collected_artifacts; init= 0 ) do (artifacts_toml, artifacts)
964- maximum (textwidth, keys (artifacts); init= 0 )
969+ all_collected_artifacts = reduce (
970+ vcat, map (
971+ ((pkg_root, pkg_uuid),) ->
972+ map (ca -> (ca[1 ], ca[2 ], pkg_uuid), collect_artifacts (pkg_root; platform, include_lazy)), pkg_info
973+ )
974+ )
975+ used_artifact_tomls = Set {String} (map (ca -> ca[1 ], all_collected_artifacts))
976+ longest_name_length = maximum (all_collected_artifacts; init = 0 ) do (artifacts_toml, artifacts, pkg_uuid)
977+ maximum (textwidth, keys (artifacts); init = 0 )
965978 end
966- for (artifacts_toml, artifacts) in all_collected_artifacts
979+ for (artifacts_toml, artifacts, pkg_uuid ) in all_collected_artifacts
967980 # For each Artifacts.toml, install each artifact we've collected from it
968981 for name in keys (artifacts)
969982 local rname = rpad (name, longest_name_length)
@@ -981,9 +994,12 @@ function download_artifacts(ctx::Context;
981994 dstate. status_update_time = t
982995 end
983996 end
997+ # Check if the current package is eligible for PkgServer artifact downloads
998+ local pkg_server_eligible = pkg_uuid != = nothing && Registry. is_pkg_in_pkgserver_registry (pkg_uuid, server_registry_info, ctx. registries)
999+
9841000 # returns a string if exists, or function that downloads the artifact if not
9851001 local ret = ensure_artifact_installed (name, artifacts[name], artifacts_toml;
986- verbose, quiet_download= ! (usable_io (io)), io, progress)
1002+ pkg_server_eligible, verbose, quiet_download= ! (usable_io (io)), io, progress)
9871003 if ret isa Function
9881004 download_states[hash] = dstate
9891005 download_jobs[hash] =
@@ -1175,17 +1191,10 @@ function download_source(ctx::Context, pkgs; readonly=true)
11751191 archive_urls = Pair{String,Bool}[]
11761192 # Check if the current package is available in one of the registries being tracked by the pkg server
11771193 # In that case, download from the package server
1178- if server_registry_info != = nothing
1194+ if Registry . is_pkg_in_pkgserver_registry (pkg . uuid, server_registry_info, ctx . registries)
11791195 server, registry_info = server_registry_info
1180- for reg in ctx. registries
1181- if reg. uuid in keys (registry_info)
1182- if haskey (reg, pkg. uuid)
1183- url = " $server /package/$(pkg. uuid) /$(pkg. tree_hash) "
1184- push! (archive_urls, url => true )
1185- break
1186- end
1187- end
1188- end
1196+ url = " $server /package/$(pkg. uuid) /$(pkg. tree_hash) "
1197+ push! (archive_urls, url => true )
11891198 end
11901199 for repo_url in urls
11911200 url = get_archive_url_for_version (repo_url, pkg. tree_hash)
0 commit comments