@@ -222,21 +222,42 @@ end
222222# This has to be done after the packages have been downloaded
223223# since we need access to the Project file to read the information
224224# about extensions
225- function fixups_from_projectfile! (env:: EnvCache )
225+ function fixups_from_projectfile! (ctx:: Context )
226+ env = ctx. env
226227 for pkg in values (env. manifest)
227- # isfile_casesenstive within locate_project_file used to error on Windows if given a
228- # relative path so abspath it to be extra safe https://github.com/JuliaLang/julia/pull/55220
229- project_file = Base . locate_project_file ( abspath ( source_path (env . manifest_file, pkg)))
230- if project_file isa String && isfile (project_file )
231- p = Types . read_project (project_file)
232- pkg. weakdeps = p. weakdeps
233- pkg. exts = p. exts
234- pkg. entryfile = p. entryfile
235- for (name, _) in p . weakdeps
228+ if ctx . julia_version != = VERSION && is_stdlib (pkg . uuid, ctx . julia_version)
229+ # Special handling for non-current julia_version resolving given the source for historical stdlibs
230+ # isn't available at this stage as Pkg thinks it should not be needed, so rely on STDLIBS_BY_VERSION
231+ stdlibs = Types . get_last_stdlibs (ctx . julia_version )
232+ p = stdlibs[pkg . uuid]
233+ pkg. weakdeps = Dict {String, Base.UUID} (stdlibs[uuid] . name => uuid for uuid in p. weakdeps)
234+ # pkg.exts = p.exts # TODO : STDLIBS_BY_VERSION doesn't record this
235+ # pkg.entryfile = p.entryfile # TODO : STDLIBS_BY_VERSION doesn't record this
236+ for (name, _) in pkg . weakdeps
236237 if ! haskey (p. deps, name)
237238 delete! (pkg. deps, name)
238239 end
239240 end
241+ else
242+ # normal mode based on project files.
243+ # isfile_casesenstive within locate_project_file used to error on Windows if given a
244+ # relative path so abspath it to be extra safe https://github.com/JuliaLang/julia/pull/55220
245+ sourcepath = source_path (env. manifest_file, pkg)
246+ if sourcepath === nothing
247+ pkgerror (" could not find source path for package $(pkg. name) based on manifest $(env. manifest_file) " )
248+ end
249+ project_file = Base. locate_project_file (abspath (sourcepath))
250+ if project_file isa String && isfile (project_file)
251+ p = Types. read_project (project_file)
252+ pkg. weakdeps = p. weakdeps
253+ pkg. exts = p. exts
254+ pkg. entryfile = p. entryfile
255+ for (name, _) in p. weakdeps
256+ if ! haskey (p. deps, name)
257+ delete! (pkg. deps, name)
258+ end
259+ end
260+ end
240261 end
241262 end
242263 prune_manifest (env)
@@ -337,18 +358,22 @@ function collect_developed!(env::EnvCache, pkg::PackageSpec, developed::Vector{P
337358 source = project_rel_path (env, source_path (env. manifest_file, pkg))
338359 source_env = EnvCache (projectfile_path (source))
339360 pkgs = load_project_deps (source_env. project, source_env. project_file, source_env. manifest, source_env. manifest_file)
340- for pkg in filter (is_tracking_path, pkgs)
361+ for pkg in pkgs
341362 if any (x -> x. uuid == pkg. uuid, developed)
342363 continue
343364 end
344- # normalize path
345- # TODO : If path is collected from project, it is relative to the project file
346- # otherwise relative to manifest file....
347- pkg. path = Types. relative_project_path (env. manifest_file,
348- project_rel_path (source_env,
349- source_path (source_env. manifest_file, pkg)))
350- push! (developed, pkg)
351- collect_developed! (env, pkg, developed)
365+ if is_tracking_path (pkg)
366+ # normalize path
367+ # TODO : If path is collected from project, it is relative to the project file
368+ # otherwise relative to manifest file....
369+ pkg. path = Types. relative_project_path (env. manifest_file,
370+ project_rel_path (source_env,
371+ source_path (source_env. manifest_file, pkg)))
372+ push! (developed, pkg)
373+ collect_developed! (env, pkg, developed)
374+ elseif is_tracking_repo (pkg)
375+ push! (developed, pkg)
376+ end
352377 end
353378end
354379
@@ -1537,6 +1562,12 @@ function is_all_registered(registries::Vector{Registry.RegistryInstance}, pkgs::
15371562end
15381563
15391564function check_registered (registries:: Vector{Registry.RegistryInstance} , pkgs:: Vector{PackageSpec} )
1565+ if isempty (registries) && ! isempty (pkgs)
1566+ registry_pkgs = filter (tracking_registered_version, pkgs)
1567+ if ! isempty (registry_pkgs)
1568+ pkgerror (" no registries have been installed. Cannot resolve the following packages:\n $(join (map (pkg -> " " * err_rep (pkg), registry_pkgs), " \n " )) " )
1569+ end
1570+ end
15401571 pkg = is_all_registered (registries, pkgs)
15411572 if pkg isa PackageSpec
15421573 pkgerror (" expected package $(err_rep (pkg)) to be registered" )
@@ -1658,7 +1689,7 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}, new_git=Set{UUID}();
16581689 man_pkgs, deps_map = _resolve (ctx. io, ctx. env, ctx. registries, pkgs, preserve, ctx. julia_version)
16591690 update_manifest! (ctx. env, man_pkgs, deps_map, ctx. julia_version)
16601691 new_apply = download_source (ctx)
1661- fixups_from_projectfile! (ctx. env )
1692+ fixups_from_projectfile! (ctx)
16621693
16631694 # After downloading resolutionary packages, search for (Julia)Artifacts.toml files
16641695 # and ensure they are all downloaded and unpacked as well:
@@ -1705,7 +1736,7 @@ function develop(ctx::Context, pkgs::Vector{PackageSpec}, new_git::Set{UUID};
17051736 pkgs, deps_map = _resolve (ctx. io, ctx. env, ctx. registries, pkgs, preserve, ctx. julia_version)
17061737 update_manifest! (ctx. env, pkgs, deps_map, ctx. julia_version)
17071738 new_apply = download_source (ctx)
1708- fixups_from_projectfile! (ctx. env )
1739+ fixups_from_projectfile! (ctx)
17091740 download_artifacts (ctx; platform= platform, julia_version= ctx. julia_version)
17101741 write_env (ctx. env) # write env before building
17111742 show_update (ctx. env, ctx. registries; io= ctx. io)
@@ -1720,7 +1751,9 @@ function up_load_versions!(ctx::Context, pkg::PackageSpec, entry::PackageEntry,
17201751 entry. version != = nothing || return false # no version to set
17211752 if entry. pinned || level == UPLEVEL_FIXED
17221753 pkg. version = entry. version
1723- pkg. tree_hash = entry. tree_hash
1754+ if pkg. path === nothing
1755+ pkg. tree_hash = entry. tree_hash
1756+ end
17241757 elseif entry. repo. source != = nothing || source_repo. source != = nothing # repo packages have a version but are treated specially
17251758 if source_repo. source != = nothing
17261759 pkg. repo = source_repo
@@ -1846,7 +1879,7 @@ function up(ctx::Context, pkgs::Vector{PackageSpec}, level::UpgradeLevel;
18461879 end
18471880 update_manifest! (ctx. env, pkgs, deps_map, ctx. julia_version)
18481881 new_apply = download_source (ctx)
1849- fixups_from_projectfile! (ctx. env )
1882+ fixups_from_projectfile! (ctx)
18501883 download_artifacts (ctx, julia_version= ctx. julia_version)
18511884 write_env (ctx. env; skip_writing_project) # write env before building
18521885 show_update (ctx. env, ctx. registries; io= ctx. io, hidden_upgrades_info = true )
@@ -1892,7 +1925,7 @@ function pin(ctx::Context, pkgs::Vector{PackageSpec})
18921925
18931926 update_manifest! (ctx. env, pkgs, deps_map, ctx. julia_version)
18941927 new = download_source (ctx)
1895- fixups_from_projectfile! (ctx. env )
1928+ fixups_from_projectfile! (ctx)
18961929 download_artifacts (ctx; julia_version= ctx. julia_version)
18971930 write_env (ctx. env) # write env before building
18981931 show_update (ctx. env, ctx. registries; io= ctx. io)
@@ -1940,7 +1973,7 @@ function free(ctx::Context, pkgs::Vector{PackageSpec}; err_if_free=true)
19401973
19411974 update_manifest! (ctx. env, pkgs, deps_map, ctx. julia_version)
19421975 new = download_source (ctx)
1943- fixups_from_projectfile! (ctx. env )
1976+ fixups_from_projectfile! (ctx)
19441977 download_artifacts (ctx)
19451978 write_env (ctx. env) # write env before building
19461979 show_update (ctx. env, ctx. registries; io= ctx. io)
@@ -2553,8 +2586,7 @@ end
25532586
25542587function is_package_downloaded (manifest_file:: String , pkg:: PackageSpec ; platform= HostPlatform ())
25552588 sourcepath = source_path (manifest_file, pkg)
2556- identifier = pkg. name != = nothing ? pkg. name : pkg. uuid
2557- (sourcepath === nothing ) && pkgerror (" Could not locate the source code for the $(identifier) package. Are you trying to use a manifest generated by a different version of Julia?" )
2589+ sourcepath === nothing && return false
25582590 isdir (sourcepath) || return false
25592591 check_artifacts_downloaded (sourcepath; platform) || return false
25602592 return true
0 commit comments