Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use tox with conda-based Python installations?

Tags:

python

conda

tox

The Python testing tool tox seems to be designed to work with virtualenv. Can it also work on conda/anaconda-based Python installations?

like image 846
cmeeren Avatar asked May 31 '15 09:05

cmeeren


People also ask

Can I mix pip and conda?

pip is the standard package manager for python, meaning you can use it both inside and outside of Anaconda.

Can I install Python using conda?

The Earth Engine Python API can be installed to a local machine via conda, a Python package and environment manager. Conda is bundled with Anaconda and Miniconda Python distributions.

Which Python is conda using?

Conda treats Python the same as any other package, so it is easy to manage and update multiple installations. Anaconda supports Python 3.7, 3.8, 3.9 and 3.10. The current default is Python 3.9.


1 Answers

The tox-conda plugin should close that gap nowadays, but needs contributors who actively use conda to test and improve it.

from the README:

tox-conda is a plugin that provides integration with the conda package and environment manager for the tox automation tool. It's like having your cake and eating it, too!

By default, tox creates isolated environments using [virtualenv](https://virtualenv.pypa.io] and installs dependencies from pip.

In contrast, when using the tox-conda plugin tox will use conda to create environments, and will install specified dependencies from conda. This is useful for developers who rely on conda for environment management and package distribution but want to take advantage of the features provided by tox for test automation.

To install that plugin it needs to be installed alongside tox in the same virutal environment. To create a virtual environment containing tox and tox-conda this should suffice:

$ python3 -m venv toxbase $ toxbase/bin/pip install tox tox-conda [...] Successfully installed tox-3.13.2 tox-conda-0.2.0 $ toxbase/bin/tox --version 3.13.1 imported from /home/ob/tmp/toxbase/lib/python3.6/site-packages/tox/__init__.py registered plugins:     tox-conda-0.2.0 at /home/ob/tmp/toxbase/lib/python3.6/site-packages/tox_conda/plugin.py 

from then on tox can be used as a command line tool and kept current by upgrading it in the toxbase virtualenv. Another, more automated way would be to use pipx

like image 63
Oliver Bestwalter Avatar answered Sep 19 '22 20:09

Oliver Bestwalter