Allow to specify constraints without depending on a package
Problem to solve
Example use cases:
- The ABC interpreter needs to have a constraint on
base-compiler
andbase-compiler-itasks
, to make sure that the bytecode generator works for the generated ABC code. However, for the interpreter to work it is not necessary that either of the two is installed; just one of them. - A package defines types for dealing with [some domain]. It should be possible to use most functionality with just
base
, but you also want to provide JSON or iTasks instances in separate modules. You then want to specify a constraint onjson
oritasks
, but you don't want these packages to be installed always; the constraint should only be used if there is already a dependency on this package anyway to further restrict the allowed versions.
Proposal
All these cases can be solved by allowing packages to specify constraints without forcing a dependency. Such a constraint would be resolved by still allowing the 'unused' constructor in Z3, and would thus only be applied if there is another package that actually requires the dependency.
It is probably best to add this as an extra option in dependencies themselves, instead of adding a separate field optional_dependencies
:
dependencies:
base-compiler-itasks:
version: ^1 || ^2
optional: true
This allows us to use the same format in test_dependencies
and build_dependencies
. There should still be the short format base-compiler-itasks: ^1 || ^2
of course, with default optional: false
. optional: true
should only be allowed with scope: Use
.
Steps to take:
-
Implement optional
. -
Add support in clean-lang.org to display optional dependencies.
It is not clear to me if this is unproblematic.
Documentation
The nitrile.yml reference.