Skip to content

Commit 16ecfb6

Browse files
committed
multi-output: document full/lite splits for optional dependencies.
1 parent 0d193e9 commit 16ecfb6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/maintainer/knowledge_base.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,37 @@ add some information on r packages which make heavy use of `noarch: generic`
16551655
- [importlib_metadata and importlib-metadata](https://github.com/conda-forge/importlib_metadata-feedstock/blob/main/recipe/meta.yaml)
16561656
- [typing_extensions and typing-extensions](https://github.com/conda-forge/typing_extensions-feedstock/blob/main/recipe/meta.yaml)
16571657

1658+
### Common patterns
1659+
1660+
#### Splitting out heavy optional dependencies
1661+
1662+
When a package has especially large optional dependencies it can be useful to split the package into a "lite" version that depends only on the core dependencies and a "full" version that depends on the "lite" version and all optional dependencies. The `pin_subpackage` function helps to ensure that the "full" version will pull the exact version of the "lite" version. As an example consider the [seaborn recipe](https://github.com/conda-forge/seaborn-feedstock/blob/eec88f0116a26c2e205daab10193e38e96407cab/recipe/meta.yaml) with optional statsmodels dependency:
1663+
1664+
```yaml
1665+
- name: seaborn
1666+
build:
1667+
noarch: python
1668+
requirements:
1669+
run:
1670+
- statsmodels >=0.12
1671+
- {{ pin_subpackage('seaborn-base', exact=True) }}
1672+
```
1673+
1674+
In order to prevent the "lite" version `seaborn-base` to pull in seaborn versions before the package split, `run_constrained` will ensure that the `seaborn-base` package can only be installed together with the matching version of the `seaborn` package.
1675+
1676+
```yaml
1677+
- name: seaborn-base
1678+
build:
1679+
noarch: python
1680+
requirements:
1681+
run_constrained:
1682+
- seaborn ={{ version }}=*_{{ build }}
1683+
```
1684+
1685+
:::important
1686+
Counter-intuitively `{{ pin_subpackage('seaborn-base', exact=True) }}` will only work in the requirements section but not in `run_constrained` (see [conda-build#4415](https://github.com/conda/conda-build/issues/4415)). Use `seaborn ={{ version }}=*_{{ build }}` to ensure that the `seaborn-base` package can only be installed with the matching version of the `seaborn` package.
1687+
:::
1688+
16581689
### Common pitfalls with `outputs`
16591690

16601691
This is a non-exhaustive list of common pitfalls when using `outputs`.

0 commit comments

Comments
 (0)