installing minimal and flexible dependencies for Parsons
Our documentation aims to make getting started with Parsons as easy as possible, often trading that off against making the library easy to integrate into a larger code base. Notably, the most common installation (pip install parsons
) method uses pinned dependencies — specific versions of all the Python libraries Parsons may need.
In environments where Parsons is not the primary application, or in scenarios where Parsons must run with limited resources, we recommend users install only the dependencies they need at loose version constraints. To tell Parsons (and pip
, Python’s package manager) to take this route, we start by setting two environment variables:
# bash, zsh, etc.
export PIP_NO_BINARY=parsons
export PARSONS_LIMITED_DEPENDENCIES=true
# Windows CMD.EXE
set PIP_NO_BINARY=parsons
set PARSONS_LIMITED_DEPENDENCIES=true
PIP_NO_BINARY
tells pip
to use the source distribution of Parsons rather than the faster, but less-dynamic “wheels” version.
PARSONS_LIMITED_DEPENDENCIES
is checked at installation time to see whether to install fixed dependencies (the default) or a limited set (our goal).
Next we install Parsons, either with minimal dependencies or with one or more bundles of related dependencies:
# minimal set of dependencies
pip install parsons
# minimal set + Google-related dependencies
pip install parsons[google]
# minimal set + Google & NGPVAN-related dependencies
pip install parsons[google,ngpvan]
# all related dependencies (without strict version numbers)
pip install parsons[all]
To see the full list of available bundles, look for the definition of extras_require
in our setup.py.
And that’s it! You have just installed the dependencies you need, and at flexible versions, so they should play nice with the rest of your environment. This also greatly reduces your memory footprint (8x in one test)!
You can import connectors as you would in a full Parsons installation:
>>> from parsons import VAN
However, connectors that you do not have the dependencies for will not be available:
>>> from parsons import Airtable
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Airtable' from 'parsons' (/usr/local/lib/python3.10/site-packages/parsons/__init__.py)
Happy hacking!