Actually check if the loaded backend version mets the compat entries (#4137)
* implement checking backend compat * format * handle backends without compat entry * get version for julia 1.6
This commit is contained in:
parent
4ebadb7612
commit
092fb67017
@ -17,6 +17,7 @@ Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
|
|||||||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||||
Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e"
|
Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e"
|
||||||
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
|
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
|
||||||
|
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
|
||||||
PlotThemes = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a"
|
PlotThemes = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a"
|
||||||
PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043"
|
PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043"
|
||||||
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
||||||
@ -45,11 +46,11 @@ JSON = "0.21, 1"
|
|||||||
Latexify = "0.14 - 0.15"
|
Latexify = "0.14 - 0.15"
|
||||||
Measures = "0.3"
|
Measures = "0.3"
|
||||||
NaNMath = "0.3, 1"
|
NaNMath = "0.3, 1"
|
||||||
|
PGFPlotsX = "1"
|
||||||
PlotThemes = "2"
|
PlotThemes = "2"
|
||||||
PlotUtils = "1"
|
PlotUtils = "1"
|
||||||
PlotlyBase = "0.7"
|
PlotlyBase = "0.7"
|
||||||
PlotlyJS = "0.18"
|
PlotlyJS = "0.18"
|
||||||
PGFPlotsX = "1"
|
|
||||||
PyPlot = "2"
|
PyPlot = "2"
|
||||||
RecipesBase = "1.2"
|
RecipesBase = "1.2"
|
||||||
RecipesPipeline = "0.5"
|
RecipesPipeline = "0.5"
|
||||||
|
|||||||
33
src/Plots.jl
33
src/Plots.jl
@ -1,5 +1,7 @@
|
|||||||
module Plots
|
module Plots
|
||||||
|
|
||||||
|
using Pkg
|
||||||
|
|
||||||
if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@optlevel"))
|
if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@optlevel"))
|
||||||
@eval Base.Experimental.@optlevel 1
|
@eval Base.Experimental.@optlevel 1
|
||||||
end
|
end
|
||||||
@ -7,17 +9,26 @@ if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@max_m
|
|||||||
@eval Base.Experimental.@max_methods 1
|
@eval Base.Experimental.@max_methods 1
|
||||||
end
|
end
|
||||||
|
|
||||||
const _current_plots_version = VersionNumber(
|
const _plots_project = Pkg.Types.read_project(normpath(@__DIR__, "..", "Project.toml"))
|
||||||
split(
|
const _current_plots_version = _plots_project.version
|
||||||
first(
|
const _plots_compats = _plots_project.compat
|
||||||
filter(
|
function _check_compat(sim::Module)
|
||||||
line -> occursin("version", line),
|
sim_str = string(sim)
|
||||||
readlines(normpath(@__DIR__, "..", "Project.toml")),
|
if !haskey(_plots_compats, sim_str)
|
||||||
),
|
return nothing
|
||||||
),
|
end
|
||||||
"\"",
|
be_v = Pkg.Types.read_project(joinpath(Base.pkgdir(sim), "Project.toml")).version
|
||||||
)[2],
|
be_c = _plots_compats[sim_str]
|
||||||
)
|
if be_c isa String # julia 1.6
|
||||||
|
if be_v in Pkg.Types.semver_spec(be_c)
|
||||||
|
@warn "$sim $be_v is not compatible with this version of Plots. The declared compatibility is $(be_c)."
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if isempty(intersect(be_v, be_c.val))
|
||||||
|
@warn "$sim $be_v is not compatible with this version of Plots. The declared compatibility is $(be_c.str)."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
using Reexport
|
using Reexport
|
||||||
|
|
||||||
|
|||||||
@ -300,11 +300,23 @@ function _initialize_backend(pkg::AbstractBackend)
|
|||||||
@eval Main begin
|
@eval Main begin
|
||||||
import $sym
|
import $sym
|
||||||
export $sym
|
export $sym
|
||||||
|
Plots._check_compat($sym)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_initialize_backend(pkg::GRBackend) = nothing
|
_initialize_backend(pkg::GRBackend) = nothing
|
||||||
|
|
||||||
|
function _initialize_backend(pkg::PlotlyBackend)
|
||||||
|
try
|
||||||
|
@eval Main begin
|
||||||
|
import PlotlyBase
|
||||||
|
end
|
||||||
|
_check_compat(PlotlyBase)
|
||||||
|
catch
|
||||||
|
@info "For saving to png with the Plotly backend PlotlyBase has to be installed."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# gr
|
# gr
|
||||||
|
|
||||||
@ -423,16 +435,6 @@ is_marker_supported(::GRBackend, shape::Shape) = true
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# plotly
|
# plotly
|
||||||
|
|
||||||
function _initialize_backend(pkg::PlotlyBackend)
|
|
||||||
try
|
|
||||||
@eval Main begin
|
|
||||||
import PlotlyBase
|
|
||||||
end
|
|
||||||
catch
|
|
||||||
@info "For saving to png with the Plotly backend PlotlyBase has to be installed."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
const _plotly_attr = merge_with_base_supported([
|
const _plotly_attr = merge_with_base_supported([
|
||||||
:annotations,
|
:annotations,
|
||||||
:legend_background_color,
|
:legend_background_color,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user