I recently started with the development of ExactFieldSolutions.
The package aims at providing full-field exact solutions for various PDEs, which can then be used for verifying the accuracy of numerical solutions.
The package has Plots.jl as dependency, as it is being use in part of the scripts for examples of visualisation (in folder visualisations) and examples of convergence tests (in folder benchmarks) .
I had the request to make Plots.jl an extension. It makes sense as common usage would not require any visualisation. Users may not want to load plots at all (running on a cluster) or may rely on other visualisations tools that exports visualisation functions with similar name.
For this, Iāve moved the benchmarks and visualisations folder into an ext folder. Then, Project.toml was edited that way. The hope is that if the user employs any of the scripts located in any of these 2 folders, then Plots.jl would be installed. Unfortunately, this create problems, running a script from folder visualisation complains about Plots.jl not being installed. On the other hand, running a script from folder benchmarks attempts to install Plots but then complains about GR_jllā¦
What would be the best way to handle this kind of situation? Is there something obviously wrong?
Extensions donāt sound like the right tool for this problem at all. The usual approach would be to have a separate environment for the examples, where both the ExactFieldSolutions and Plots packages would be available.
Thanks for the suggestion. I didnāt know that a package could host several environments internally. This could be a good solution. I will give it a try!
Can we think of a title that will make this answer more searchable in the future? Say, āIntegrating Plots into a Packageā or something even better?
Well, in fact the problem would rather be: how to demonstrate a package, when demonstration requires dependencies that are not essential to the core of a package. I took Plots as an example but other packages may be concerned. I have just tested the solution of @GunnarFarneback and this works. It allowed to remove Plots, Symbolics and SparseDiffTools from the environment of the core package. Now I have to see how nice it is in practice for further developing the package (i.e. I like visualising when I add new solution, so this may require switching environments back and forth). Thanks a lot for the many suggestions!
thanks again everyone for your help. Iāve tagged the first answer of @GunnarFarneback as the solution - ExactFieldSolutions.jl now uses this approach. I will definitely try out the workspace feature in the future, this seems indeed ideally designed.