Skip to content

Commit d69a8a0

Browse files
committed
add some backwards compatibility for 1.6.1
1 parent 5a5ca99 commit d69a8a0

File tree

5 files changed

+69
-14
lines changed

5 files changed

+69
-14
lines changed

src/API.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,8 +1147,12 @@ function precompile(ctx::Context; internal_call::Bool=false, strict::Bool=false,
11471147
end
11481148
try
11491149
ret = Logging.with_logger(Logging.NullLogger()) do
1150-
# capture stderr, send stdout to devnull, don't skip loaded modules
1151-
Base.compilecache(pkg, sourcepath, iob, devnull, false)
1150+
@static if hasmethod(Base.compilecache, Tuple{Base.PkgId, String, IO, IO, Bool})
1151+
# capture stderr, send stdout to devnull, don't skip loaded modules
1152+
Base.compilecache(pkg, sourcepath, iob, devnull, false)
1153+
else
1154+
Base.compilecache(pkg, sourcepath, iob, devnull)
1155+
end
11521156
end
11531157
if ret isa Base.PrecompilableError
11541158
push!(precomperr_deps, pkg)

src/manifest.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,23 @@ function Manifest(raw::Dict, f_or_io::Union{String, IO})::Manifest
176176
return validate_manifest(julia_version, manifest_format, stage1, other)
177177
end
178178

179+
if isdefined(Base, :is_v1_format_manifest)
180+
const is_v1_format_manifest = Base.is_v1_format_manifest
181+
else
182+
function is_v1_format_manifest(raw_manifest::Dict)
183+
if haskey(raw_manifest, "manifest_format")
184+
if raw_manifest["manifest_format"] isa Dict && haskey(raw_manifest["manifest_format"], "uuid")
185+
# the off-chance where an old format manifest has a dep called "manifest_format"
186+
return true
187+
end
188+
return false
189+
else
190+
return true
191+
end
192+
end
193+
end
194+
195+
179196
function read_manifest(f_or_io::Union{String,IO})
180197
raw = if f_or_io isa IO
181198
TOML.tryparse(read(f_or_io, String))
@@ -185,7 +202,7 @@ function read_manifest(f_or_io::Union{String,IO})
185202
if raw isa TOML.ParserError
186203
pkgerror("Could not parse manifest: ", sprint(showerror, raw))
187204
end
188-
if Base.is_v1_format_manifest(raw)
205+
if is_v1_format_manifest(raw)
189206
raw = convert_flat_format_manifest(raw)
190207
end
191208
return Manifest(raw, f_or_io)

test/manifests.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,51 @@ using ..Utils
1313
@test occursin(r"Activating.*environment at.*", output)
1414
Pkg.add("Profile")
1515
env_manifest = Pkg.Types.Context().env.manifest_file
16-
@test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest))
16+
@test Pkg.Types.is_v1_format_manifest(Base.parsed_toml(env_manifest))
1717
end
1818
end
1919

2020
@testset "v1.0: activate, change, maintain manifest format" begin
2121
env_dir = joinpath(@__DIR__, "manifest", "formats", "v1.0")
2222
env_manifest = joinpath(env_dir, "Manifest.toml")
2323
isfile(env_manifest) || error("Reference manifest is missing")
24-
if Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == false
24+
if Pkg.Types.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == false
2525
error("Reference manifest file at $(env_manifest) is invalid")
2626
end
2727
isolate(loaded_depot=true) do
2828
io = IOBuffer()
2929
Pkg.activate(env_dir; io=io)
3030
output = String(take!(io))
3131
@test occursin(r"Activating.*environment at.*`.*v1.0.*`", output)
32-
@test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest))
32+
@test Pkg.Types.is_v1_format_manifest(Base.parsed_toml(env_manifest))
3333

3434
Pkg.add("Profile")
35-
@test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest))
35+
@test Pkg.Types.is_v1_format_manifest(Base.parsed_toml(env_manifest))
3636

3737
Pkg.rm("Profile")
38-
@test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest))
38+
@test Pkg.Types.is_v1_format_manifest(Base.parsed_toml(env_manifest))
3939
end
4040
end
4141

4242
@testset "v2.0: activate, change, maintain manifest format" begin
4343
env_dir = joinpath(@__DIR__, "manifest", "formats", "v2.0")
4444
env_manifest = joinpath(env_dir, "Manifest.toml")
4545
isfile(env_manifest) || error("Reference manifest is missing")
46-
if Base.is_v1_format_manifest(Base.parsed_toml(env_manifest))
46+
if Pkg.Types.is_v1_format_manifest(Base.parsed_toml(env_manifest))
4747
error("Reference manifest file at $(env_manifest) is invalid")
4848
end
4949
isolate(loaded_depot=true) do
5050
io = IOBuffer()
5151
Pkg.activate(env_dir; io=io)
5252
output = String(take!(io))
5353
@test occursin(r"Activating.*environment at.*`.*v2.0.*`", output)
54-
@test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == false
54+
@test Pkg.Types.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == false
5555

5656
Pkg.add("Profile")
57-
@test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == false
57+
@test Pkg.Types.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == false
5858

5959
Pkg.rm("Profile")
60-
@test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == false
60+
@test Pkg.Types.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == false
6161

6262
m = Pkg.Types.read_manifest(env_manifest)
6363
@test m.other["some_other_field"] == "other"

test/new.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2544,6 +2544,17 @@ end
25442544
@test test_result
25452545
end
25462546

2547+
# returns a deps list for both old and new manifest formats
2548+
function get_deps(raw_manifest::Dict)
2549+
if Pkg.Types.is_v1_format_manifest(raw_manifest)
2550+
return raw_manifest
2551+
else
2552+
# if the manifest has no deps, there won't be a `deps` field
2553+
return get(Dict{String, Any}, raw_manifest, "deps")
2554+
end
2555+
end
2556+
2557+
25472558
@testset "Pkg.add() with julia_version" begin
25482559
# A package with artifacts that went from normal package -> stdlib
25492560
gmp_jll_uuid = "781609d7-10c4-51f6-84f2-b8444358ff6d"
@@ -2556,7 +2567,7 @@ end
25562567
manifest_path = joinpath(dirname(Base.active_project()), "Manifest.toml")
25572568
@test isfile(manifest_path)
25582569
manifest = Pkg.Types.read_manifest
2559-
deps = Base.get_deps(TOML.parsefile(manifest_path))
2570+
deps = get_deps(TOML.parsefile(manifest_path))
25602571
@test haskey(deps, name)
25612572
return only(deps[name])
25622573
end

test/test_packages/BuildProjectFixedDeps/deps/build.jl

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,30 @@ build_artifact = joinpath(@__DIR__, "artifact")
33
isfile(build_artifact) && rm(build_artifact)
44
project = TOML.parsefile(Base.active_project())
55
@assert get(project["deps"], "JSON", nothing) === nothing
6-
manifest = Base.get_deps(TOML.parsefile(joinpath(dirname(Base.active_project()), "Manifest.toml")))
6+
7+
# Backwards compat with 1.6.1
8+
function is_v1_format_manifest(raw_manifest::Dict)
9+
if haskey(raw_manifest, "manifest_format")
10+
if raw_manifest["manifest_format"] isa Dict && haskey(raw_manifest["manifest_format"], "uuid")
11+
# the off-chance where an old format manifest has a dep called "manifest_format"
12+
return true
13+
end
14+
return false
15+
else
16+
return true
17+
end
18+
end
19+
# returns a deps list for both old and new manifest formats
20+
function get_deps(raw_manifest::Dict)
21+
if is_v1_format_manifest(raw_manifest)
22+
return raw_manifest
23+
else
24+
# if the manifest has no deps, there won't be a `deps` field
25+
return get(Dict{String, Any}, raw_manifest, "deps")
26+
end
27+
end
28+
29+
manifest = get_deps(TOML.parsefile(joinpath(dirname(Base.active_project()), "Manifest.toml")))
730
json = manifest["JSON"][1]
831
@assert json["uuid"] == "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
932
@assert json["version"] == "0.19.0"

0 commit comments

Comments
 (0)