Best practice for creating and managing dependancies of folders that are not needed by the package itself

Say I have a package “MyPkg.jl” with the following structure:

MyPkg.jl/Manifest.toml
MyPkg.jl/Project.toml
MyPkg.jl/src/MyPkg.jl
MyPkg.jl/benchmark/benchmark.jl

where benchmark.jl is a script that produces benchmark statistics for MyPkg.jl and has additional dependancies to MyPkg.jl.

What is the best way to handle the dependancies of benchmark.jl?

Ideally I’d like to simply add [extras] with [targets] that point to benchmark but this looks to only be an option for targets test and build 3297

1 Like

What I do for docs and benchmarks is create a dedicated Project.toml at the root of the subfolder, in which I pkg> dev the main package. The case of testing is a bit peculiar, and I prefer to use extras for that (see here why, although that might be fixed soon).

In the long run, you probably want to follow this GitHub issue, which describes exactly what we both seem to dream of:

2 Likes

On the same page as mentioned by Guillaume, you might also want to have a look at Run.jl

Reproducible runs not only for test but also for any sub-projects (docs, benchmarks, etc.)

It also simplifies CI

2 Likes

I’m still not 100% there:

[1] I created a ./benchmark/Project.toml with the corresponding dependancies.
[2] All benchmark dependancies are included as [extras] in the main package Project.toml.
[3] I then activate ./benchmark/Project.toml
[4] I then pkg> dev the main package

However this last step creates ./benchmark/Manifest.toml which I don’t think should be there. Is this typical? Do I simply apply a gitignore to ./benchmark/Manifest.toml when syncing with the repository?

For the docs and benchmarks you usually want the manifest to be there, so that the whole thing is fully reproducible. Don’t put it in the gitignore, just let it be :slight_smile:

1 Like