Developer Tools That Simplify Your Life (2 Part Series)
1 Installing CLI Tools Using ‘dephell’
2 Using Python3’s ‘venv’ with tox
Using the built-in Python module in favor of
virtualenv
to create your testing or project automation environments.
tox
is a generic virtualenv management and test command line tool, especially useful for multi-environment testing. It has a plugin architecture, with plenty of both built-in and 3rd party extensions.
This post assumes you are already familiar with tox
and have a working configuration for it. If not, check out its documentation.
In order to make tox
use the built-in virtual environment venv
of Python 3.3+, there is a plugin named tox-venv that switches from using virtualenv
to venv
whenever it is available.
tox-dev / tox-venv
Use Python 3 venvs for Python 3 test environments
Typically, venv
is more robust when faced with ever-changing runtime environments and versions of related tooling (pip
, setuptools
, …).
To enable that plugin, add this to your tox.ini
:
<span>[tox]</span><span>requires</span> <span>=</span> <span>tox-venv</span><span>[tox]</span> <span>requires</span> <span>=</span> <span>tox-venv</span>[tox] requires = tox-venv
That merely triggers tox
to check (on startup) that the plugin is installed. You still have to add it to your dev-requirements.txt
or a similar file, so it gets installed together with tox
. You can also install tox
globally using dephell jail install tox tox-venv
– see the first post in this series for details.
The end result is this (call tox -v
to see those messages):
<span>py38</span> <span>create:</span> <span>…/.tox/py38</span><span>…/.tox$</span> <span>/usr/bin/python3.8</span> <span>-m</span> <span>venv</span> <span>py38</span> <span>>…/log/py38-0.log</span><span>py38</span> <span>create:</span> <span>…/.tox/py38</span> <span>…/.tox$</span> <span>/usr/bin/python3.8</span> <span>-m</span> <span>venv</span> <span>py38</span> <span>>…/log/py38-0.log</span>py38 create: …/.tox/py38 …/.tox$ /usr/bin/python3.8 -m venv py38 >…/log/py38-0.log
And there you have it, no more virtualenv package needed.
Developer Tools That Simplify Your Life (2 Part Series)
1 Installing CLI Tools Using ‘dephell’
2 Using Python3’s ‘venv’ with tox
暂无评论内容