Skip to content

Commit fcb635b

Browse files
authored
Merge pull request #2628 from JuliaLang/kc/1.6
Backports for 1.6, take 2.
2 parents 919cc28 + 891e76a commit fcb635b

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

src/API.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ end
13211321
instantiate(; kwargs...) = instantiate(Context(); kwargs...)
13221322
function instantiate(ctx::Context; manifest::Union{Bool, Nothing}=nothing,
13231323
update_registry::Bool=true, verbose::Bool=false,
1324-
platform::AbstractPlatform=HostPlatform(), allow_autoprecomp::Bool=true, kwargs...)
1324+
platform::AbstractPlatform=HostPlatform(), allow_build::Bool=true, allow_autoprecomp::Bool=true, kwargs...)
13251325
Context!(ctx; kwargs...)
13261326
if !isfile(ctx.env.project_file) && isfile(ctx.env.manifest_file)
13271327
_manifest = Pkg.Types.read_manifest(ctx.env.manifest_file)
@@ -1411,7 +1411,7 @@ function instantiate(ctx::Context; manifest::Union{Bool, Nothing}=nothing,
14111411
end
14121412
Operations.download_artifacts(ctx, art_pkgs; platform, verbose, io=ctx.io)
14131413
# Run build scripts
1414-
Operations.build_versions(ctx, union(UUID[pkg.uuid for pkg in new_apply], new_git); verbose)
1414+
allow_build && Operations.build_versions(ctx, union(UUID[pkg.uuid for pkg in new_apply], new_git); verbose)
14151415

14161416
allow_autoprecomp && Pkg._auto_precompile(ctx)
14171417
end
@@ -1536,7 +1536,7 @@ function add_snapshot_to_undo(env=nothing)
15361536
UndoState()
15371537
end
15381538
# Is the current state the same as the previous one, do nothing
1539-
if !isempty(state.entries) && env.project == env.original_project && env.manifest == env.original_manifest
1539+
if !isempty(state.entries) && env.project == env.original_project && env.manifest.deps == env.original_manifest.deps
15401540
return
15411541
end
15421542
snapshot = UndoSnapshot(now(), env.project, env.manifest)

src/Operations.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,13 @@ end
361361
function resolve_versions!(ctx::Context, pkgs::Vector{PackageSpec})
362362
# compatibility
363363
if ctx.julia_version !== nothing
364+
ctx.env.manifest.julia_version = ctx.julia_version
364365
v = intersect(ctx.julia_version, project_compatibility(ctx, "julia"))
365366
if isempty(v)
366367
@warn "julia version requirement for project not satisfied" _module=nothing _file=nothing
367368
end
369+
else
370+
ctx.env.manifest.julia_version = VERSION
368371
end
369372
names = Dict{UUID, String}(uuid => stdlib for (uuid, stdlib) in stdlibs())
370373
# recursive search for packages which are tracking a path
@@ -900,7 +903,7 @@ end
900903

901904
function build(ctx::Context, pkgs::Vector{PackageSpec}, verbose::Bool)
902905
if any_package_not_installed(ctx) || !isfile(ctx.env.manifest_file)
903-
Pkg.instantiate(ctx)
906+
Pkg.instantiate(ctx, allow_build=false, allow_autoprecomp=false)
904907
end
905908
uuids = UUID[]
906909
_get_deps!(ctx, pkgs, uuids)

src/Types.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Base.:(==)(t1::PackageEntry, t2::PackageEntry) = t1.name == t2.name &&
221221
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`
222222

223223
Base.@kwdef mutable struct Manifest
224-
julia_version::Union{Nothing,VersionNumber} = Base.VERSION
224+
julia_version::Union{Nothing,VersionNumber} = nothing # only set to VERSION when resolving
225225
manifest_format::VersionNumber = v"1.0.0" # default to older flat format
226226
deps::Dict{UUID,PackageEntry} = Dict{UUID,PackageEntry}()
227227
other::Dict{String,Any} = Dict{String,Any}()

src/manifest.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function validate_manifest(julia_version::Union{Nothing,VersionNumber}, manifest
129129
end
130130

131131
function Manifest(raw::Dict, f_or_io::Union{String, IO})::Manifest
132-
julia_version = raw["julia_version"] == "nothing" ? nothing : VersionNumber(raw["julia_version"])
132+
julia_version = haskey(raw, "julia_version") ? VersionNumber(raw["julia_version"]) : nothing
133133
manifest_format = VersionNumber(raw["manifest_format"])
134134
if !in(manifest_format.major, 1:2)
135135
if f_or_io isa IO
@@ -203,16 +203,16 @@ function read_manifest(f_or_io::Union{String,IO})
203203
pkgerror("Could not parse manifest: ", sprint(showerror, raw))
204204
end
205205
if is_v1_format_manifest(raw)
206-
raw = convert_flat_format_manifest(raw)
206+
raw = convert_v1_format_manifest(raw)
207207
end
208208
return Manifest(raw, f_or_io)
209209
end
210210

211-
function convert_flat_format_manifest(old_raw_manifest::Dict)
211+
function convert_v1_format_manifest(old_raw_manifest::Dict)
212212
new_raw_manifest = Dict{String, Any}(
213213
"deps" => old_raw_manifest,
214-
"julia_version" => "nothing", # must be a string here to match raw dict
215214
"manifest_format" => "1.0.0" # must be a string here to match raw dict
215+
# don't set julia_version as it is unknown in old manifests
216216
)
217217
return new_raw_manifest
218218
end
@@ -239,7 +239,9 @@ function destructure(manifest::Manifest)::Dict
239239
raw = Dict{String,Vector{Dict{String,Any}}}()
240240
elseif manifest.manifest_format.major == 2
241241
raw = Dict{String,Any}()
242-
raw["julia_version"] = manifest.julia_version
242+
if !isnothing(manifest.julia_version) # don't write julia_version if nothing
243+
raw["julia_version"] = manifest.julia_version
244+
end
243245
raw["manifest_format"] = string(manifest.manifest_format.major, ".", manifest.manifest_format.minor)
244246
raw["deps"] = Dict{String,Vector{Dict{String,Any}}}()
245247
for (k, v) in manifest.other

0 commit comments

Comments
 (0)