Skip to content

Commit

Permalink
Merge pull request #2628 from JuliaLang/kc/1.6
Browse files Browse the repository at this point in the history
Backports for 1.6, take 2.
  • Loading branch information
KristofferC authored Jun 29, 2021
2 parents 919cc28 + 891e76a commit fcb635b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
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

0 comments on commit fcb635b

Please sign in to comment.