Skip to main content

tox-interpreters

GitHub Actions codecov version python license Code style: black

What?

tox-interpreters enables overriding the logic tox follows in resolving base Python interpreters when it comes to virtual environment creation. It does so by allowing the user to bind test env names to the interpreters of their choice, by means of regular expressions.

Why?

I usually run tox from a permanent and isolated virtual environment, and I keep Python interpreters in multiple versions installed at the system level for tox itself to use whenever it needs to create a test environment.

It turns out that if the required Python version for a new environment matches the one tox is running from, tox will use its own Python interpreter as base to perform the creation, despite its belonging to a virtual environment - the system level interpreter will not be used.

The standard way of fixing this would be by setting basepython to the absolute path of the interpreter to be used for a specific environment. Unfortunately this becomes impractical as soon as a generative envlist with factors is involved.

Of course this is just one of the many possible use cases. Generally speaking, tox-interpreters aims at providing full consistency and flexibility in virtual environment creation across Python versions, by allowing the user to choose the base interpreter to be used depending on the name of the test environment.

Installation

tox-interpreters has been developed as a tox plugin, therefore it has to be installed along with tox itself.

$ pip install tox-interpreters

Usage

To use tox-interpreters, add the setting interpreter to the [testenv] section of your tox configuration file (typically tox.ini), as follows:

[testenv]
interpreter =
    py37.*=/path/to/python3.7
    py38.*=/path/to/python3.8

The interpreter setting accepts a list of <regex>=<interpreter> lines as value. Each line binds a regular expression to an interpreter.

Whenever a new test environment needs to be created, the selection of the base Python interpreter is performed by checking the name of the environment against all the regular expressions, in order. The interpreter bound to the first matching regex will be used.

In case of no match, the selection logic falls back to the standard behaviour of tox - that is, everything works just as if tox-interpreters wasn't installed at all.

Interpreters can be specified by their absolute path or just by their file name. In the latter case, the path to the file needs to be in the PATH environment variable for virtual environment creation to succeed.

[testenv]
interpreter =
    py37.*=/path/to/python3.7
    py38.*=python3.8

License

See: LICENSE

MIT License

Copyright (c) 2019 Fabio Sangiovanni

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for tox-interpreters 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tox-interpreters 0.1.0
File Size Uploaded
tox-interpreters-0.1.0.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tox-interpreters 0.1.0
File Interpreter ABI Platform
tox_interpreters-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / tox-interpreters-0.1.0.tar.gz

Download URL tox-interpreters-0.1.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6033203ff4a7252ae9a7e60e018568d09f4c6db096af88b3f1607dc10366f7aa
BLAKE2b-256 checksum
How to use checksums
9004178715308489038e86abc32aefb3ee2cbaf33d69939b4a29aa3270e83c41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.8.0

Release files / tox_interpreters-0.1.0-py3-none-any.whl

Download URL tox_interpreters-0.1.0-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2301ebf03a6d68a8bb9dce1b29eefc544607bc601b5d1e42534f4daf8fd4462a
BLAKE2b-256 checksum
How to use checksums
86d13d4403a160063c8eac792abb338f697d1dcd6fe3f9cdd4b9545089f7f2f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.8.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page