From 35358a42eadb00ea4421ad422f64dedcebf69e7b Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 29 Oct 2024 16:57:29 -0400 Subject: [PATCH 1/3] strip out tree_hash for stdlibs that have have been freed in newer julia versions (#4062) * strip out tree_hash for stdlibs that have have been freed in newer julia versions * Update src/Operations.jl (cherry picked from commit 9f8e11a4c0efb3b68a1e25a33f372f398c89cd66) --- src/Operations.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Operations.jl b/src/Operations.jl index 4e9eaed55f..64a7420222 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -189,6 +189,13 @@ end #################### function load_tree_hash!(registries::Vector{Registry.RegistryInstance}, pkg::PackageSpec, julia_version) + if is_stdlib(pkg.uuid, julia_version) && pkg.tree_hash !== nothing + # manifests from newer julia versions might have stdlibs that are upgradable (FORMER_STDLIBS) + # that have tree_hash recorded, which we need to clear for this version where they are not upgradable + # given regular stdlibs don't have tree_hash recorded + pkg.tree_hash = nothing + return pkg + end tracking_registered_version(pkg, julia_version) || return pkg hash = nothing for reg in registries From 691510be6df160691416e1a09b7b29d4ab78537d Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Fri, 22 Mar 2024 20:14:14 +0100 Subject: [PATCH 2/3] collect e.g. weak deps from project even if it is not a package (#3852) * collect e.g. weak deps from project even if it is not a package (cherry picked from commit 9c6356fa9d838388cc308cfedaec6cd38fdf00ba) --- src/Operations.jl | 38 +++++++++---------- src/Types.jl | 2 +- test/extensions.jl | 12 ++++++ .../TestWeakDepProject/Project.toml | 9 +++++ 4 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 test/test_packages/TestWeakDepProject/Project.toml diff --git a/src/Operations.jl b/src/Operations.jl index 64a7420222..da8cdedb96 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -240,19 +240,16 @@ function reset_all_compat!(proj::Project) return nothing end -function collect_project(pkg::PackageSpec, path::String) +function collect_project(pkg::Union{PackageSpec, Nothing}, path::String) deps = PackageSpec[] weakdeps = Set{UUID}() project_file = projectfile_path(path; strict=true) - if project_file === nothing - pkgerror("could not find project file for package $(err_rep(pkg)) at `$path`") - end - project = read_package(project_file) + project = project_file === nothing ? Project() : read_project(project_file) #= # TODO, this should either error or be quiet julia_compat = get_compat(project, "julia") if julia_compat !== nothing && !(VERSION in julia_compat) - println(io, "julia version requirement for package $(err_rep(pkg)) not satisfied") + println(io, "julia version requirement for package at `$path`"") end =# for (name, uuid) in project.deps @@ -264,11 +261,13 @@ function collect_project(pkg::PackageSpec, path::String) push!(deps, PackageSpec(name, uuid, vspec)) push!(weakdeps, uuid) end - if project.version !== nothing - pkg.version = project.version - else - # @warn("project file for $(pkg.name) is missing a `version` entry") - pkg.version = VersionNumber(0) + if pkg !== nothing + if project.version !== nothing + pkg.version = project.version + else + # @warn("project file for $(pkg.name) is missing a `version` entry") + pkg.version = VersionNumber(0) + end end return deps, weakdeps end @@ -306,13 +305,13 @@ end function collect_fixed!(env::EnvCache, pkgs::Vector{PackageSpec}, names::Dict{UUID, String}) deps_map = Dict{UUID,Vector{PackageSpec}}() weak_map = Dict{UUID,Set{UUID}}() - if env.pkg !== nothing - pkg = env.pkg - deps, weakdeps = collect_project(pkg, dirname(env.project_file)) - deps_map[pkg.uuid] = deps - weak_map[pkg.uuid] = weakdeps - names[pkg.uuid] = pkg.name - end + + uuid = Types.project_uuid(env) + deps, weakdeps = collect_project(env.pkg, dirname(env.project_file)) + deps_map[uuid] = deps + weak_map[uuid] = weakdeps + names[uuid] = env.pkg === nothing ? "project" : env.pkg.name + for pkg in pkgs path = project_rel_path(env, source_path(env.manifest_file, pkg)) if !isdir(path) @@ -337,7 +336,8 @@ function collect_fixed!(env::EnvCache, pkgs::Vector{PackageSpec}, names::Dict{UU idx = findfirst(pkg -> pkg.uuid == uuid, pkgs) fix_pkg = pkgs[idx] end - fixed[uuid] = Resolve.Fixed(fix_pkg.version, q, weak_map[uuid]) + fixpkgversion = fix_pkg === nothing ? v"0.0.0" : fix_pkg.version + fixed[uuid] = Resolve.Fixed(fixpkgversion, q, weak_map[uuid]) end return fixed end diff --git a/src/Types.jl b/src/Types.jl index 519bc69b50..2f24f08f10 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -423,7 +423,7 @@ Base.@kwdef mutable struct Context julia_version::Union{VersionNumber,Nothing} = VERSION end -project_uuid(env::EnvCache) = env.pkg === nothing ? nothing : env.pkg.uuid +project_uuid(env::EnvCache) = env.pkg === nothing ? Base.dummy_uuid(env.project_file) : env.pkg.uuid collides_with_project(env::EnvCache, pkg::PackageSpec) = is_project_name(env, pkg.name) || is_project_uuid(env, pkg.uuid) is_project(env::EnvCache, pkg::PackageSpec) = is_project_uuid(env, pkg.uuid) diff --git a/test/extensions.jl b/test/extensions.jl index 1a76757d7d..b0ca325924 100644 --- a/test/extensions.jl +++ b/test/extensions.jl @@ -1,5 +1,6 @@ using .Utils using Test +using UUIDs @testset "weak deps" begin he_root = joinpath(@__DIR__, "test_packages", "ExtensionExamples", "HasExtensions.jl") @@ -78,4 +79,15 @@ using Test @test occursin("HasExtensions", out) @test occursin("HasDepWithExtensions", out) end + + isolate(loaded_depot=false) do + mktempdir() do dir + Pkg.Registry.add("General") + path = joinpath(@__DIR__, "test_packages", "TestWeakDepProject") + cp(path, joinpath(dir, "TestWeakDepProject")) + Pkg.activate(joinpath(dir, "TestWeakDepProject")) + Pkg.resolve() + @test Pkg.dependencies()[UUID("2ab3a3ac-af41-5b50-aa03-7779005ae688")].version == v"0.3.26" + end + end end diff --git a/test/test_packages/TestWeakDepProject/Project.toml b/test/test_packages/TestWeakDepProject/Project.toml new file mode 100644 index 0000000000..c856f60f08 --- /dev/null +++ b/test/test_packages/TestWeakDepProject/Project.toml @@ -0,0 +1,9 @@ +[deps] +ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + +[weakdeps] +LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688" + +[compat] +ForwardDiff = "=0.10.36" +LogExpFunctions = "=0.3.26" From f8ef8013e8cf45bd4c52a95fa7ec462a9abdc952 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Wed, 10 Apr 2024 11:17:16 +0200 Subject: [PATCH 3/3] make `add` and `dev` on a package remove it from the set of weak dependencies (#3865) * make `add` and `dev` on a package remove it from the weakdeps section (cherry picked from commit 88c38b2cd00e93e77c78ab952ffb6a06e6e1828b) --- src/Operations.jl | 15 +++++++++++---- test/extensions.jl | 9 +++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index da8cdedb96..c6415f6886 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1385,6 +1385,7 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}, new_git=Set{UUID}(); assert_can_add(ctx, pkgs) # load manifest data for (i, pkg) in pairs(pkgs) + delete!(ctx.env.project.weakdeps, pkg.name) entry = manifest_info(ctx.env.manifest, pkg.uuid) is_dep = any(uuid -> uuid == pkg.uuid, [uuid for (name, uuid) in ctx.env.project.deps]) pkgs[i] = update_package_add(ctx, pkg, entry, is_dep) @@ -1411,6 +1412,7 @@ function develop(ctx::Context, pkgs::Vector{PackageSpec}, new_git::Set{UUID}; assert_can_add(ctx, pkgs) # no need to look at manifest.. dev will just nuke whatever is there before for pkg in pkgs + delete!(ctx.env.project.weakdeps, pkg.name) ctx.env.project.deps[pkg.name] = pkg.uuid end # resolve & apply package versions @@ -2207,6 +2209,7 @@ function status_ext_info(pkg::PackageSpec, env::EnvCache) manifest = env.manifest manifest_info = get(manifest, pkg.uuid, nothing) manifest_info === nothing && return nothing + depses = manifest_info.deps weakdepses = manifest_info.weakdeps exts = manifest_info.exts if !isempty(weakdepses) && !isempty(exts) @@ -2217,10 +2220,14 @@ function status_ext_info(pkg::PackageSpec, env::EnvCache) # Check if deps are loaded extdeps_info= Tuple{String, Bool}[] for extdep in extdeps - haskey(weakdepses, extdep) || - pkgerror(isnothing(pkg.name) ? "M" : "$(pkg.name) has a m", - "alformed Project.toml, the extension package $extdep is not listed in [weakdeps]") - uuid = weakdepses[extdep] + if !(haskey(weakdepses, extdep) || haskey(depses, extdep)) + pkgerror(isnothing(pkg.name) ? "M" : "$(pkg.name) has a malformed Project.toml, ", + "the extension package $extdep is not listed in [weakdeps] or [deps]") + end + uuid = get(weakdepses, extdep, nothing) + if uuid === nothing + uuid = depses[extdep] + end loaded = haskey(Base.loaded_modules, Base.PkgId(uuid, extdep)) push!(extdeps_info, (extdep, loaded)) end diff --git a/test/extensions.jl b/test/extensions.jl index b0ca325924..271452d571 100644 --- a/test/extensions.jl +++ b/test/extensions.jl @@ -88,6 +88,15 @@ using UUIDs Pkg.activate(joinpath(dir, "TestWeakDepProject")) Pkg.resolve() @test Pkg.dependencies()[UUID("2ab3a3ac-af41-5b50-aa03-7779005ae688")].version == v"0.3.26" + + # Check that explicitly adding a package that is a weak dep removes it from the set of weak deps + ctx = Pkg.Types.Context() + @test "LogExpFunctions" in keys(ctx.env.project.weakdeps) + @test !("LogExpFunctions" in keys(ctx.env.project.deps)) + Pkg.add("LogExpFunctions") + ctx = Pkg.Types.Context() + @test "LogExpFunctions" in keys(ctx.env.project.deps) + @test !("LogExpFunctions" in keys(ctx.env.project.weakdeps)) end end end