Package: tox-ignore-env-name-mismatch
tox-ignore-env-name-mismatchReuse virtualenvs with multipletoxtest environments.If two environments have compatible specifications (basically, samedeps) and
use the sameenv_dir, installing this plugin and settingrunner = ignore_env_name_mismatchwill allow tox to use the same underlying
virtualenv for each test environment.Development status:EXPRIMENTAL- The API is evolving and things are breaking.
Please vendor the plugin as described below, or youwillget broken.UsageInstalltox-ignore-env-name-mismatchin the same environment astox.Setrunner = ignore_env_name_mismatchin a testenv to opt-out of recreating the virtualenv when the env name changes.To always use this plugin:Vendorcopysrc/tox_ignore_env_name_mismatch.pyto the root of your project
directory astoxfile.pyThis uses the tox4's new"inline
plugin"approach
instead of relying on the provisioning system (whichcan be disabled via
CLI).Install/provision[tox]
min_version = 4.3.3
requires =
    tox-ignore-env-name-mismatch ~= 0.2.0This will causetoxto provision a new virtualenv fortoxitself and other
dependencies named in therequireskey if the current
environment does not meet the specification.Pinning the plugin to a minor version ishighly recommendedto avoid breaking
changes.NOTE: tox < 4.3.3 hada bugwhich
prevented this type of installation.Example[tox]
envlist = py39,py310,py311,lint,format,types
min_version = 4.3.3
requires =
    tox-ignore-env-name-mismatch ~= 0.2.0

[testenv]
deps = pytest
commands = pytest {posargs}

[testenv:{lint,format,types}]
env_dir = {toxworkdir}{/}static
runner = ignore_env_name_mismatch
deps =
    black
    flake8
    mypy
commands =
    lint: flake8 src tests
    format: black --check src tests
    types: mypy --strict srcsee./examplesdirectory for a working example including the tox configuration above.Why??Typically this usage pattern is seen with "auxillary" environments that
perform project operations, like linting, generating docs, or publishing
packages. Using differenttestenvsections is a nice way to separatecommandsandpassenv/setenv, but creating separate virtualenv that would otherwise
use identical dependencies is both a waste of time and space.In tox 3, it was possible to achieve this behavior (with a bug and some caveats)
by simply having testenvs share anenv_dir. In tox 4, this hackaround was
properly fixed and now tox checks a cached{envdir}/.tox-info.jsonand
recreates the virtualenv if the current testenv doesn't match what is cached.This plugin allows a test environment to specifically opt-out of recreating
the virtualenv when only theenv_namediffers.This plugin only supports tox 4.MotivationPeople have been asking for this for at least 7 years and the coretoxproject
is specifically not interested in supporting this use case in tox 4 (which isfine, that's what plugins are for).[tox-dev/tox#2788] Re-use of virtual environments across envs in tox4[2022, Github]Reuse environment on Tox 4[2022, StackOverflow]tox multiple tests, re-using tox environment[2019, StackOverflow][tox-dev/tox#425] Ability to share tox environments within a project[2016, Github]Tox tricks and patterns#Environment reuse[2015, Blog]Changelogv0.2 - 2023-01-15[BREAKING]#3Rewrite plugin to use Public APITo upgrade to v0.2, changeignore_env_name_mismatch = truetorunner = ignore_env_name_mismatch.v0.1 - 2023-01-14Initial Release