implement checking backend compat

This commit is contained in:
Simon Christ 2022-03-10 21:18:14 +01:00
parent 4ebadb7612
commit 2838109a53
3 changed files with 27 additions and 22 deletions

View File

@ -17,6 +17,7 @@ Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e"
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PlotThemes = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a"
PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
@ -45,11 +46,11 @@ JSON = "0.21, 1"
Latexify = "0.14 - 0.15"
Measures = "0.3"
NaNMath = "0.3, 1"
PGFPlotsX = "1"
PlotThemes = "2"
PlotUtils = "1"
PlotlyBase = "0.7"
PlotlyJS = "0.18"
PGFPlotsX = "1"
PyPlot = "2"
RecipesBase = "1.2"
RecipesPipeline = "0.5"

View File

@ -1,5 +1,7 @@
module Plots
using Pkg
if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@optlevel"))
@eval Base.Experimental.@optlevel 1
end
@ -7,17 +9,16 @@ if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@max_m
@eval Base.Experimental.@max_methods 1
end
const _current_plots_version = VersionNumber(
split(
first(
filter(
line -> occursin("version", line),
readlines(normpath(@__DIR__, "..", "Project.toml")),
),
),
"\"",
)[2],
)
const _plots_project = Pkg.Types.read_project(normpath(@__DIR__, "..", "Project.toml"))
const _current_plots_version = _plots_project.version
const _plots_compats = _plots_project.compat
function _check_compat(sim::Module)
be_v = Pkg.Types.read_project(joinpath(Base.pkgdir(sim), "Project.toml")).version
be_c = _plots_compats[string(sim)]
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
using Reexport

View File

@ -300,11 +300,24 @@ function _initialize_backend(pkg::AbstractBackend)
@eval Main begin
import $sym
export $sym
Plots._check_compat($sym)
end
end
_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
@ -423,16 +436,6 @@ is_marker_supported(::GRBackend, shape::Shape) = true
# ------------------------------------------------------------------------------
# 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([
:annotations,
:legend_background_color,