Skip to content

use julia_version Pkg.add kwarg rather than specifying it through ctx #416

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
32 changes: 18 additions & 14 deletions src/Prefix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -597,20 +597,25 @@ function get_addable_spec(name::AbstractString, version::VersionNumber;
uuid=uuid,
#version=version,
tree_hash=tree_hash_sha1,
repo=Pkg.Types.GitRepo(rev=git_commit_sha, source=valid_url),
rev=git_commit_sha,
url=valid_url,
Comment on lines -600 to +601
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifying repo directly isn't compatible with the public Pkg.add API as Pkg.handle_package_input! doesn't expect it to exist, instead constructs it from rev and url etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved handling JuliaLang/Pkg.jl#4170

)
end

# Helper function to install packages also in Julia v1.8
function Pkg_add(args...; kwargs...)
@static if VERSION < v"1.8.0"
Pkg.add(args...; kwargs...)
else
try
Pkg.respect_sysimage_versions(false)
# we don't want to precompile packages during installation
# auto-precompilation also calls `Pkg.instantiate` which will warn about non-VERSION `julia_version` values
withenv("JULIA_PKG_PRECOMPILE_AUTO" => "false") do
@static if VERSION < v"1.8.0"
Pkg.add(args...; kwargs...)
finally
Pkg.respect_sysimage_versions(true)
else
try
Pkg.respect_sysimage_versions(false)
Pkg.add(args...; kwargs...)
finally
Pkg.respect_sysimage_versions(true)
end
end
end
end
Expand Down Expand Up @@ -669,18 +674,16 @@ function setup_dependencies(prefix::Prefix,
deps_project = joinpath(prefix, triplet(platform), ".project")
Pkg.activate(deps_project) do
# Update registry first, in case the jll packages we're looking for have just been registered/updated
ctx = Pkg.Types.Context(;julia_version)
outs = verbose ? stdout : devnull
update_registry(outs)

# Add all dependencies. Note: Pkg.add(ctx, deps) modifies in-place `deps` without
# notice. We need to `deepcopy` the argument to prevent it from modying our
# dependencies from under our feet: <https://github.com/JuliaLang/Pkg.jl/issues/3112>.
Pkg_add(ctx, deepcopy(dependencies); platform=platform, io=outs)
# Add all dependencies.
Pkg_add(dependencies; platform=platform, io=outs, julia_version=julia_version)

# Ony Julia v1.6, `Pkg.add()` doesn't mutate `dependencies`, so we can't use the `UUID`
# that was found during resolution there. Instead, we'll make use of `ctx.env` to figure
# out the UUIDs of all our packages.
ctx = Pkg.Types.Context()
dependency_uuids = Set([uuid for (uuid, pkg) in ctx.env.manifest if pkg.name ∈ dependencies_names])

# Some JLLs are also standard libraries that may be present in the manifest because
Expand Down Expand Up @@ -718,7 +721,8 @@ function setup_dependencies(prefix::Prefix,

# Re-install stdlib dependencies, but this time with `julia_version = nothing`
if !isempty(stdlib_pkgspecs)
Pkg_add(ctx, stdlib_pkgspecs; io=outs, julia_version=nothing)
# TODO: shouldn't this take platform?
Pkg_add(stdlib_pkgspecs; io=outs, julia_version=nothing)
end

# Load their Artifacts.toml files
Expand Down
6 changes: 2 additions & 4 deletions test/dependencies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,8 @@ end
uuid="86de99a1-58d6-5da7-8064-bd56ce2e322c",
tree_hash=Base.SHA1("83481d62501cf2ef22bed745dbcedc4e75fa6e95"),
version=PKG_VERSIONS.VersionSpec("*"),
repo=Pkg.Types.GitRepo(
source="https://github.com/JuliaBinaryWrappers/LLVM_jll.jl.git",
rev="2772761b330d51146ace3125b26acdad0df4f30f",
),
url="https://github.com/JuliaBinaryWrappers/LLVM_jll.jl.git",
rev="2772761b330d51146ace3125b26acdad0df4f30f",
)

with_temp_project() do dir
Expand Down