Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make add and dev on a package remove it from the set of weak dependencies #3865

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,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])
source_path, source_repo = get_path_repo(ctx.env.project, pkg.name)
Expand Down Expand Up @@ -1544,6 +1545,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
Expand Down Expand Up @@ -2402,6 +2404,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)
Expand All @@ -2412,10 +2415,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
Expand Down
9 changes: 9 additions & 0 deletions test/extensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,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
Loading