Search code examples
dependenciespackagejulia

Julia: create a package with optional dependencies


I want to build a numerical package that also has optional support for visualization. For simplicity, let's say the respective dependencies are NumPackage for the heavy lifting and VizPackage for optional visualization.

In Julia, how can I build a module that has NumPackage in its required dependencies, but VizPackage only as an optional dependency, say for example for those users that want to run an example simulation and visualize it?

I saw the Requires.jl package but not sure if it's the right tool for what I'm trying to do.


Solution

  • The current best solution (2019-10-04) is to use Requires.jl. However, there are a number of issues with Requires.jl so there are plans for a better solution, see https://github.com/JuliaLang/Pkg.jl/issues/1285. Hopefully it will be ready in time for Julia version 1.4 or 1.5.