Handling dependencies for non-src, non-test code

I’m developing a package that has a different set of dependencies during development than it should for the user. Specifically, the user version depends on a specific set of DifferentialEquations packages, rather than the whole thing (to save on disk space + precompilation time), while in development I use the whole package to run benchmarks against different solvers.

In Python, I’d be able to specify different dependencies for, e.g.: [dev] and [test], but it seems like the intended way to achieve this in Julia (for test code) to put that code in a test/ folder with its own Project.toml.

I’ve tried to do the same thing in my benchmarking code, creating a benchmarking/ folder inside my package folder (next to src/, test/, and the package Project.toml). Inside that folder I have a Project.toml with my additional dependencies.

I now have two questions:
1 - is this the right approach so far?
2 - how do I include my package as a dependency to my benchmarking code, so that I can import it?

1 Like

There’s special sauce for merging the src and test dependencies when running tests. You won’t get that for your benchmarking folder. Instead, a common approach is to dev the base package in the benchmarking environment. From the package folder, assuming your benchmarking environment is in ./benchmarking, do the following

$ julia --project=benchmarking
julia> ]
(benchmarking) pkg> dev .
(benchmarking) pkg> add <other benchmarking deps>

Now you should be able to import both your package and the benchmarking-specific dependencies when running code in the benchmarking environment.

5 Likes