Skip to content

Commit

Permalink
add WEAKDEPS to trigger package extensions (#5026)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg authored Nov 13, 2024
1 parent 6bc1ecc commit 2068ec7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
10 changes: 10 additions & 0 deletions PlotsBase/src/PlotsBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@max_m
@eval Base.Experimental.@max_methods 1
end

# multiple weakdeps triggers (keep in sync with Project.toml !)
const WEAKDEPS = Expr(
:block,
:(import UnitfulLatexify),
:(import LaTeXStrings),
:(import Latexify),
:(import Contour),
:(import Colors),
)

using Base.Meta

import PrecompileTools
Expand Down
2 changes: 2 additions & 0 deletions PlotsBase/src/backends.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ for sym ∈ _default_supported_syms
end
end

const WEAKDEPS =

_display(::Plot{NoneBackend}) =
@warn "No backend activated yet. Load the backend library and call the activation function to do so.\nE.g. `import GR; gr()` activates the GR backend."

Expand Down
12 changes: 1 addition & 11 deletions PlotsBase/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,7 @@ const TEST_BACKENDS = NamedTuple(p => Symbol(lowercase(string(p))) for p ∈ TES
get!(ENV, "MPLBACKEND", "agg")

using PlotsBase

# multiple weakdeps (keep in sync with Project.toml !)
const WEAKDEPS = Expr(
:block,
:(import UnitfulLatexify),
:(import LaTeXStrings),
:(import Latexify),
:(import Contour),
:(import Colors),
)
eval(WEAKDEPS)
eval(PlotsBase.WEAKDEPS)

# initialize all backends
for pkg TEST_PACKAGES
Expand Down
2 changes: 1 addition & 1 deletion PlotsBase/test/test_preferences.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ end
write(
script,
"""
$WEAKDEPS
$(PlotsBase.WEAKDEPS)
import $pkg
using Test, PlotsBase
Expand Down
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import UnicodePlots
import StatsPlots

const PlotsBase = Plots.PlotsBase
eval(PlotsBase.WEAKDEPS)

const SRC_DIR = joinpath(@__DIR__, "src")
const WORK_DIR = joinpath(@__DIR__, "work")
Expand Down

0 comments on commit 2068ec7

Please sign in to comment.