# `conda_curation` `conda_curation` filters conda repositories (especially [Conda Forge](https://conda-forge.org/)) to remove packages based on a variety of criteria. - **Policy enforcement**: make insecure or disallowed packages (e.g. old Python interpreters, old OpenSSL/CA certificate bundles) unavailable. - **Solve performance**: shrinking repodata substantially speeds up conda client solves and builds (`mamba create --dry-run` and `mambabuild` get noticeably faster, and failed solves fail faster and cleaner). ## Command line usage ``` conda_curation [OPTIONS] ``` Positional argument: - `` — path to a YAML file of user-provided matchspecs (see [Matchspec file format](#matchspec-file-format)). Options: | Flag | Default | Description | | --- | --- | --- | | `-F, --ban-feature ` | (none) | Remove packages that track this feature. Repeatable. | | `-C, --must-compatible-with ` | (none) | Remove packages that are not compatible with any available candidate of `PACKAGE_NAME`. Repeatable. | | `--keep-dev` | (off) | Do not remove development (`dev`) packages. | | `--keep-rc` | (off) | Do not remove release-candidate (`rc`) packages. | | `--channel-alias ` | `https://conda.anaconda.org/conda-forge/` | Base URL used for downloading repodata (and recorded as output `base_url`; see [CEP-15](#cep-15-base_url)). A trailing slash is added automatically if missing. | | `--offline` | (off) | Use cached repodata and make no network calls. | | `-e, --explain` | (off) | Print the reason each package is being removed. | | `-o, --output-dir ` | `out` | Directory to write the filtered `repodata.json` files to (created if missing). | | `-a, --architecture ` | all supported | Which architecture subdirs to render. Repeatable. Allowed values are alphanumeric with hyphens/underscores/dots; `noarch` is not allowed because it is always included implicitly. Supported defaults: `linux-64`, `linux-aarch64`, `linux-ppc64le`, `osx-64`, `osx-arm64`, `win-64`. | ## Matchspec file format The matchspec YAML file is a mapping from package name to a list of conda matchspec strings (version and/or build constraints). A package only survives filtering if it matches **at least one** matchspec listed for it. Packages not named in the file are not filtered by this rule. Use an empty list (`[]`) to ban a package name entirely. Example (`matchspecs/secure_python.yaml`): ```yaml ca_certificates: - ">=2024" python: - ">=3.8.18,<3.9.0a0" - ">=3.9.18,<3.10.0a0" - ">=3.10.13,<3.11.0a0" - ">=3.11.6,<3.12.0a0" - ">=3.12.3,<3.13.0a0" python_abi: - ">=3.8" conda-forge-repodata-patches: [] ``` Minimal example (`matchspecs/newpython.yaml`): ```yaml python: - ">=3.12.3,<3.13.0a0" ``` ## Filtering performed Applied in order, to every requested architecture (plus `noarch`): 1. **User matchspecs** — remove packages that do not match any user-provided matchspec for that package name. 2. **Old builds** — remove packages superseded by newer builds (e.g. `python-3.9.18-h12345678_0` is removed when `python-3.9.18-h12345678_1` exists). 3. **Features** — remove packages tracking any `-F/--ban-feature` feature (e.g. `pypy`). 4. **dev & rc** — remove `dev` and `rc` packages (e.g. `2.0.0.dev0`, `2.0.0.rc0`) unless `--keep-dev` / `--keep-rc` is given. 5. **Incompatible architecture** — remove packages that cannot be installed on the target architecture. 6. **Compatibility pruning** — for each `-C/--must-compatible-with PACKAGE_NAME`, remove packages incompatible with every remaining candidate of that package. Example: with `-C python` and only `python >=3.12` allowed, `openssl 1.1.1n` is removed because `mamba create -n ... openssl==1.1.1n "python>=3.12"` cannot be solved. 7. **Unsolvable-package analysis (recursive)** — repeatedly remove packages that depend on already-removed dependencies (or that have no possible solution at all) until no more can be removed. E.g. filtering out Python 2.7 also removes every numpy build compiled against Python 2.7. ## Output For each requested architecture subdir and for `noarch`, a filtered `repodata.json` is written under the output directory (`-o/--output-dir`, default `out`): ``` out/ ├── noarch/repodata.json ├── linux-64/repodata.json ├── linux-aarch64/repodata.json ├── linux-ppc64le/repodata.json ├── osx-64/repodata.json ├── osx-arm64/repodata.json └── win-64/repodata.json ``` Progress is printed to stdout: per-round removal counts and timings, per-architecture package/edge counts, a final "Remaining: N (P% of original)" line per architecture, and a final "Noarch packages removed: X of Y" line. With `-e/--explain`, each removed package's reason is printed as well. ## CEP-15 `base_url` If the source repository (per `--channel-alias`) does not already have `info.base_url` set in its `repodata.json`, the output `repodata.json` gets `info.base_url` set to the `--channel-alias` (plus the subdir). If it was already set in the source repodata, it is preserved. If all clients support CEP-15, this removes the need for a redirecting proxy server for package downloads. ## Serving the output The tool only produces filtered repodata; you must bring your own HTTP/proxy server to serve packages. Redirect all `.*repodata.*\.json.*` URLs to the rendered output of `conda_curation`. This has been done with `nginx` using 301 redirects for asset downloads to an artifact server, or by putting nginx directly in front of the artifact server. ## Caching Repodata is downloaded into rattler's default cache directory. With `--offline`, only cached repodata is used and no network calls are made. ## Example invocations ```bash # Filter conda-forge using the bundled "secure_python" policy; output to ./out conda_curation matchspecs/secure_python.yaml # Only keep packages compatible with Python >=3.12, explain each removal, # and write to a specific directory conda_curation -C python -e -o my-channel matchspecs/newpython.yaml # Ban a feature and restrict architectures conda_curation -F pypy -a linux-64 -a osx-64 -o filtered matchspecs/secure_python.yaml # Re-run from cached repodata without network access conda_curation --offline -o filtered matchspecs/secure_python.yaml ```