Feature: Support compatibility constraints
Summary
Provide a new feature allowing users to specify additional packages they want the solved environment to be compatible with, but without actually downloading or installing those packages.
Use case
In many of our workflows, the software dependencies in our production environments are a strict subset of our development environments. For example, one would not need pytest or gtest in production. These differing sets of dependencies can result in differently solved environments (see example), which is suboptimal for ensuring software behaves identically during development and production.
One possible solution is to install additional dependencies in production to enforce consistency with the development environment. However, it does not really make sense to waste production resources in this way.
This feature allows you to create environments as if those additional dependencies were also present. The resulting environment is compatible with those additional dependencies, but does not contain them because they are not actually required. All installed packages would then have the same consistent version.
Example
Here we describe a toy and somewhat contrived example. Imagine if, the production environment requires only numpy=1.21.1, and the development environment additionally requires pytest=6.0.1. Then, let's try:
mamba create -yq -n example-prod -c conda-forge numpy=1.21.1
mamba create -yq -n example-dev -c conda-forge numpy=1.21.1 pytest=6.0.1
conda list -n example-prod "^python$"
conda list -n example-dev "^python$"
The resulting environments contain Python 3.9.6 in prod, but only Python 3.8.10 in dev. This is inconsistent, which isn't very good. Although this is a very contrived example (eg. the developer can simply update to the latest pytest), with more complex dependencies a simple solution does not always exist (eg. perhaps the latest version still only supports Python 3.8).
Given the new feature, we can instead create the production environment with the following command to maintain compatibility without installing pytest.
mamba create -yq -n example-prod -c conda-forge numpy=1.21.1 --compatible pytest=6.0.1
(We're also open to renaming this command-line argument to something else instead of -x,--compatible.)
Implementation
We add a component to the transaction's filter to ensure that only relevant specs are actioned upon. After the environment is solved, we perform a multi-source BFS through the dependency graph, using as starting nodes the set of specs the user has explicitly requested mamba to install. Any specs not visited by this BFS are filtered out of the transaction.
Tasks checklist
- [x] Implement feature and link to micromamba
- [ ] Discuss and reach consensus about implementation and usage of the feature
- [ ] Add tests (after above discussion)
- [ ] Add bindings to expose functionality to mamba
FYI: @wolfv @fhoehle