From 961e6f6acd7d6b0582eb7fe3f86b6e8699543d20 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Fri, 23 Oct 2020 01:20:36 -0400 Subject: [PATCH 1/3] Add support for installing all dev dependencies to a testenv --- tox_poetry_installer.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tox_poetry_installer.py b/tox_poetry_installer.py index 78293cd..fde8619 100644 --- a/tox_poetry_installer.py +++ b/tox_poetry_installer.py @@ -232,6 +232,23 @@ def _install_env_dependencies( reporter.error(f"{_REPORTER_PREFIX} {err}") raise err + if venv.envconfig.install_dev_deps: + reporter.verbosity1( + f"{_REPORTER_PREFIX} env specifies 'install_env_deps = true', including Poetry dev dependencies" + ) + + dev_dependencies = [ + dep + for dep in poetry.locker.locked_repository(True).packages + if dep not in poetry.locker.locked_repository(False).packages + ] + + reporter.verbosity1( + f"{_REPORTER_PREFIX} identified {len(dev_dependencies)} Poetry dev dependencies" + ) + + dependencies = list(set(dev_dependencies + dependencies)) + reporter.verbosity1( f"{_REPORTER_PREFIX} identified {len(dependencies)} total dependencies from {len(env_deps.locked_deps)} locked env dependencies" ) @@ -306,6 +323,13 @@ def tox_addoption(parser: ToxParser): dependencies should be treated as locked or not. """ + parser.add_testenv_attribute( + name="install_dev_deps", + type="bool", + default=False, + help="Automatically install all Poetry development dependencies to the environment", + ) + parser.add_testenv_attribute( name="require_locked_deps", type="bool", From c7bb3d35ea17ba8b91b4cf5d1b78f01da5282421 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Sat, 24 Oct 2020 12:10:07 -0400 Subject: [PATCH 2/3] Bump feature version --- pyproject.toml | 2 +- tox_poetry_installer.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a04bb77..6c44955 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tox-poetry-installer" -version = "0.3.1" +version = "0.4.0" license = "MIT" authors = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"] description = "Tox plugin to install Tox environment dependencies using the Poetry backend and lockfile" diff --git a/tox_poetry_installer.py b/tox_poetry_installer.py index fde8619..f8b6fae 100644 --- a/tox_poetry_installer.py +++ b/tox_poetry_installer.py @@ -45,7 +45,7 @@ from tox.venv import VirtualEnv as ToxVirtualEnv __title__ = "tox-poetry-installer" __summary__ = "Tox plugin to install Tox environment dependencies using the Poetry backend and lockfile" -__version__ = "0.3.1" +__version__ = "0.4.0" __url__ = "https://github.com/enpaul/tox-poetry-installer/" __license__ = "MIT" __authors__ = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"] From 5979ec7a8a70282ab6023ccbbf18c077e8c693e8 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Wed, 28 Oct 2020 16:26:31 -0400 Subject: [PATCH 3/3] Add documentation for new config option --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index ef131a4..6ce6896 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,10 @@ deps = commands = ... ``` +Alternatively, to quickly install all Poetry dev-dependencies to a Tox environment, add the +`install_dev_deps = true` option to the environment configuration. This option can be used either +with the `require_locked_deps = true` option or without it + **Note:** Regardless of the settings outlined above, all dependencies of the project package (the one Tox is testing) will always be installed from the lockfile.