Skip to content

Commit

Permalink
fix windows test - fix downstream imports
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Nov 29, 2022
1 parent 86a1062 commit e76bee6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
29 changes: 22 additions & 7 deletions src/backends.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,19 @@ end

function _initialize_backend(pkg::AbstractBackend)
sym = backend_package_name(pkg)
@eval Main begin
@eval Main begin # NOTE: this is a hack (expecting the package to be in `Project.toml`, remove in `Plots` `2.0`)
import $sym
export $sym
$(_check_compat)($sym)
end
@eval const $sym = Main.$sym
end

# FIXME: remove hard `GR` dependency in Plots `2.0`
_initialize_backend(pkg::GRBackend) = @eval begin
import GR
export GR
$(_check_compat)(GR)
end

const _gr_attr = merge_with_base_supported([
Expand Down Expand Up @@ -415,6 +423,10 @@ function _initialize_backend(pkg::PlotlyBackend)
end
_check_compat(PlotlyBase)
_check_compat(PlotlyKaleido)
@eval begin
const PlotlyBase = Main.PlotlyBase
const PlotlyKaleido = Main.PlotlyKaleido
end
catch err
@warn "For saving to png with the `Plotly` backend `PlotlyBase` and `PlotlyKaleido` need to be installed." err
end
Expand Down Expand Up @@ -653,13 +665,16 @@ const _plotlyjs_scale = _plotly_scale
# ------------------------------------------------------------------------------
# pyplot

_initialize_backend(::PyPlotBackend) = @eval Main begin
import PyPlot
export PyPlot
$(_check_compat)(PyPlot)
function _initialize_backend(::PyPlotBackend)
@eval Main begin
import PyPlot
export PyPlot
$(_check_compat)(PyPlot)

# we don't want every command to update the figure
PyPlot.ioff()
# we don't want every command to update the figure
PyPlot.ioff()
end
@eval const PyPlot = Main.PyPlot
end

const _pyplot_attr = merge_with_base_supported([
Expand Down
6 changes: 0 additions & 6 deletions src/init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,6 @@ end
##################################################################
backend() # get from `Preferences` or env, and initialize backend

# needs to be split from `__init__` (for precompilation phase)
@eval begin
const $(backend_package_name()) = Main.$(backend_package_name())
export $(backend_package_name())
end

include(backend_path(backend_name()))

# COV_EXCL_START
Expand Down
2 changes: 1 addition & 1 deletion test/test_backends.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ end
ENV[\"PLOTS_PRECOMPILE\"] = false
using Pkg
Pkg.activate(; temp = true)
Pkg.develop(; path = \"$(pkgdir(Plots))\")
Pkg.develop(; path = \"$(escape_string(pkgdir(Plots)))\")
using Plots, Test
@test backend() == Plots.GastonBackend()
"``` |> run
Expand Down

0 comments on commit e76bee6

Please sign in to comment.