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))
add_backend(b::AbstractBackend) = warn("No custom install defined for $(backend_name(b))")
function add_backend(pkg::Symbol)
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
_create_backend_figure(plt::Plot) = nothing
@ -147,6 +151,7 @@ function backend()
_initialize_backend(inst)
catch err
warn("Couldn't initialize $sym. (might need to install it?)")
add_backend(sym)
rethrow(err)
end

View File

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

View File

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

View File

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

View File

@ -48,13 +48,15 @@ is_marker_supported(::PyPlotBackend, shape::Shape) = true
# --------------------------------------------------------------------------------------
function add_backend(::PyPlotBackend)
if !is_installed("PyPlot")
withenv("PYTHON" => "") do
function add_backend_string(::PyPlotBackend)
"""
if !Plots.is_installed("PyPlot")
Pkg.add("PyPlot")
end
withenv("PYTHON" => "") do
Pkg.build("PyPlot")
end
end
"""
end
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...)
@eval begin
import UnicodePlots