Skip to content

Commit

Permalink
select Plots backend via Preferences (or env variable) (#4566)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Christ <[email protected]>

Co-authored-by: Mark Kittisopikul <[email protected]>
  • Loading branch information
t-bltg and mkitti authored Dec 4, 2022
1 parent 5df0c5d commit a1ad4c9
Show file tree
Hide file tree
Showing 22 changed files with 461 additions and 343 deletions.
20 changes: 5 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ jobs:
env:
GKS_ENCODING: "utf8"
GKSwstype: "nul"
PYTHON: "Conda" # for `PyPlot`
JULIA_PYTHONCALL_EXE: "@PyCall" # for `PythonCall`
JULIA_CONDAPKG_BACKEND: "MicroMamba"
name: Julia ${{ matrix.version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.version == 'nightly' }}
Expand Down Expand Up @@ -73,11 +72,8 @@ jobs:
- name: Install conda based matplotlib
shell: julia --project=@. --color=yes {0}
run: |
@show ENV["PYTHON"]
using Pkg
Pkg.add("Conda"); Pkg.build("Conda"; verbose=true)
using Conda; env, rc = Conda.ROOTENV, Conda.conda_rc(Conda.ROOTENV)
Conda.runconda(`config --set auto_update_conda False --file $rc --force`, env)
using Pkg; Pkg.add("CondaPkg")
using CondaPkg; CondaPkg.resolve()
libgcc = if Sys.islinux()
# see discourse.julialang.org/t/glibcxx-version-not-found/82209/8
# julia 1.8.3 is built with libstdc++.so.6.0.29, so we must restrict to this version (gcc 11.3.0, not gcc 12.2.0)
Expand All @@ -92,14 +88,8 @@ jobs:
else
()
end
Conda.add([libgcc..., "matplotlib"])
Conda.list()
# configure `CondPkg` to use `Conda` setup
open(ENV["GITHUB_ENV"], "a") do io
println(io, "JULIA_CONDAPKG_EXE=", Conda.CONDA_EXE)
println(io, "JULIA_CONDAPKG_BACKEND=Null")
end
Pkg.add("PyCall"); Pkg.build("PyCall"; verbose=true)
CondaPkg.PkgREPL.add([libgcc..., "matplotlib"])
CondaPkg.status()
- uses: julia-actions/julia-runtest@latest
with:
Expand Down
12 changes: 7 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PlotThemes = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a"
PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -40,25 +41,27 @@ UnicodeFun = "1cfade01-22cf-5700-b092-accc4b62d6e1"
Unzip = "41fe7b60-77ed-43a1-b4f0-825fd5a5650d"

[compat]
Conda = "1"
Contour = "0.5 - 0.6"
FFMPEG = "0.2 - 0.4"
FixedPointNumbers = "0.6 - 0.8"
GR = "0.69.5 - 0.71"
Gaston = "1"
HDF5 = "0.16"
InspectDR = "0.4"
JLFzf = "0.1"
JSON = "0.21, 1"
LaTeXStrings = "1"
Latexify = "0.14 - 0.15"
Measures = "0.3"
NaNMath = "0.3, 1"
PGFPlots = "3"
PGFPlotsX = "1"
PlotThemes = "2, 3"
PlotUtils = "1"
PlotlyBase = "0.7 - 0.8"
PlotlyJS = "0.18"
PlotlyKaleido = "1"
PyCall = "1"
Preferences = "1"
PyPlot = "2"
PythonPlot = "1"
RecipesBase = "1.3.1"
Expand All @@ -78,7 +81,6 @@ julia = "1.6"
[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
Expand All @@ -91,11 +93,11 @@ Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
InspectDR = "d0351b0e-4b05-5898-87b3-e2a8edfddd1d"
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
PGFPlots = "3b7a836e-365b-5785-a47d-02c71176b4aa"
PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925"
PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5"
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
PlotlyKaleido = "f2990250-8cf9-495f-b13a-cce12b45703c"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
PythonPlot = "274fc56d-3b97-40fa-a1cd-1b4a50311bf9"
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"
Expand All @@ -110,4 +112,4 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92"

[targets]
test = ["Aqua", "Colors", "Conda", "Distributions", "FileIO", "FilePathsBase", "Gaston", "GeometryBasics", "Gtk", "ImageMagick", "Images", "InspectDR", "LibGit2", "OffsetArrays", "PGFPlotsX", "PlotlyJS", "PlotlyBase", "PyCall", "PyPlot", "PythonPlot", "PlotlyKaleido", "HDF5", "RDatasets", "SentinelArrays", "StableRNGs", "StaticArrays", "StatsPlots", "Test", "TestImages", "UnicodePlots", "Unitful", "VisualRegressionTests"]
test = ["Aqua", "Colors", "Distributions", "FileIO", "FilePathsBase", "Gaston", "GeometryBasics", "Gtk", "ImageMagick", "Images", "InspectDR", "LibGit2", "OffsetArrays", "PGFPlotsX", "PlotlyJS", "PlotlyBase", "PyPlot", "PythonPlot", "PlotlyKaleido", "HDF5", "RDatasets", "SentinelArrays", "StableRNGs", "StaticArrays", "StatsPlots", "Test", "TestImages", "UnicodePlots", "Unitful", "VisualRegressionTests"]
46 changes: 6 additions & 40 deletions src/Plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,9 @@ if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@max_m
@eval Base.Experimental.@max_methods 1
end

using Pkg

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)
sim_str = string(sim)
haskey(_plots_compats, sim_str) || return nothing
be_v = Pkg.Types.read_project(joinpath(Base.pkgdir(sim), "Project.toml")).version
be_c = _plots_compats[sim_str]
if be_c isa String # julia 1.6
if !(be_v in Pkg.Types.semver_spec(be_c))
@warn "$sim $be_v is not compatible with this version of Plots. The declared compatibility is $(be_c)."
end
else
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
end

using Dates, Printf, Statistics, Base64, LinearAlgebra, Random
using SparseArrays
using Pkg, Dates, Printf, Statistics, Base64, LinearAlgebra, SparseArrays, Random
using SnoopPrecompile, Preferences, Requires, Reexport
using Base.Meta
using Requires
using Reexport
using Unzip
@reexport using RecipesBase
@reexport using PlotThemes
Expand Down Expand Up @@ -167,6 +143,7 @@ using .PlotMeasures
import .PlotMeasures: Length, AbsoluteLength, Measure, width, height
# ---------------------------------------------------------

const PLOTS_SEED = 1234
const PX_PER_INCH = 100
const DPI = PX_PER_INCH
const MM_PER_INCH = 25.4
Expand All @@ -190,23 +167,12 @@ include("animation.jl")
include("examples.jl")
include("plotattr.jl")
include("backends.jl")
const CURRENT_BACKEND = CurrentBackend(:none)
include("backends/web.jl")
include("output.jl")
include("ijulia.jl")
include("fileio.jl")

# Use fixed version of Plotly instead of the latest one for stable dependency
# Ref: https://github.com/JuliaPlots/Plots.jl/pull/2779
const _plotly_min_js_filename = "plotly-2.6.3.min.js"
const CURRENT_BACKEND = CurrentBackend(:none)
const PLOTS_SEED = 1234

include("init.jl")

include("backends/plotly.jl")
include("backends/web.jl")
include("backends/gr.jl")

include("shorthands.jl")
include("precompile.jl")
include("init.jl")

end
Loading

0 comments on commit a1ad4c9

Please sign in to comment.