|
1 | 1 | struct NoBackend <: AbstractBackend end
|
2 | 2 |
|
3 |
| -const _plots_project = Pkg.Types.read_package(normpath(@__DIR__, "..", "Project.toml")) |
4 |
| -const _current_plots_version = _plots_project.version |
5 |
| -const _plots_compats = _plots_project.compat |
| 3 | +lazyloadPkg() = Base.require(@__MODULE__, :Pkg) |
| 4 | + |
| 5 | +const _current_plots_version = VersionNumber(TOML.parsefile(normpath(@__DIR__, "..", "Project.toml"))["version"]) |
| 6 | +const _plots_compats = TOML.parsefile(normpath(@__DIR__, "..", "Project.toml"))["compat"] |
6 | 7 |
|
7 | 8 | const _backendSymbol = Dict{DataType,Symbol}(NoBackend => :none)
|
8 | 9 | const _backendType = Dict{Symbol,DataType}(:none => NoBackend)
|
9 | 10 | const _backend_packages = Dict{Symbol,Symbol}()
|
10 | 11 | const _initialized_backends = Set{Symbol}()
|
11 | 12 | const _backends = Symbol[]
|
12 | 13 |
|
13 |
| -const _plots_deps = let toml = Pkg.TOML.parsefile(normpath(@__DIR__, "..", "Project.toml")) |
| 14 | +const _plots_deps = let toml = TOML.parsefile(normpath(@__DIR__, "..", "Project.toml")) |
14 | 15 | merge(toml["deps"], toml["extras"])
|
15 | 16 | end
|
16 | 17 |
|
@@ -38,22 +39,20 @@ function _check_installed(backend::Union{Module,AbstractString,Symbol}; warn = t
|
38 | 39 | version = if pkg_id === nothing
|
39 | 40 | nothing
|
40 | 41 | else
|
41 |
| - get(Pkg.dependencies(), pkg_id.uuid, (; version = nothing)).version |
| 42 | + pkg = lazyloadPkg() |
| 43 | + get(Base.invokelatest(pkg.dependencies), pkg_id.uuid, (; version = nothing)).version |
42 | 44 | end
|
43 | 45 | version === nothing && @warn "backend `$str` is not installed."
|
44 | 46 | version
|
45 | 47 | end
|
46 | 48 |
|
47 | 49 | function _check_compat(m::Module; warn = true)
|
48 | 50 | (be_v = _check_installed(m; warn)) === nothing && return
|
49 |
| - if (be_c = _plots_compats[string(m)]) isa String # julia 1.6 |
50 |
| - if be_v ∉ Pkg.Types.semver_spec(be_c) |
51 |
| - @warn "`$m` $be_v is not compatible with this version of `Plots`. The declared compatibility is $(be_c)." |
52 |
| - end |
53 |
| - else |
54 |
| - if intersect(be_v, be_c.val) |> isempty |
55 |
| - @warn "`$m` $be_v is not compatible with this version of `Plots`. The declared compatibility is $(be_c.str)." |
56 |
| - end |
| 51 | + be_c = _plots_compats[string(m)] |
| 52 | + pkg = lazyloadPkg() |
| 53 | + semver = Base.invokelatest(pkg.Types.semver_spec, be_c) |
| 54 | + if Base.invokelatest(∉, be_v, semver) |
| 55 | + @warn "`$m` $be_v is not compatible with this version of `Plots`. The declared compatibility is $(be_c)." |
57 | 56 | end
|
58 | 57 | nothing
|
59 | 58 | end
|
@@ -214,9 +213,11 @@ function diagnostics(io::IO = stdout)
|
214 | 213 | else
|
215 | 214 | be_name = string(backend_package_name(be))
|
216 | 215 | @info "selected `Plots` backend: $be_name, from $origin"
|
217 |
| - Pkg.status( |
| 216 | + pkg = lazyloadPkg() |
| 217 | + Base.invokelatest( |
| 218 | + pkg.status, |
218 | 219 | ["Plots", "RecipesBase", "RecipesPipeline", be_name];
|
219 |
| - mode = Pkg.PKGMODE_MANIFEST, |
| 220 | + mode = pkg.PKGMODE_MANIFEST, |
220 | 221 | io,
|
221 | 222 | )
|
222 | 223 | end
|
@@ -379,7 +380,9 @@ function _initialize_backend(pkg::AbstractBackend)
|
379 | 380 | @eval name === :GR ? Plots : Main begin
|
380 | 381 | import $name
|
381 | 382 | export $name
|
382 |
| - $(_check_compat)($name) |
| 383 | + if $(QuoteNode(name)) !== :GR |
| 384 | + $(_check_compat)($name) |
| 385 | + end |
383 | 386 | end
|
384 | 387 | _post_imports(pkg)
|
385 | 388 | _runtime_init(pkg)
|
|
0 commit comments