Package: conda-pip-minimal
conda cpmSimple tool to generate minimal versions of Conda environments, also includingpipdependencies, for cross-platform sharing.Built on top ofconda treeandpipdeptree. Inspired byconda minify.Why useconda cpm?Conda (especially with mamba) is a great tool to manage Python virtual
environments, especially if you need to install some non-Python dependencies,
or use compiled dependencies like CUDA. Seehttps://aseifert.com/p/python-environments/for more on this.I use Conda preferentially to install any packages available through it; and
provide my virtualenv’s Python version through Conda.Some packages are not easily accessible on Conda, and I usepiporpoetry(orhatchor your other tool of choice) to pull those packages in.This approach works remarkably well, but when it is time to share my
environment with others, there are several ways to do it, and they are subtly
different in capabilities and issues.e.gconda env export,conda env export --from-history,conda list --exportFor pip-installed packages,pip freeze,pip list --freeze, or whatever
your favorite Python package manager provides.conda-lock, pipenv, and other lock file generating toolsIf the exported file is too specific, specifying every dependency and build
identifier, it often cannot be reproduced on a different platform because
these are not portable.If you use bothcondaandpip, these tools will typically be unaware of
each other, generating overlapping requirements files.How doesconda cpmsolve this?conda cpmconstructs a minimalenvironment.ymlfile, with only the
"leaves" of the dependency tree, both forpipandconda.It retains information about which packages came from Conda and which came
from Pip, but does not include dependencies in the export.It specifies exact versions by default, but it can optionally relax the
version requirements to being flexible at the patch level or minor level
(semver).It can optionally include info about which Conda channel a package came from,
the Python version, or any manually specified packages.It does not include system-specific information like the Conda environment
prefix.Installationvia pippip install conda-pip-minimalvia pipxpipx install conda-pip-minimalRun without installingpipx run conda-pip-minimal --helpUsageThe script for this package is namedconda-cpm; so it can be run likeconda cpm$condacpm[OPTIONS]Options:-p, --prefix PATH: Conda env prefix-n, --name TEXT: Conda env name--pip / --no-pip: Include pip dependencies  [default: True]--relax [none|major|minor|full]: [default: full]--include TEXT: Packages to always include  [default: python, pip]--exclude TEXT: Packages to always exclude  [default: ]--channel / --no-channel: Add channel to conda dependencies  [default: False]--debug / --no-debug: [default: False]--help: Show this message and exit.ExamplesHere are a few example runs for this package:From within the conda environment:❯condacpm
dependencies:
-python=3.8.13
-pip=22.2.2
-pip:-conda-pip-minimal==0.1.0-ipython==8.5.0-snoop==0.4.2-trio-typing==0.7.0
name:/home/venky/dev/conda-pip-minimal/.venvSpecifying the conda environment❯condacpm--prefix~/dev/conda-pip-minimal/.venv
dependencies:
-pip=22.2.2
-python=3.8.13
-pip:-conda-pip-minimal==0.1.0-ipython==8.5.0-snoop==0.4.2-trio-typing==0.7.0
name:/home/venky/dev/conda-pip-minimal/.venvExclude packages❯condacpm--prefix~/dev/conda-pip-minimal/.venv--excludesnoop--excludetrio-typing
dependencies:
-python=3.8.13
-pip=22.2.2
-pip:-conda-pip-minimal==0.1.0-ipython==8.5.0
name:/home/venky/dev/conda-pip-minimal/.venvInclude a normally-excluded dependency❯condacpm--prefix~/dev/conda-pip-minimal/.venv--includetrio
dependencies:
-trio=0.22.0
-pip:-conda-pip-minimal==0.1.0-ipython==8.5.0-snoop==0.4.2-trio-typing==0.7.0
name:/home/venky/dev/conda-pip-minimal/.venvSpecify conda channels❯condacpm--prefix~/dev/conda-pip-minimal/.venv--channel
dependencies:
-conda-forge::python=3.8.13
-conda-forge::pip=22.2.2
-pip:-conda-pip-minimal==0.1.0-ipython==8.5.0-snoop==0.4.2-trio-typing==0.7.0
name:/home/venky/dev/conda-pip-minimal/.venvRelax versions❯condacpm--prefix~/dev/conda-pip-minimal/.venv--relaxminor
dependencies:
-python=3.8.*
-pip=22.2.*
-pip:-conda-pip-minimal==0.1.*-ipython==8.5.*-snoop==0.4.*-trio-typing==0.7.*
name:/home/venky/dev/conda-pip-minimal/.venvSkip pip dependenciesWhy would you want to do this, though?❯condacpm--prefix~/dev/conda-pip-minimal/.venv--no-pip
dependencies:
-pip=22.2.2
-python=3.8.13
name:/home/venky/dev/conda-pip-minimal/.venv