From 16c9cecb4665ae395ff9bf046598127d23151a08 Mon Sep 17 00:00:00 2001 From: MichaelHatherly Date: Fri, 18 Oct 2024 14:00:48 +0100 Subject: [PATCH] Revert use of package extensions Currently experiencing cyclic dependency warnings when using the worker package along with system images that contain packages that are dependencies of the extensions themselves. For the time being until the issue can be resolved we will use use `Requires.jl` for the extension loading mechanism instead. --- src/QuartoNotebookWorker/Project.toml | 54 +++++++++---------- .../ext/QuartoNotebookWorkerCairoMakieExt.jl | 2 +- ...QuartoNotebookWorkerDataFramesTablesExt.jl | 4 +- .../ext/QuartoNotebookWorkerJSONExt.jl | 2 +- .../QuartoNotebookWorkerLaTeXStringsExt.jl | 2 +- .../ext/QuartoNotebookWorkerMakieExt.jl | 2 +- .../ext/QuartoNotebookWorkerPlotlyBaseExt.jl | 2 +- .../ext/QuartoNotebookWorkerPlotlyJSExt.jl | 2 +- .../ext/QuartoNotebookWorkerPlotsExt.jl | 2 +- .../ext/QuartoNotebookWorkerRCallExt.jl | 2 +- .../ext/QuartoNotebookWorkerReviseExt.jl | 4 +- .../ext/QuartoNotebookWorkerSymPyCoreExt.jl | 2 +- .../src/QuartoNotebookWorker.jl | 38 ++++++++++++- 13 files changed, 76 insertions(+), 42 deletions(-) diff --git a/src/QuartoNotebookWorker/Project.toml b/src/QuartoNotebookWorker/Project.toml index cf0f4c4..a986bd7 100644 --- a/src/QuartoNotebookWorker/Project.toml +++ b/src/QuartoNotebookWorker/Project.toml @@ -12,32 +12,32 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" -[weakdeps] -CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" -DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" -JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" -Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" -PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5" -PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" -Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -RCall = "6f49c342-dc21-5d91-9882-a32aef131414" -Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" -SymPyCore = "458b697b-88f0-4a86-b56b-78b75cfb3531" -Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" - -[extensions] -QuartoNotebookWorkerCairoMakieExt = "CairoMakie" -QuartoNotebookWorkerDataFramesTablesExt = ["DataFrames", "Tables"] -QuartoNotebookWorkerJSONExt = "JSON" -QuartoNotebookWorkerLaTeXStringsExt = "LaTeXStrings" -QuartoNotebookWorkerMakieExt = "Makie" -QuartoNotebookWorkerPlotlyBaseExt = "PlotlyBase" -QuartoNotebookWorkerPlotlyJSExt = "PlotlyJS" -QuartoNotebookWorkerPlotsExt = "Plots" -QuartoNotebookWorkerRCallExt = "RCall" -QuartoNotebookWorkerReviseExt = "Revise" -QuartoNotebookWorkerSymPyCoreExt = "SymPyCore" - +# [weakdeps] +# CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" +# DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +# JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +# LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" +# Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" +# PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5" +# PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" +# Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" +# RCall = "6f49c342-dc21-5d91-9882-a32aef131414" +# Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" +# SymPyCore = "458b697b-88f0-4a86-b56b-78b75cfb3531" +# Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" +# +# [extensions] +# QuartoNotebookWorkerCairoMakieExt = "CairoMakie" +# QuartoNotebookWorkerDataFramesTablesExt = ["DataFrames", "Tables"] +# QuartoNotebookWorkerJSONExt = "JSON" +# QuartoNotebookWorkerLaTeXStringsExt = "LaTeXStrings" +# QuartoNotebookWorkerMakieExt = "Makie" +# QuartoNotebookWorkerPlotlyBaseExt = "PlotlyBase" +# QuartoNotebookWorkerPlotlyJSExt = "PlotlyJS" +# QuartoNotebookWorkerPlotsExt = "Plots" +# QuartoNotebookWorkerRCallExt = "RCall" +# QuartoNotebookWorkerReviseExt = "Revise" +# QuartoNotebookWorkerSymPyCoreExt = "SymPyCore" +# [preferences.QuartoNotebookWorker] packages = [] diff --git a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerCairoMakieExt.jl b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerCairoMakieExt.jl index 37e666f..ec12643 100644 --- a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerCairoMakieExt.jl +++ b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerCairoMakieExt.jl @@ -1,7 +1,7 @@ module QuartoNotebookWorkerCairoMakieExt import QuartoNotebookWorker -import CairoMakie +import ..CairoMakie function configure() fm = QuartoNotebookWorker._figure_metadata() diff --git a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerDataFramesTablesExt.jl b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerDataFramesTablesExt.jl index 1a941ba..2af0afe 100644 --- a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerDataFramesTablesExt.jl +++ b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerDataFramesTablesExt.jl @@ -1,8 +1,8 @@ module QuartoNotebookWorkerDataFramesTablesExt import QuartoNotebookWorker -import DataFrames -import Tables +import ..DataFrames +import ..Tables QuartoNotebookWorker._ojs_convert(df::DataFrames.AbstractDataFrame) = Tables.rows(df) diff --git a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerJSONExt.jl b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerJSONExt.jl index 9affa56..f422a98 100644 --- a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerJSONExt.jl +++ b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerJSONExt.jl @@ -1,7 +1,7 @@ module QuartoNotebookWorkerJSONExt import QuartoNotebookWorker -import JSON +import ..JSON function QuartoNotebookWorker._ojs_define(::QuartoNotebookWorker.OJSDefine, kwargs) contents = QuartoNotebookWorker.ojs_convert(kwargs) diff --git a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerLaTeXStringsExt.jl b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerLaTeXStringsExt.jl index 531f5b5..aeac18c 100644 --- a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerLaTeXStringsExt.jl +++ b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerLaTeXStringsExt.jl @@ -1,7 +1,7 @@ module QuartoNotebookWorkerLaTeXStringsExt import QuartoNotebookWorker as QNW -import LaTeXStrings as LS +import ..LaTeXStrings as LS QNW._mimetype_wrapper(s::LS.LaTeXString) = LaTeXStringWrapper(s) diff --git a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerMakieExt.jl b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerMakieExt.jl index 910f199..4249c0e 100644 --- a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerMakieExt.jl +++ b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerMakieExt.jl @@ -1,7 +1,7 @@ module QuartoNotebookWorkerMakieExt import QuartoNotebookWorker -import Makie +import ..Makie function configure() fm = QuartoNotebookWorker._figure_metadata() diff --git a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerPlotlyBaseExt.jl b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerPlotlyBaseExt.jl index a880295..aa9fdc2 100644 --- a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerPlotlyBaseExt.jl +++ b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerPlotlyBaseExt.jl @@ -1,7 +1,7 @@ module QuartoNotebookWorkerPlotlyBaseExt import QuartoNotebookWorker -import PlotlyBase +import ..PlotlyBase struct PlotlyBasePlotWithoutRequireJS plot::PlotlyBase.Plot diff --git a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerPlotlyJSExt.jl b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerPlotlyJSExt.jl index b25cb6e..4b0ae81 100644 --- a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerPlotlyJSExt.jl +++ b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerPlotlyJSExt.jl @@ -1,7 +1,7 @@ module QuartoNotebookWorkerPlotlyJSExt import QuartoNotebookWorker -import PlotlyJS +import ..PlotlyJS QuartoNotebookWorker.expand(p::PlotlyJS.SyncPlot) = QuartoNotebookWorker.expand(p.plot) diff --git a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerPlotsExt.jl b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerPlotsExt.jl index 880ad51..e576fca 100644 --- a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerPlotsExt.jl +++ b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerPlotsExt.jl @@ -1,7 +1,7 @@ module QuartoNotebookWorkerPlotsExt import QuartoNotebookWorker -import Plots +import ..Plots function configure() fm = QuartoNotebookWorker._figure_metadata() diff --git a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerRCallExt.jl b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerRCallExt.jl index 672e4fc..e1ffeb6 100644 --- a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerRCallExt.jl +++ b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerRCallExt.jl @@ -1,7 +1,7 @@ module QuartoNotebookWorkerRCallExt import QuartoNotebookWorker -import RCall +import ..RCall const RCall_temp_files_ref = Ref{String}() const rcalljl_device_ref = Ref{Symbol}(:png) diff --git a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerReviseExt.jl b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerReviseExt.jl index 613773b..0fce08c 100644 --- a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerReviseExt.jl +++ b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerReviseExt.jl @@ -1,10 +1,10 @@ module QuartoNotebookWorkerReviseExt -import Revise +import ..Revise import QuartoNotebookWorker function __init__() - @debug "extension has been loaded" Revise QuartoNotebookWorker + @info "extension has been loaded" Revise QuartoNotebookWorker end end diff --git a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerSymPyCoreExt.jl b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerSymPyCoreExt.jl index bc74055..5a08649 100644 --- a/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerSymPyCoreExt.jl +++ b/src/QuartoNotebookWorker/ext/QuartoNotebookWorkerSymPyCoreExt.jl @@ -1,7 +1,7 @@ module QuartoNotebookWorkerSymPyCoreExt import QuartoNotebookWorker as QNW -import SymPyCore as SPC +import ..SymPyCore as SPC QNW._mimetype_wrapper(s::SPC.SymbolicObject) = SymWrapper(s) QNW._mimetype_wrapper(s::AbstractArray{<:SPC.Sym}) = SymWrapper(s) diff --git a/src/QuartoNotebookWorker/src/QuartoNotebookWorker.jl b/src/QuartoNotebookWorker/src/QuartoNotebookWorker.jl index ad095b7..930a21a 100644 --- a/src/QuartoNotebookWorker/src/QuartoNotebookWorker.jl +++ b/src/QuartoNotebookWorker/src/QuartoNotebookWorker.jl @@ -75,9 +75,43 @@ end # Handle older versions of Julia that don't have support for package extensions. # Note that this macro must be called in the root-module of a package, otherwise # `pathof(__module__)` will be `nothing`. -import .Packages.PackageExtensionCompat: @require_extensions +import .Packages.Requires function __init__() - @require_extensions + Requires.@require CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" include( + "../ext/QuartoNotebookWorkerCairoMakieExt.jl", + ) + Requires.@require DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" begin + Requires.@require Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" include( + "../ext/QuartoNotebookWorkerDataFramesTablesExt.jl", + ) + end + Requires.@require JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" include( + "../ext/QuartoNotebookWorkerJSONExt.jl", + ) + Requires.@require LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" include( + "../ext/QuartoNotebookWorkerLaTeXStringsExt.jl", + ) + Requires.@require Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" include( + "../ext/QuartoNotebookWorkerMakieExt.jl", + ) + Requires.@require PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5" include( + "../ext/QuartoNotebookWorkerPlotlyBaseExt.jl", + ) + Requires.@require PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" include( + "../ext/QuartoNotebookWorkerPlotlyJSExt.jl", + ) + Requires.@require Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" include( + "../ext/QuartoNotebookWorkerPlotsExt.jl", + ) + Requires.@require RCall = "6f49c342-dc21-5d91-9882-a32aef131414" include( + "../ext/QuartoNotebookWorkerRCallExt.jl", + ) + Requires.@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" include( + "../ext/QuartoNotebookWorkerReviseExt.jl", + ) + Requires.@require SymPyCore = "458b697b-88f0-4a86-b56b-78b75cfb3531" include( + "../ext/QuartoNotebookWorkerSymPyCoreExt.jl", + ) end # Imports.