mirror of
https://github.com/enpaul/tox-poetry-installer.git
synced 2025-01-14 08:33:31 +00:00
implement tox_add_option hook
This commit is contained in:
parent
0693ce4706
commit
c81215bc3b
6
tox.ini
6
tox.ini
@ -20,7 +20,7 @@ commands =
|
||||
|
||||
[testenv:static]
|
||||
description = Static formatting and quality enforcement
|
||||
basepython = py3.10
|
||||
basepython = py310
|
||||
platform = linux
|
||||
ignore_errors = true
|
||||
locked_deps =
|
||||
@ -45,7 +45,7 @@ commands =
|
||||
|
||||
[testenv:static-tests]
|
||||
description = Static formatting and quality enforcement for the tests
|
||||
basepython = py3.10
|
||||
basepython = py310
|
||||
platform = linux
|
||||
ignore_errors = true
|
||||
locked_deps =
|
||||
@ -62,7 +62,7 @@ commands =
|
||||
|
||||
[testenv:security]
|
||||
description = Security checks
|
||||
basepython = py3.10
|
||||
basepython = py310
|
||||
platform = linux
|
||||
ignore_errors = true
|
||||
skip_install = true
|
||||
|
@ -1,4 +1,5 @@
|
||||
# pylint: disable=missing-docstring
|
||||
from tox_poetry_installer.hooks import tox_add_core_config
|
||||
from tox_poetry_installer.hooks import tox_add_env_config
|
||||
from tox_poetry_installer.hooks import tox_add_option
|
||||
from tox_poetry_installer.hooks import tox_on_install
|
||||
|
@ -7,6 +7,7 @@ themselves manageable).
|
||||
from itertools import chain
|
||||
from typing import List
|
||||
|
||||
from tox.config.cli.parser import ToxParser
|
||||
from tox.config.sets import ConfigSet
|
||||
from tox.config.sets import EnvConfigSet
|
||||
from tox.plugin import impl
|
||||
@ -31,6 +32,25 @@ def tox_add_core_config(core_conf: ConfigSet):
|
||||
)
|
||||
|
||||
|
||||
@impl
|
||||
def tox_add_option(parser: ToxParser):
|
||||
"""Add additional command line arguments to tox to configure plugin behavior"""
|
||||
parser.add_argument(
|
||||
"--require-poetry",
|
||||
action="store_true",
|
||||
dest="require_poetry",
|
||||
help="(deprecated) Trigger a failure if Poetry is not available to Tox",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--parallel-install-threads",
|
||||
type=int,
|
||||
dest="parallel_install_threads",
|
||||
default=constants.DEFAULT_INSTALL_THREADS,
|
||||
help="Number of locked dependencies to install simultaneously; set to 0 to disable parallel installation",
|
||||
)
|
||||
|
||||
|
||||
@impl
|
||||
def tox_add_env_config(env_conf: EnvConfigSet):
|
||||
"""Add required env configuration options to the tox INI file"""
|
||||
@ -164,10 +184,9 @@ def tox_on_install(
|
||||
raise err
|
||||
|
||||
dependencies = utilities.dedupe_packages(group_deps + env_deps + project_deps)
|
||||
|
||||
installer.install(
|
||||
poetry,
|
||||
tox_env,
|
||||
dependencies,
|
||||
tox_env.core["parallel_install_threads"],
|
||||
tox_env.options.parallel_install_threads,
|
||||
)
|
||||
|
@ -37,7 +37,7 @@ def check_preconditions(venv: ToxVirtualEnv) -> "_poetry.Poetry":
|
||||
if isinstance(venv, PackageToxEnv):
|
||||
raise exceptions.SkipEnvironment(f"Skipping Tox provisioning env '{venv.name}'")
|
||||
|
||||
if venv.conf["require_poetry"]:
|
||||
if venv.options.require_poetry:
|
||||
logger.warning(
|
||||
"DEPRECATION: The '--require-poetry' runtime option is deprecated and will be "
|
||||
"removed in version 1.0.0. Please update test environments that require Poetry to "
|
||||
|
Loading…
Reference in New Issue
Block a user