Skip to content

package manager: allow one dependency to be fulfilled by one of many alternatives #10516

@kristoff-it

Description

@kristoff-it

Normally when a package has dependencies, all of them need to be provided for it to build successfully.

This proposal is about adding a mechanism that would allow to specify a dependency that can be satisfied by any package in a list of alternatives. The package manager at this point would be able to choose which element to provide based on a set of internal rules.

Since we haven't chosen yet a text format for enumerating dependencies, I'll use everyone's favorite to provide a concrete example. The syntax is not meant to be well designed, just focus on the semantics of the example.

tcp-client:
   version: 1
   deps: 
      - iguanaTLS@v2.2
 

http-client:
   version: 1
   deps: 
      - http-parser@v1
      - ssl: oneOf:
          - iguanaTLS@v2
          - libressl@v2
          - bearssl@v2
elazig-search:
   deps: 
      - bearssl@v2
      - http-client@v1
monzigdb:
   deps: 
      - tcp-client@v1
      - http-client@v1

So in this example you can see that http-client can use any of the mentioned tls libraries and how that can be useful to reduce the total number of dependencies when used by elazig-search and monzigdb.

More in general this feature could help the creation of "interface packages": packages whose only job is to extract a common interface from a set of concrete implementations for consumers that really value avoiding getting locked into a specific dependency. I think more could be said about the value of this practice but it's a bit outside of the scope of this proposal.

Not covered here but also necessary, is the ability to orchestrate the different optional dependencies in the Zig code (eg how can I add a conditional that depends on which dependency was fulfilled?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions