All the messy tools in python

Python Packaging Authority is the organisation which manages all the core tools supporting python

Package Managers

Purpose: only manage python packages inside a python installation (typically present under lib/site-packages)

Packages are libraries and/or cli application, written in python / depend on python interpreter
Packages are (typically) installed from a remote repo such as PyPi, Conda

The pip is the basic package manager, installed with every python, present as executable + python module.
pip depends on its “parent” python (the one with which it was installed)

pip typically installs the packages in its parent python’s site packages folder, OR in the virtual env it resides in

By default, the “venv” command will create a new binary of “pip” particular to that environment, which will install new packges in that environment itself

pipx is a python cli specialized package installer. It can only be used to install packages with cli entrypoints in their isolated envrionments.
it lets you install cli applications but NOT libraries that you import in your code.
pipx relies on its parent python, pip (and venv)

Virtual Environment Managers

Purpose: python offers virtual environments to isolate packages, so that your different applications can use different versions of the packages.

virtualenv is the OG python environment manager.
Since Python 3.3, a subset of it has been integrated into the standard library under the venv module. See doc for differences.
virtualenv is a CLI tool, while venv is only available as a python module (need to run as python -m venv)

By default, different virtual envrironments generated from the same virtualenv/venv comand, will share the parent python executable. The site-packages will not be shared among virtual environments, that’s how you get package isolation

Python Version Managers

Purpose: manage different versions of the python interpreter itself.

pyenv is a python version manager. pyenv is not part of the Python Packaging Authority
Important thing is pyenv does not depend on python at all, its mostly written in shell scripts.
It also supports virtual environment using a plugin pyenv-virtualenv.

And here comes… Conda and Mamba

Conda: Python Version Manager + Package Manager + Environment Manager
So use conda, be at ease !
at least until the licence is not changed

mamba (hosted at mamba-org/mama ) is alternative to conda, written in C, fully compatible with conda packages (at least the one in conda-forge).
Although it started as a wrapper over conda, now some core functionalities are written in C. So its faster.
Main differentiater was faster package dependency resolver using libsolv (also used in rpm, yum)
Although in 2023 conda also added libmamba-solver

Anyway, the goal of “mamba-org” is to provide conda-like features while removing dependency anaconda.com
They are planning to self-host another repository. See quetz. Learn more.

Also mamba encourages users to use conda-forge channel, and remove conda’s default channel. Learn more

The Anaconda default channels are incompatible with conda-forge.

The mamba-org actually provides has 2 tools,

mamba : depends on conda for some features. Similar to conda it has base environment. The installer also has pre-configured .condarc/.mambarc files.
conda-forge/Miniforge is a community-driver installer which installs both mamba and conda. It replaces Miniconda. In this case, both conda and mamba share the base environment, and install packages and create new envs in ~/miniforge3 folder. Miniforge also sets the conda-forge as the default package repository for both conda and mamba, removing anaconda’s default.

micromamba : micromamba is a small, pure-C++ reimplementation of mamba/conda. It strives to be a full replacement for mamba and conda. As such, it doesn’t use any conda code (in fact it doesn’t require Python at all).
By default it provides a completely empty base environment (unlike conda or mamba which contain their dependencies)
See the documentation on micromamba for details.

What to do in future if conda is banned?

Or if conda has some licensing issue.
Then you can move to these options, from easy to hard

  1. Use micromamba which is totally independent from conda. The full mamba may or may not be useful since it (at least at the time of writing) depends on conda for some features.

  2. Use pyenv with its virtual env plugin, and inside each enviironment use pip to manage packages. Using pyenv is preferred since its independent of python.

  3. Use your system’s package manager (apt, brew) to install virtualenv . Use virtualenv to manage multiple pythons and envrionments, and pip for package management.

Python Development Tools

setuptools is the OG python packaging tool, comes by default with every python. Used in projects to define project dependencies and to build projects. Very less automation, need to mannually write setup.py or (the recently standardized) pyproject.toml manifest files.

pipenv: Pipenv automatically creates and manages a virtualenv for your projects, as well as adds/removes packages from your Pipfile  as you install/uninstall packages. nicely bridges the gaps between pip, python (using system python, pyenv or asdf) and virtualenv

poetry : is more or less pipenv+setuptools with its own customisations and features. It is not part of the pypa. more on poetry

A good read comparing pipenv, setuptools and poetry: