Pluto.jl icon indicating copy to clipboard operation
Pluto.jl copied to clipboard

PkgManager: Allow loading of extensions specifically designed for pluto, implicitly

Open pankgeorg opened this issue 2 months ago • 3 comments

Some packages want to provide Pluto renderers, but only if the code runs inside Pluto. These renderers may be quite heavy and ideally wouldn't be loaded by any user of the library (e.g. MTK). It would be nice for Pkg to be able to detect Pluto (or, more likely, the PlutoRunner module) and load the extensions that are registered for a Pluto environment.

One important caveat is that we can't just slap PlutoRunner to the Manifest; as the file should also run independently (without loading the extension, as it does now). So this is really a "runtime" check.

pankgeorg avatar Sep 26 '25 09:09 pankgeorg

Can you also write how this compares to https://plutojl.org/en/docs/abstractplutodingetjes/#is_inside_pluto ?

fonsp avatar Sep 26 '25 14:09 fonsp

Pkg would handle it. It would "install and load the package" when inside pluto. Roughly equivalent to

function Base.show(io, ...)
if is_inside_pluto(io::IO) && !isdefined(:PlutoRunner, LatexifyPlutoExt)
  Pkg.add("LatexifyPlutoExt")
  using LatexifyPlutoExt
end

but if it's possible to do natively (and avoid opting out of the pkg manager) that would be even nicer)

pankgeorg avatar Sep 26 '25 16:09 pankgeorg

I'm struggling actually creating an extension, but if someone can test if

[weakdeps]
PlutoRunner = "dc6b355a-2368-4481-ae6d-ae0351418d79"

[extensions]
YourExtensionForPluto = "PlutoRunner"

loads YourExtensionForPluto when in Pluto, that's pretty much done

pankgeorg avatar Sep 26 '25 16:09 pankgeorg