From c8d7009200f0b618bd44713114bdfe1d26c011c7 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Mon, 19 Apr 2021 23:11:04 -0400 Subject: [PATCH 1/3] Update require_poetry option to be config option rather than runtime Add deprecation warning for future removal of runtime require_poetry option --- tox_poetry_installer/hooks.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tox_poetry_installer/hooks.py b/tox_poetry_installer/hooks.py index 1a0489c..7c880ee 100644 --- a/tox_poetry_installer/hooks.py +++ b/tox_poetry_installer/hooks.py @@ -56,6 +56,13 @@ def tox_addoption(parser: ToxParser): help="Require all dependencies in the environment be installed using the Poetry lockfile", ) + parser.add_testenv_attribute( + name="require_poetry", + type="bool", + default=False, + help="Trigger a failure if Poetry is not available to Tox", + ) + parser.add_testenv_attribute( name="locked_deps", type="line-list", @@ -75,12 +82,18 @@ def tox_testenv_install_deps(venv: ToxVirtualEnv, action: ToxAction) -> Optional :param action: Tox action object """ + if venv.envconfig.config.option.require_poetry: + logger.warning( + "DEPRECATION WARNING: The '--require-poetry' runtime option is deprecated and will be " + "removed in version 1.0.0. Please update test environments that require Poetry to " + "set the 'require_poetry = true' option in tox.ini" + ) + try: poetry = utilities.check_preconditions(venv, action) except exceptions.SkipEnvironment as err: - if ( - isinstance(err, exceptions.PoetryNotInstalledError) - and venv.envconfig.config.option.require_poetry + if isinstance(err, exceptions.PoetryNotInstalledError) and ( + venv.envconfig.config.option.require_poetry or venv.envconfig.require_poetry ): venv.status = err.__class__.__name__ logger.error(str(err)) From efdc2f7f26f1834b9d92a8633f8e7494aaf23c43 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Mon, 19 Apr 2021 23:17:20 -0400 Subject: [PATCH 2/3] Update documentation with new option details --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 72b13a8..69ff26e 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,7 @@ configuration section. | `locked_deps` | List | `[]` | Names of packages to install to the test environment from the Poetry lockfile. Transient dependencies (packages required by these dependencies) are automatically included. | | `require_locked_deps` | Boolean | False | Whether the plugin should block attempts to install unlocked dependencies to the test environment. If enabled, then the [`tox_testenv_install_deps`](https://tox.readthedocs.io/en/latest/plugins.html#tox.hookspecs.tox_testenv_install_deps) plugin hook will be intercepted and an error will be raised if the test environment has the `deps` option configured. | | `install_dev_deps` | Boolean | False | Whether all of the Poetry dev-dependencies should be installed to the test environment. | +| `require_poetry` | Boolean | False | Whether Tox should be forced to fail if the plugin cannot import Poetry locally. If `False` then the plugin will be skipped for the test environment if Poetry cannot be imported. If `True` then the plugin will force the environment to error and the Tox run to fail. | ### Runtime Options @@ -207,9 +208,12 @@ of the plugin. | Argument | Type | Default | Description | | :----------------------------- | :-----: | :-----: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `--require-poetry` | Flag | False | If provided then Tox is forced to fail if the plugin cannot import Poetry locally. If not provided then the plugin will skip all checks and dependency installations. | | `--parallelize-locked-install` | Integer | `0` | Number of worker threads to use to install dependencies in parallel. Installing in parallel with more threads can greatly speed up the install process, but can cause race conditions during install. The default, `0`, disables the parallel install so that dependencies are installed sequentially. | +> **Note:** The `--require-poetry` runtime option is deprecated and will be removed in +> version 1.0.0. Please set `require_poetry = true` in `tox.ini` for environments that +> should fail if Poetry is not available. + ### Errors There are several errors that the plugin can encounter for a test environment when Tox is From 1f449c038fdc9d068ef1aca828244ffe1fd4e518 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Mon, 19 Apr 2021 23:29:16 -0400 Subject: [PATCH 3/3] Update badges --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 69ff26e..49891a4 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ A plugin for [Tox](https://tox.readthedocs.io/en/latest/) that lets you install environment dependencies from the [Poetry](https://python-poetry.org/) lockfile. [![CI Status](https://github.com/enpaul/tox-poetry-installer/workflows/CI/badge.svg?event=push)](https://github.com/enpaul/tox-poetry-installer/actions) -[![PyPI Version](https://img.shields.io/pypi/v/tox-poetry-installer?color=%2331c854)](https://pypi.org/project/tox-poetry-installer/) -[![PyPI Downloads](https://img.shields.io/pypi/dm/tox-poetry-installer?color=%2331c854)](https://libraries.io/pypi/tox-poetry-installer) -[![License](https://img.shields.io/pypi/l/tox-poetry-installer?color=%2331c854)](https://opensource.org/licenses/MIT) +[![PyPI Version](https://img.shields.io/pypi/v/tox-poetry-installer)](https://pypi.org/project/tox-poetry-installer/) +[![PyPI Downloads](https://img.shields.io/pypi/dm/tox-poetry-installer)](https://libraries.io/pypi/tox-poetry-installer) +[![License](https://img.shields.io/pypi/l/tox-poetry-installer)](https://opensource.org/licenses/MIT) [![Python Supported Versions](https://img.shields.io/pypi/pyversions/tox-poetry-installer)](https://www.python.org) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)