Package: tox-interpreters
tox-interpretersWhat?tox-interpretersenables overriding the logictoxfollows 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 runtoxfrom a permanent and isolated virtual environment,
and I keep Python interpreters in multiple versions installed at the
system level fortoxitself 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 onetoxis running from,toxwill use itsownPython
interpreter as base to perform the creation, despite its belonging to a
virtual environment - the system level interpreter willnotbe used.The standard way of fixing this would be by settingbasepythonto 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-interpretersaims 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.Installationtox-interpretershas been developed as atoxplugin, therefore it
has to be installed along withtoxitself.$pipinstalltox-interpretersUsageTo usetox-interpreters, add the settinginterpreterto the[testenv]section of yourtoxconfiguration file (typicallytox.ini), as follows:[testenv]interpreter=py37.*=/path/to/python3.7py38.*=/path/to/python3.8Theinterpretersetting 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 oftox- that is, everything works just as iftox-interpreterswasn'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 thePATHenvironment variable for virtual environment creation to succeed.[testenv]interpreter=py37.*=/path/to/python3.7py38.*=python3.8LicenseSee:LICENSEMIT LicenseCopyright (c) 2019 Fabio SangiovanniPermission 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.