Add config support for the parallelization functionality

This commit is contained in:
Ethan Paul 2021-04-16 02:05:08 -04:00
parent 06fcd56172
commit 5e33af6eb2
No known key found for this signature in database
GPG Key ID: D0E2CBF1245E92BF

View File

@ -34,6 +34,14 @@ def tox_addoption(parser: ToxParser):
help="Trigger a failure if Poetry is not available to Tox", help="Trigger a failure if Poetry is not available to Tox",
) )
parser.add_argument(
"--parallelize-locked-install",
type=int,
dest="parallelize_locked_install",
default=None,
help="Number of worker threads to use for installing dependencies from the Poetry lockfile in parallel",
)
parser.add_testenv_attribute( parser.add_testenv_attribute(
name="install_dev_deps", name="install_dev_deps",
type="bool", type="bool",
@ -143,10 +151,21 @@ def tox_testenv_install_deps(venv: ToxVirtualEnv, action: ToxAction) -> Optional
raise err raise err
dependencies = dev_deps + env_deps + project_deps dependencies = dev_deps + env_deps + project_deps
log_parallel = (
f" (using {venv.envconfig.config.option.parallelize_locked_install} threads)"
if venv.envconfig.config.option.parallelize_locked_install
else ""
)
action.setactivity( action.setactivity(
__about__.__title__, __about__.__title__,
f"Installing {len(dependencies)} dependencies from Poetry lock file", f"Installing {len(dependencies)} dependencies from Poetry lock file{log_parallel}",
)
installer.install(
poetry,
venv,
dependencies,
venv.envconfig.config.option.parallelize_locked_install,
) )
installer.install(poetry, venv, dependencies)
return venv.envconfig.require_locked_deps or None return venv.envconfig.require_locked_deps or None