Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1358,9 +1358,9 @@ function instantiate(
end

# Install all packages
new_apply = Operations.download_source(ctx)
new_apply = Operations.download_source(ctx, pkgs)
# Install all artifacts
Operations.download_artifacts(ctx; platform, verbose)
Operations.download_artifacts(ctx, pkgs; platform, verbose)
# Run build scripts
allow_build && Operations.build_versions(ctx, union(new_apply, new_git); verbose = verbose)

Expand Down
15 changes: 14 additions & 1 deletion src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ mutable struct DownloadState
end

function download_artifacts(
ctx::Context;
ctx::Context, pkgs;
platform::AbstractPlatform = HostPlatform(),
julia_version = VERSION,
verbose::Bool = false,
Expand All @@ -973,7 +973,9 @@ function download_artifacts(
io = ctx.io
fancyprint = can_fancyprint(io)
pkg_info = Tuple{String, Union{Base.UUID, Nothing}}[]
pkg_uuids = Set(pkg.uuid for pkg in pkgs)
for (uuid, pkg) in env.manifest
uuid in pkg_uuids || continue
pkg = manifest_info(env.manifest, uuid)
pkg_root = source_path(env.manifest_file, pkg, julia_version)
pkg_root === nothing || push!(pkg_info, (pkg_root, uuid))
Expand Down Expand Up @@ -1142,6 +1144,17 @@ function download_artifacts(
return write_env_usage(used_artifact_tomls, "artifact_usage.toml")
end

function download_artifacts(
ctx::Context;
platform::AbstractPlatform = HostPlatform(),
julia_version = VERSION,
verbose::Bool = false,
io::IO = stderr_f(),
include_lazy::Bool = false
)
return download_artifacts(ctx, values(ctx.env.manifest); platform, julia_version, verbose, io, include_lazy)
end

function check_artifacts_downloaded(pkg_root::String; platform::AbstractPlatform = HostPlatform())
for (artifacts_toml, artifacts) in collect_artifacts(pkg_root; platform)
for name in keys(artifacts)
Expand Down
56 changes: 56 additions & 0 deletions test/workspaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,60 @@ end
end
end

@testset "selective workspace instantiate" begin
mktempdir() do dir
path = copy_test_package(dir, "WorkspaceTestInstantiate")
cd(path) do
with_current_env() do
# Add Crayons dependency to root project to differentiate from subproject's Example
Pkg.activate(".")
Pkg.add("Crayons")

# The test subproject already has Example dependency
# Workspace structure is already set up in the test package

# Resolve to create full manifest
Pkg.resolve()
@test isfile("Manifest.toml")

# Verify manifest contains both dependencies
manifest = Pkg.Types.read_manifest("Manifest.toml")
example_uuid = UUID("7876af07-990d-54b4-ab0e-23690620f79a") # From test subproject
crayons_uuid = UUID("a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f") # From root project
@test haskey(manifest.deps, example_uuid)
@test haskey(manifest.deps, crayons_uuid)

# Clear package installations to test selective download
depot_path = first(Pkg.depots())
packages_dir = joinpath(depot_path, "packages")
for pkg_name in ["Example", "Crayons"]
pkg_dir = joinpath(packages_dir, pkg_name)
rm(pkg_dir, recursive = true, force = true)
end

# Test workspace=false only downloads root project deps (Crayons)
Pkg.instantiate(workspace = false)
example_installed = isdir(joinpath(packages_dir, "Example"))
crayons_installed = isdir(joinpath(packages_dir, "Crayons"))
@test crayons_installed # Should be installed (root project dependency)
@test !example_installed # Should not be installed with workspace=false

# Clear and test workspace=true downloads all deps
rm(joinpath(packages_dir, "Crayons"), recursive = true, force = true)
Pkg.instantiate(workspace = true)
example_installed = isdir(joinpath(packages_dir, "Example"))
crayons_installed = isdir(joinpath(packages_dir, "Crayons"))
@test crayons_installed # Should be installed
@test example_installed # Should be installed with workspace=true

# Test is_instantiated behavior
rm(joinpath(packages_dir, "Example"), recursive = true, force = true)
ctx = Pkg.Types.Context()
@test Pkg.Operations.is_instantiated(ctx.env, false) # Root project complete (has Crayons)
@test !Pkg.Operations.is_instantiated(ctx.env, true) # Workspace incomplete (missing Example)
end
end
end
end

end # module
Loading