From 59bf9ad26e4006b7f0338e5f78b8e97c24d5b815 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Fri, 22 Jan 2021 19:11:54 -0500 Subject: [PATCH] Add precondition check for skipping tox self-provisioned env Fixes #35 --- tox_poetry_installer/utilities.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tox_poetry_installer/utilities.py b/tox_poetry_installer/utilities.py index 8aee0c1..c3b8362 100644 --- a/tox_poetry_installer/utilities.py +++ b/tox_poetry_installer/utilities.py @@ -145,6 +145,16 @@ def find_transients( def check_preconditions(venv: ToxVirtualEnv, action: ToxAction) -> "_poetry.Poetry": """Check that the local project environment meets expectations""" + # Skip running the plugin for the provisioning environment. The provisioned environment, + # for alternative Tox versions and/or the ``requires`` meta dependencies is specially + # handled by Tox and is out of scope for this plugin. Since one of the ways to install this + # plugin in the first place is via the Tox provisioning environment, it quickly becomes a + # chicken-and-egg problem. + if action.name == venv.envconfig.config.provision_tox_env: + raise exceptions.SkipEnvironment( + f"Skipping Tox provisioning env '{action.name}'" + ) + # Skip running the plugin for the packaging environment. PEP-517 front ends can handle # that better than we can, so let them do their thing. More to the point: if you're having # problems in the packaging env that this plugin would solve, god help you.