Skip to content

Backports for 1.6, take 2. #2628

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

Merged
merged 4 commits into from
Jun 29, 2021
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
6 changes: 3 additions & 3 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ end
instantiate(; kwargs...) = instantiate(Context(); kwargs...)
function instantiate(ctx::Context; manifest::Union{Bool, Nothing}=nothing,
update_registry::Bool=true, verbose::Bool=false,
platform::AbstractPlatform=HostPlatform(), allow_autoprecomp::Bool=true, kwargs...)
platform::AbstractPlatform=HostPlatform(), allow_build::Bool=true, allow_autoprecomp::Bool=true, kwargs...)
Context!(ctx; kwargs...)
if !isfile(ctx.env.project_file) && isfile(ctx.env.manifest_file)
_manifest = Pkg.Types.read_manifest(ctx.env.manifest_file)
Expand Down Expand Up @@ -1411,7 +1411,7 @@ function instantiate(ctx::Context; manifest::Union{Bool, Nothing}=nothing,
end
Operations.download_artifacts(ctx, art_pkgs; platform, verbose, io=ctx.io)
# Run build scripts
Operations.build_versions(ctx, union(UUID[pkg.uuid for pkg in new_apply], new_git); verbose)
allow_build && Operations.build_versions(ctx, union(UUID[pkg.uuid for pkg in new_apply], new_git); verbose)

allow_autoprecomp && Pkg._auto_precompile(ctx)
end
Expand Down Expand Up @@ -1536,7 +1536,7 @@ function add_snapshot_to_undo(env=nothing)
UndoState()
end
# Is the current state the same as the previous one, do nothing
if !isempty(state.entries) && env.project == env.original_project && env.manifest == env.original_manifest
if !isempty(state.entries) && env.project == env.original_project && env.manifest.deps == env.original_manifest.deps
return
end
snapshot = UndoSnapshot(now(), env.project, env.manifest)
Expand Down
5 changes: 4 additions & 1 deletion src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,13 @@ end
function resolve_versions!(ctx::Context, pkgs::Vector{PackageSpec})
# compatibility
if ctx.julia_version !== nothing
ctx.env.manifest.julia_version = ctx.julia_version
v = intersect(ctx.julia_version, project_compatibility(ctx, "julia"))
if isempty(v)
@warn "julia version requirement for project not satisfied" _module=nothing _file=nothing
end
else
ctx.env.manifest.julia_version = VERSION
end
names = Dict{UUID, String}(uuid => stdlib for (uuid, stdlib) in stdlibs())
# recursive search for packages which are tracking a path
Expand Down Expand Up @@ -900,7 +903,7 @@ end

function build(ctx::Context, pkgs::Vector{PackageSpec}, verbose::Bool)
if any_package_not_installed(ctx) || !isfile(ctx.env.manifest_file)
Pkg.instantiate(ctx)
Pkg.instantiate(ctx, allow_build=false, allow_autoprecomp=false)
end
uuids = UUID[]
_get_deps!(ctx, pkgs, uuids)
Expand Down
2 changes: 1 addition & 1 deletion src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ Base.:(==)(t1::PackageEntry, t2::PackageEntry) = t1.name == t2.name &&
Base.hash(x::PackageEntry, h::UInt) = foldr(hash, [x.name, x.version, x.path, x.pinned, x.repo, x.tree_hash, x.deps], init=h) # omits `other`

Base.@kwdef mutable struct Manifest
julia_version::Union{Nothing,VersionNumber} = Base.VERSION
julia_version::Union{Nothing,VersionNumber} = nothing # only set to VERSION when resolving
manifest_format::VersionNumber = v"1.0.0" # default to older flat format
deps::Dict{UUID,PackageEntry} = Dict{UUID,PackageEntry}()
other::Dict{String,Any} = Dict{String,Any}()
Expand Down
12 changes: 7 additions & 5 deletions src/manifest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function validate_manifest(julia_version::Union{Nothing,VersionNumber}, manifest
end

function Manifest(raw::Dict, f_or_io::Union{String, IO})::Manifest
julia_version = raw["julia_version"] == "nothing" ? nothing : VersionNumber(raw["julia_version"])
julia_version = haskey(raw, "julia_version") ? VersionNumber(raw["julia_version"]) : nothing
manifest_format = VersionNumber(raw["manifest_format"])
if !in(manifest_format.major, 1:2)
if f_or_io isa IO
Expand Down Expand Up @@ -203,16 +203,16 @@ function read_manifest(f_or_io::Union{String,IO})
pkgerror("Could not parse manifest: ", sprint(showerror, raw))
end
if is_v1_format_manifest(raw)
raw = convert_flat_format_manifest(raw)
raw = convert_v1_format_manifest(raw)
end
return Manifest(raw, f_or_io)
end

function convert_flat_format_manifest(old_raw_manifest::Dict)
function convert_v1_format_manifest(old_raw_manifest::Dict)
new_raw_manifest = Dict{String, Any}(
"deps" => old_raw_manifest,
"julia_version" => "nothing", # must be a string here to match raw dict
"manifest_format" => "1.0.0" # must be a string here to match raw dict
# don't set julia_version as it is unknown in old manifests
)
return new_raw_manifest
end
Expand All @@ -239,7 +239,9 @@ function destructure(manifest::Manifest)::Dict
raw = Dict{String,Vector{Dict{String,Any}}}()
elseif manifest.manifest_format.major == 2
raw = Dict{String,Any}()
raw["julia_version"] = manifest.julia_version
if !isnothing(manifest.julia_version) # don't write julia_version if nothing
raw["julia_version"] = manifest.julia_version
end
raw["manifest_format"] = string(manifest.manifest_format.major, ".", manifest.manifest_format.minor)
raw["deps"] = Dict{String,Vector{Dict{String,Any}}}()
for (k, v) in manifest.other
Expand Down