add_backend/add_backend_string redesign

This commit is contained in:
Thomas Breloff 2016-09-22 13:47:33 -04:00
parent 1f7043e02a
commit 5f4dfdd5d2
8 changed files with 50 additions and 18 deletions

View File

@ -31,8 +31,12 @@ include("backends/web.jl")
# --------------------------------------------------------- # ---------------------------------------------------------
add_backend(pkg::Symbol) = add_backend(_backend_instance(pkg)) function add_backend(pkg::Symbol)
add_backend(b::AbstractBackend) = warn("No custom install defined for $(backend_name(b))") info("To do a standard install of $pkg, copy and run this:\n\n")
println(add_backend_string(_backend_instance(pkg)))
println()
end
add_backend_string(b::AbstractBackend) = warn("No custom install defined for $(backend_name(b))")
# don't do anything as a default # don't do anything as a default
_create_backend_figure(plt::Plot) = nothing _create_backend_figure(plt::Plot) = nothing
@ -147,6 +151,7 @@ function backend()
_initialize_backend(inst) _initialize_backend(inst)
catch err catch err
warn("Couldn't initialize $sym. (might need to install it?)") warn("Couldn't initialize $sym. (might need to install it?)")
add_backend(sym)
rethrow(err) rethrow(err)
end end

View File

@ -75,14 +75,15 @@ function _initialize_backend(::GLVisualizeBackend; kw...)
end end
end end
function add_backend(::GLVisualizeBackend) function add_backend_string(b::GLVisualizeBackend)
if !is_installed("GLVisualize") """
if !Plots.is_installed("GLVisualize")
Pkg.add("GLVisualize") Pkg.add("GLVisualize")
end end
if !is_installed("Contour") if !Plots.is_installed("Contour")
Pkg.add("Contour") Pkg.add("Contour")
end end
if !is_installed("GLPlot") if !Plots.is_installed("GLPlot")
Pkg.add("GLPlot") Pkg.add("GLPlot")
end end
@ -92,11 +93,12 @@ function add_backend(::GLVisualizeBackend)
"GLVisualize", "GeometryTypes", "FixedSizeArrays", "GLVisualize", "GeometryTypes", "FixedSizeArrays",
"FreeType", "GLPlot" "FreeType", "GLPlot"
] ]
warn("Running Pkg.checkout(\"$pkg\"). To revert, run Pkg.free(\"$pkg\")") warn("Running Pkg.checkout(\"\$pkg\"). To revert, run Pkg.free(\"\$pkg\")")
Pkg.checkout(pkg) Pkg.checkout(pkg)
end end
warn("Running Pkg.checkout(\"Reactive\", \"sd/betterstop\"). To revert, run Pkg.free(\"Reactive\")") warn("Running Pkg.checkout(\"Reactive\", \"sd/betterstop\"). To revert, run Pkg.free(\"Reactive\")")
Pkg.checkout("Reactive", "sd/betterstop") Pkg.checkout("Reactive", "sd/betterstop")
"""
end end
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------

View File

@ -42,6 +42,12 @@ const _gr_marker = _allMarkers
const _gr_scale = [:identity, :log10] const _gr_scale = [:identity, :log10]
is_marker_supported(::GRBackend, shape::Shape) = true is_marker_supported(::GRBackend, shape::Shape) = true
function add_backend_string(::GRBackend)
"""
Pkg.add("GR")
Pkg.build("GR")
"""
end
function _initialize_backend(::GRBackend; kw...) function _initialize_backend(::GRBackend; kw...)
@eval begin @eval begin

View File

@ -40,6 +40,12 @@ const _pgfplots_scale = [:identity, :ln, :log2, :log10]
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
function add_backend_string(::PGFPlotsBackend)
"""
Pkg.add("PGFPlots")
Pkg.build("PGFPlots")
"""
end
function _initialize_backend(::PGFPlotsBackend; kw...) function _initialize_backend(::PGFPlotsBackend; kw...)
@eval begin @eval begin

View File

@ -47,8 +47,10 @@ is_subplot_supported(::PlotlyBackend) = true
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
function add_backend(::PlotlyBackend) function add_backend_string(::PlotlyBackend)
"""
Pkg.build("Plots") Pkg.build("Plots")
"""
end end

View File

@ -10,15 +10,17 @@ const _plotlyjs_scale = _plotly_scale
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
function add_backend(::PlotlyJSBackend) function add_backend_string(::PlotlyJSBackend)
if !is_installed("PlotlyJS") """
if !Plots.is_installed("PlotlyJS")
Pkg.add("PlotlyJS") Pkg.add("PlotlyJS")
end end
if !is_installed("Rsvg") if !Plots.is_installed("Rsvg")
Pkg.add("Rsvg") Pkg.add("Rsvg")
end end
@eval import Blink import Blink
Blink.AtomShell.install() Blink.AtomShell.install()
"""
end end

View File

@ -48,13 +48,15 @@ is_marker_supported(::PyPlotBackend, shape::Shape) = true
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
function add_backend(::PyPlotBackend) function add_backend_string(::PyPlotBackend)
if !is_installed("PyPlot") """
withenv("PYTHON" => "") do if !Plots.is_installed("PyPlot")
Pkg.add("PyPlot") Pkg.add("PyPlot")
Pkg.build("PyPlot")
end
end end
withenv("PYTHON" => "") do
Pkg.build("PyPlot")
end
"""
end end
function _initialize_backend(::PyPlotBackend) function _initialize_backend(::PyPlotBackend)

View File

@ -28,6 +28,13 @@ warnOnUnsupported_args(::UnicodePlotsBackend, d::KW) = nothing
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
function add_backend_string(::UnicodePlotsBackend)
"""
Pkg.add("UnicodePlots")
Pkg.build("UnicodePlots")
"""
end
function _initialize_backend(::UnicodePlotsBackend; kw...) function _initialize_backend(::UnicodePlotsBackend; kw...)
@eval begin @eval begin
import UnicodePlots import UnicodePlots