Managing python installations¶
virtualenv¶
The basic building block for Python-based components is creation of virtualenvs (to separate package installations from each other):
self += VirtualEnv('2.7')
- class batou.lib.python.VirtualEnv(version)¶
Creates a virtualenv for the given Python version in the working directory of the parent component. (Requires that
pythonX.Yis in thePATH)
- executable¶
Full path to the Python executable to create the virtualenv for (default:
pythonX.Ybased on the version attribute).
batou downloads a compatible version of virtualenv (depending on the Python
version you need) to ensure everything works as expected and to avoid problems
with incompatibilities or unexpected behaviours of whatever version might be
installed already on the system. (virtualenv base installations are shared by
all components for creating new virtualenvs, it is installed to
work/.virtualenv).
Installing packages¶
Python packages are installed from a package index such as PyPI. batou uses pip or easy_install for this purpose (but that actually is an implementation detail and depends on the specifics of the Python and virtualenv version).
Packages must be added to a virtual environment.
venv = VirtualEnv('2.7')
self += venv
venv += Package('Sphinx', version='1.1.3')
- class batou.lib.python.Package(package)¶
Install the Python package with the given name into the virtualenv of the parent component. Using
Packagerequires that it is added to aVirtualEnvinstance.
- version¶
The version of the package to install (required).
- install_options¶
List of options that are passed to pip/easy_install on the command line.
[Default: depends on the Python/virtualenv version in use]
- timeout¶
A timeout (in seconds) that the installer should use to limit stalling network activity.
Only works when using
pip.[Default: equal to the environment’s timeout setting]
- dependencies¶
Whether only the package itself or its dependencies should be installed.
[Default: True]
zc.buildout¶
batou has in-depth support for managing installations that use buildout. It automatically wraps them in a virtualenv, installs the appropriate buildout version, and takes care of running buildout whenever changes to configuration files makes it necessary. A typical usage example:
self += Buildout(python='3.7', version='2.2', setuptools='1.0',
pip='21.1',
additional_config=[Directory('profiles', source='profiles')])
- class batou.lib.buildout.Buildout¶
Manage a buildout installation
- python¶
Python version (required)
- executable¶
Full path to the python executable to create the virtualenv for (used instead of
pythonX.Y).
- version¶
Version of zc.buildout to install (required)
- setuptools¶
Version of setuptools to install into the virtualenv (must be appropriate to the buildout version, e.g. since 2.2 buildout requires setuptools, but some versions before that required distribute) (required)
- pip¶
Version of pip to install into the virtualenv (must be appropriate to the buildout version).
- distribute¶
Version of distribute to install into the virtualenv. Mutually exclusive with
setuptools, of course.