• Stars
    star
    152
  • Rank 238,233 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created about 6 years ago
  • Updated 6 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make tox cooperate with conda envs

tox-conda

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. PyPI version Python versions CI Code coverage

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 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.

tox-conda has not been tested with conda version below 4.5.

Getting Started

tox-conda can be used in one of two ways: by installing it globally and by enabling it on a per-project basis. When the plugin is installed globally, the default behavior of tox will be to use conda to create environments. To use it on a per-project basis instead, use tox's auto-provisioning feature to selectively enable the plugin.

To enable the use of tox-conda by default, follow the Installation instructions. To use the plugin selectively, do not manually install it, but instead enable it by adding tox-conda as a provisioning requirement to a project's tox config:

[tox]
requires = tox-conda

More information on auto-provisioning can be found in the tox documentation.

Installation

The tox-conda package is available on pypi. To install, simply use the following command:

$ pip install tox-conda

To install from source, first clone the project from github:

$ git clone https://github.com/tox-dev/tox-conda

Then install it in your environment:

$ cd tox-conda
$ pip install .

To install in development mode:

$ pip install -e .

The tox-conda plugin expects that tox and conda are already installed and available in your working environment.

Usage

Details on tox usage can be found in the tox documentation.

With the plugin enabled and no other changes, the tox-conda plugin will use conda to create environments and use pip to install dependencies that are given in the tox.ini configuration file.

tox-conda adds four additional (and optional) settings to the [testenv] section of configuration files:

  • conda_deps, which is used to configure which dependencies are installed from conda instead of from pip. All dependencies in conda_deps are installed before all dependencies in deps. If not given, no dependencies will be installed using conda.
  • conda_channels, which specifies which channel(s) should be used for resolving conda dependencies. If not given, only the default channel will be used.
  • conda_spec, which specifies a conda-spec.txt file that lists conda dependencies to install and will be combined with conda_deps (if given). These dependencies can be in a general from (e.g., numpy>=1.17.5) or an explicit form (eg., https://conda.anaconda.org/conda-forge/linux-64/numpy-1.17.5-py38h95a1406_0.tar.bz2), however, if the @EXPLICIT header is in conda-spec.txt, all general dependencies will be ignored, including those given in conda_deps.
  • conda_env, which specifies a conda-env.yml file to create a base conda environment for the test. The conda-env.yml file is self-contained and if the desired conda channels to use are not given, the default channels will be used. If the conda-env.yml specifies a python version it must be compatible with the basepython set for the tox env. A conda-env.yml specifying python>=3.8 could for example be used with basepython set to py38, py39 or py310. The above conda_deps, conda_channels, and conda_spec arguments, if used in conjunction with a conda-env.yml file, will be used to update the environment after the initial environment creation.
  • conda_create_args, which is used to pass arguments to the command conda create. The passed arguments are inserted in the command line before the python package. For instance, passing --override-channels will create more reproducible environments because the channels defined in the user's .condarc will not interfer.
  • conda_install_args, which is used to pass arguments to the command conda install. The passed arguments are inserted in the command line before the dependencies. For instance, passing --override-channels will create more reproducible environments because the channels defined in the user's .condarc will not interfer.
  • If mamba is installed in the same environment as tox, you may use it instead of the conda executable by setting the environment variable CONDA_EXE=mamba in the shell where tox is called.

An example configuration file is given below:

[tox]
envlist =
    {py35,py36,py37}-{stable,dev}

[testenv]
deps=
    pytest-sugar
    py35,py36: importlib_resources
    dev: git+git://github.com/numpy/numpy
conda_deps=
    pytest<=3.8
    stable: numpy=1.15
conda_channels=
    conda-forge
conda_install_args=
    --override-channels
commands=
    pytest {posargs}

More information on tox configuration files can be found in the documentation.

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, "tox-conda" is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

More Repositories

1

tox

Command line driven CI frontend and development task automation tool.
Python
3,558
star
2

pipdeptree

A command line utility to display dependency tree of the installed Python packages
Python
2,710
star
3

filelock

A platform-independent file lock for Python.
Python
696
star
4

sphinx-autodoc-typehints

Type hints support for the Sphinx autodoc extension
Python
531
star
5

tox-travis

Seamless integration of tox into Travis CI
Python
203
star
6

tox-docker

A tox plugin to run one or more Docker containers during tests
Python
173
star
7

pyproject-fmt

Python
160
star
8

tox-pyenv

plugin that tells tox to use `pyenv which` to find python executables
Python
127
star
9

tox-pipenv

A pipenv plugin for Tox
Python
123
star
10

detox

distributed tox (tox plugin to run testenvs in parallel)
Python
48
star
11

tox-ini-fmt

Formats your tox.ini files
Python
40
star
12

tox-gh

Github Action support for tox 4 and later
Python
39
star
13

azure-pipelines-template

template for your azure pipelines
24
star
14

tox-uv

Use https://github.com/astral-sh/uv with tox
Python
23
star
15

tox-venv

Use Python 3 venvs for Python 3 test environments
Python
21
star
16

pyproject-api

API to interact with the python pyproject.toml based projects
Python
21
star
17

sphinx-argparse-cli

Render CLI arguments (sub-commands friendly) defined by the argparse module.
Python
20
star
18

pyproject-fmt-rust

Rust
8
star
19

devpi-process

Python
7
star
20

gh-action-tox

Run tox as a Github Action
Dockerfile
6
star
21

tox-report

Records tox console output and produces a colored HTML report with it.
Python
6
star
22

tox-extra

Tox plugin which adds few extra checks like assuring that git does not report dirty
Python
5
star
23

cookiecutter-tox-plugin

Cookiecutter template for tox plugins
Python
5
star
24

tox-bindep

Tox plugin to run bindep checks before tests
Python
4
star
25

workflow

3
star
26

tox-external-wheels

A plugin for tox to allow external wheels for testing
Python
3
star
27

py-discovery

Python
1
star