Crazy idea. Support "conditional dependencies"/"features" in a "sandbox"-analogous manner. (Note this is just meant to prod the search space, not as a serious/complete solution)
โโโ feature
โย ย โโโ A
โย ย โย ย โโโ Project.toml
โย ย โย ย โโโ src
โย ย โย ย โโโ A.jl
โย ย โโโ B
โย ย โโโ Project.toml
โย ย โโโ src
โย ย โโโ B.jl
โโโ Project.toml
โโโ src
โโโ Foo.jl
When someone runs add --feature=A Foo, Pkg will sandbox Foo in Foo/feature/A and add the result to the active dependency graph.
So Foo/src/Foo.jl will contain the core logic. Foo/feature/A/src/A.jl will contain the "A feature" logic.
Advantages:
I like it. This seems like a promising idea.
If this were to happen it could help with https://github.com/JuliaStats/Distributions.jl/issues/702 without needing Distributions to require Optim.
Doesn't Flux have some trick to handle this problem? I don't see CuArrays as a dependency, but...
https://fluxml.ai/Flux.jl/stable/gpu/
It uses Requires.jl, see #1285
I think https://github.com/JuliaLang/Pkg.jl/issues/1285 is a bit more recent take on this.
For the purpose of history, this proposal more closely resembles #1233, not #1285.
Most helpful comment
It uses Requires.jl, see #1285