From c5c5261a8080452c5d22652cb7de38b934e0501f Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:47:27 -0500 Subject: [PATCH 1/5] Update transient processing to more narrowly scope error catching --- tox_poetry_installer/utilities.py | 66 +++++++++++++++---------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tox_poetry_installer/utilities.py b/tox_poetry_installer/utilities.py index c753a75..9886ec7 100644 --- a/tox_poetry_installer/utilities.py +++ b/tox_poetry_installer/utilities.py @@ -62,43 +62,41 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac """ from tox_poetry_installer import _poetry + def find_deps_of_deps(name: str, searched: Set[str]) -> PackageMap: + package = packages[name] + transients: PackageMap = {} + searched.add(name) + + if name in _poetry.Provider.UNSAFE_PACKAGES: + reporter.warning( + f"{constants.REPORTER_PREFIX} Installing package '{name}' using Poetry is not supported; skipping installation of package '{name}'" + ) + reporter.verbosity2( + f"{constants.REPORTER_PREFIX} Skip {package}: designated unsafe by Poetry" + ) + elif not package.python_constraint.allows(constants.PLATFORM_VERSION): + reporter.verbosity2( + f"{constants.REPORTER_PREFIX} Skip {package}: incompatible Python requirement '{package.python_constraint}' for current version '{constants.PLATFORM_VERSION}'" + ) + elif package.platform is not None and package.platform != sys.platform: + reporter.verbosity2( + f"{constants.REPORTER_PREFIX} Skip {package}: incompatible platform requirement '{package.platform}' for current platform '{sys.platform}'" + ) + else: + reporter.verbosity2(f"{constants.REPORTER_PREFIX} Include {package}") + transients[name] = package + for dep in package.requires: + if dep.name not in searched: + transients.update(find_deps_of_deps(dep.name, searched)) + + return transients + + searched: Set[str] = set() + try: - - def find_deps_of_deps(name: str, searched: Set[str]) -> PackageMap: - package = packages[name] - transients: PackageMap = {} - searched.update([name]) - - if name in _poetry.Provider.UNSAFE_PACKAGES: - reporter.warning( - f"{constants.REPORTER_PREFIX} Installing package '{name}' using Poetry is not supported; skipping installation of package '{name}'" - ) - reporter.verbosity2( - f"{constants.REPORTER_PREFIX} Skip {package}: designated unsafe by Poetry" - ) - elif not package.python_constraint.allows(constants.PLATFORM_VERSION): - reporter.verbosity2( - f"{constants.REPORTER_PREFIX} Skip {package}: incompatible Python requirement '{package.python_constraint}' for current version '{constants.PLATFORM_VERSION}'" - ) - elif package.platform is not None and package.platform != sys.platform: - reporter.verbosity2( - f"{constants.REPORTER_PREFIX} Skip {package}: incompatible platform requirement '{package.platform}' for current platform '{sys.platform}'" - ) - else: - reporter.verbosity2(f"{constants.REPORTER_PREFIX} Include {package}") - transients[name] = package - for dep in package.requires: - if dep.name not in searched: - transients.update(find_deps_of_deps(dep.name, searched)) - - return transients - - searched: Set[str] = set() transients: PackageMap = find_deps_of_deps( packages[dependency_name].name, searched ) - - return set(transients.values()) except KeyError: if any( delimiter in dependency_name @@ -111,6 +109,8 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac f"No version of locked dependency '{dependency_name}' found in the project lockfile" ) from None + return set(transients.values()) + def check_preconditions(venv: ToxVirtualEnv, action: ToxAction) -> "_poetry.Poetry": """Check that the local project environment meets expectations""" From c1d1ac2de16b92c8f32feee0fb936ecb990dcfef Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Wed, 16 Dec 2020 19:01:20 -0500 Subject: [PATCH 2/5] Update handling of poetrys unsafe dependencies to avoid keyerror Fixes #33 --- tox_poetry_installer/utilities.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tox_poetry_installer/utilities.py b/tox_poetry_installer/utilities.py index 9886ec7..2a71a57 100644 --- a/tox_poetry_installer/utilities.py +++ b/tox_poetry_installer/utilities.py @@ -63,8 +63,6 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac from tox_poetry_installer import _poetry def find_deps_of_deps(name: str, searched: Set[str]) -> PackageMap: - package = packages[name] - transients: PackageMap = {} searched.add(name) if name in _poetry.Provider.UNSAFE_PACKAGES: @@ -72,9 +70,15 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac f"{constants.REPORTER_PREFIX} Installing package '{name}' using Poetry is not supported; skipping installation of package '{name}'" ) reporter.verbosity2( - f"{constants.REPORTER_PREFIX} Skip {package}: designated unsafe by Poetry" + f"{constants.REPORTER_PREFIX} Skip {name}: designated unsafe by Poetry" ) - elif not package.python_constraint.allows(constants.PLATFORM_VERSION): + + return dict() + + transients: PackageMap = {} + package = packages[name] + + if not package.python_constraint.allows(constants.PLATFORM_VERSION): reporter.verbosity2( f"{constants.REPORTER_PREFIX} Skip {package}: incompatible Python requirement '{package.python_constraint}' for current version '{constants.PLATFORM_VERSION}'" ) From e77c8593559f393c62ab2f07d62759a274cb9faa Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Wed, 16 Dec 2020 19:14:03 -0500 Subject: [PATCH 3/5] Add additional logging to dependency processing functionality Hopefully this will help with dependency resolution errors in the future --- tox_poetry_installer/utilities.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tox_poetry_installer/utilities.py b/tox_poetry_installer/utilities.py index 2a71a57..88bcae9 100644 --- a/tox_poetry_installer/utilities.py +++ b/tox_poetry_installer/utilities.py @@ -72,7 +72,6 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac reporter.verbosity2( f"{constants.REPORTER_PREFIX} Skip {name}: designated unsafe by Poetry" ) - return dict() transients: PackageMap = {} @@ -87,11 +86,20 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac f"{constants.REPORTER_PREFIX} Skip {package}: incompatible platform requirement '{package.platform}' for current platform '{sys.platform}'" ) else: - reporter.verbosity2(f"{constants.REPORTER_PREFIX} Include {package}") + reporter.verbosity2( + f"{constants.REPORTER_PREFIX} Including {package} for installation" + ) transients[name] = package - for dep in package.requires: + for index, dep in enumerate(package.requires): + reporter.verbosity2( + f"{constants.REPORTER_PREFIX} Processing dependency {index + 1}/{len(package.requires)} for {package}: {dep.name}" + ) if dep.name not in searched: transients.update(find_deps_of_deps(dep.name, searched)) + else: + reporter.verbosity2( + f"{constants.REPORTER_PREFIX} Package with name '{dep.name}' has already been processed, skipping" + ) return transients From 2ce97a53491f8ad75eda8e15ffd5e30e31ea1187 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Wed, 16 Dec 2020 19:16:38 -0500 Subject: [PATCH 4/5] Bump patch version --- pyproject.toml | 2 +- tox_poetry_installer/__about__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 06a5188..a13b9de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tox-poetry-installer" -version = "0.6.0" +version = "0.6.1" 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/__about__.py b/tox_poetry_installer/__about__.py index af40cd6..594f2c6 100644 --- a/tox_poetry_installer/__about__.py +++ b/tox_poetry_installer/__about__.py @@ -1,7 +1,7 @@ # pylint: disable=missing-docstring __title__ = "tox-poetry-installer" __summary__ = "Tox plugin to install Tox environment dependencies using the Poetry backend and lockfile" -__version__ = "0.6.0" +__version__ = "0.6.1" __url__ = "https://github.com/enpaul/tox-poetry-installer/" __license__ = "MIT" __authors__ = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"] From f116ffefa2dab5919f960c271284c4c98474bc40 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Wed, 16 Dec 2020 20:31:41 -0500 Subject: [PATCH 5/5] Fix special handling of unsafe dependencies as primary dependencies --- tox_poetry_installer/utilities.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tox_poetry_installer/utilities.py b/tox_poetry_installer/utilities.py index 88bcae9..d2d84c9 100644 --- a/tox_poetry_installer/utilities.py +++ b/tox_poetry_installer/utilities.py @@ -67,7 +67,7 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac if name in _poetry.Provider.UNSAFE_PACKAGES: reporter.warning( - f"{constants.REPORTER_PREFIX} Installing package '{name}' using Poetry is not supported; skipping installation of package '{name}'" + f"{constants.REPORTER_PREFIX} Installing package '{name}' using Poetry is not supported and will be skipped" ) reporter.verbosity2( f"{constants.REPORTER_PREFIX} Skip {name}: designated unsafe by Poetry" @@ -110,6 +110,12 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac packages[dependency_name].name, searched ) except KeyError: + if dependency_name in _poetry.Provider.UNSAFE_PACKAGES: + reporter.warning( + f"{constants.REPORTER_PREFIX} Installing package '{dependency_name}' using Poetry is not supported and will be skipped" + ) + return set() + if any( delimiter in dependency_name for delimiter in constants.PEP508_VERSION_DELIMITERS @@ -117,6 +123,7 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac raise exceptions.LockedDepVersionConflictError( f"Locked dependency '{dependency_name}' cannot include version specifier" ) from None + raise exceptions.LockedDepNotFoundError( f"No version of locked dependency '{dependency_name}' found in the project lockfile" ) from None