diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83b3d8f6f..877989d51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,11 +53,7 @@ jobs: - os: ubuntu-latest experimental: true prefix: xvfb-run - version: '~1.11.0-0' # upcoming julia version, next `rc` - - os: ubuntu-latest - experimental: true - prefix: xvfb-run - version: 'nightly' + version: 'pre' # upcoming julia version, next `rc` steps: - uses: actions/checkout@v4 diff --git a/Project.toml b/Project.toml index cc6324540..50ea6b594 100644 --- a/Project.toml +++ b/Project.toml @@ -35,6 +35,7 @@ Showoff = "992d4aef-0814-514b-bc4d-f2e9a6c4116f" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" +TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" UnicodeFun = "1cfade01-22cf-5700-b092-accc4b62d6e1" UnitfulLatexify = "45397f5d-5981-4c77-b2b3-fc36d6e9b728" diff --git a/src/Plots.jl b/src/Plots.jl index e3610d9bd..0bef4a1b7 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -7,7 +7,7 @@ if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@max_m @eval Base.Experimental.@max_methods 1 end -using Pkg, Dates, Printf, Statistics, Base64, LinearAlgebra, SparseArrays, Random +using Dates, Printf, Statistics, Base64, LinearAlgebra, SparseArrays, Random, TOML using PrecompileTools, Reexport, RelocatableFolders using Base.Meta @reexport using RecipesBase diff --git a/src/backends.jl b/src/backends.jl index 1a75a940a..e88b25ae1 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -1,8 +1,9 @@ struct NoBackend <: AbstractBackend end -const _plots_project = Pkg.Types.read_package(normpath(@__DIR__, "..", "Project.toml")) -const _current_plots_version = _plots_project.version -const _plots_compats = _plots_project.compat +lazyloadPkg() = Base.require(@__MODULE__, :Pkg) + +const _current_plots_version = VersionNumber(TOML.parsefile(normpath(@__DIR__, "..", "Project.toml"))["version"]) +const _plots_compats = TOML.parsefile(normpath(@__DIR__, "..", "Project.toml"))["compat"] const _backendSymbol = Dict{DataType,Symbol}(NoBackend => :none) const _backendType = Dict{Symbol,DataType}(:none => NoBackend) @@ -10,7 +11,7 @@ const _backend_packages = Dict{Symbol,Symbol}() const _initialized_backends = Set{Symbol}() const _backends = Symbol[] -const _plots_deps = let toml = Pkg.TOML.parsefile(normpath(@__DIR__, "..", "Project.toml")) +const _plots_deps = let toml = TOML.parsefile(normpath(@__DIR__, "..", "Project.toml")) merge(toml["deps"], toml["extras"]) end @@ -38,7 +39,8 @@ function _check_installed(backend::Union{Module,AbstractString,Symbol}; warn = t version = if pkg_id === nothing nothing else - get(Pkg.dependencies(), pkg_id.uuid, (; version = nothing)).version + pkg = lazyloadPkg() + get(Base.invokelatest(pkg.dependencies), pkg_id.uuid, (; version = nothing)).version end version === nothing && @warn "backend `$str` is not installed." version @@ -46,14 +48,11 @@ end function _check_compat(m::Module; warn = true) (be_v = _check_installed(m; warn)) === nothing && return - if (be_c = _plots_compats[string(m)]) isa String # julia 1.6 - if be_v ∉ Pkg.Types.semver_spec(be_c) - @warn "`$m` $be_v is not compatible with this version of `Plots`. The declared compatibility is $(be_c)." - end - else - if intersect(be_v, be_c.val) |> isempty - @warn "`$m` $be_v is not compatible with this version of `Plots`. The declared compatibility is $(be_c.str)." - end + be_c = _plots_compats[string(m)] + pkg = lazyloadPkg() + semver = Base.invokelatest(pkg.Types.semver_spec, be_c) + if Base.invokelatest(∉, be_v, semver) + @warn "`$m` $be_v is not compatible with this version of `Plots`. The declared compatibility is $(be_c)." end nothing end @@ -214,9 +213,11 @@ function diagnostics(io::IO = stdout) else be_name = string(backend_package_name(be)) @info "selected `Plots` backend: $be_name, from $origin" - Pkg.status( + pkg = lazyloadPkg() + Base.invokelatest( + pkg.status, ["Plots", "RecipesBase", "RecipesPipeline", be_name]; - mode = Pkg.PKGMODE_MANIFEST, + mode = pkg.PKGMODE_MANIFEST, io, ) end @@ -379,7 +380,9 @@ function _initialize_backend(pkg::AbstractBackend) @eval name === :GR ? Plots : Main begin import $name export $name - $(_check_compat)($name) + if $(QuoteNode(name)) !== :GR + $(_check_compat)($name) + end end _post_imports(pkg) _runtime_init(pkg)