Pkg.jl: Conditional Dependencies

Created on 24 Feb 2019  ยท  6Comments  ยท  Source: JuliaLang/Pkg.jl

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:

  • No need to query for which features are activated, it is apparent from the filesystem location
  • Conceptually reinforces "environments" as an organizational unit.
feature request

Most helpful comment

It uses Requires.jl, see #1285

All 6 comments

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.

Was this page helpful?
0 / 5 - 0 ratings