From 0a363d184874290f83fbb6cc0630cdac7877384c Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Thu, 26 Nov 2020 14:32:22 -0500 Subject: [PATCH 1/3] Fix platform and py version compatibility errors Add check for compatible python versions during dependency determination Add check for compatible python platforms during dependency determination Add verbosity2 logging messages for dependency determination --- tox_poetry_installer/utilities.py | 41 +++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/tox_poetry_installer/utilities.py b/tox_poetry_installer/utilities.py index 828d685..5c44910 100644 --- a/tox_poetry_installer/utilities.py +++ b/tox_poetry_installer/utilities.py @@ -1,9 +1,11 @@ """Helper utility functions, usually bridging Tox and Poetry functionality""" +import sys from pathlib import Path from typing import Sequence from typing import Set from poetry.core.packages import Package as PoetryPackage +from poetry.core.semver.version import Version from poetry.factory import Factory as PoetryFactory from poetry.installation.pip_installer import PipInstaller as PoetryPipInstaller from poetry.io.null_io import NullIO as PoetryNullIO @@ -59,19 +61,44 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac try: - def find_deps_of_deps(name: str, transients: PackageMap): + def find_deps_of_deps(name: str, searched: Set[str]) -> PackageMap: + package = packages[name] + local_version = Version( + major=sys.version_info.major, + minor=sys.version_info.minor, + patch=sys.version_info.micro, + ) + transients: PackageMap = {} + searched.update([name]) + if name in PoetryProvider.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(local_version): + reporter.verbosity2( + f"{constants.REPORTER_PREFIX} Skip {package}: incompatible Python requirement '{package.python_constraint}' for current version '{local_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: - transients[name] = packages[name] - for dep in packages[name].requires: - if dep.name not in transients.keys(): - find_deps_of_deps(dep.name, transients) + 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)) - transients: PackageMap = {} - find_deps_of_deps(packages[dependency_name].name, transients) + return transients + + searched: Set[str] = set() + transients: PackageMap = find_deps_of_deps( + packages[dependency_name].name, searched + ) return set(transients.values()) except KeyError: From 498cb4a3d264a136548ddb80b5d7d9a3d27c87d3 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Thu, 26 Nov 2020 14:54:15 -0500 Subject: [PATCH 2/3] 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 016c5af..34ee599 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tox-poetry-installer" -version = "0.5.1" +version = "0.5.2" 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 9ae500b..4b21a84 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.5.1" +__version__ = "0.5.2" __url__ = "https://github.com/enpaul/tox-poetry-installer/" __license__ = "MIT" __authors__ = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"] From 33119df75288c5482b86839f8ac280684b97dac5 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Thu, 26 Nov 2020 15:01:59 -0500 Subject: [PATCH 3/3] Add missing tests __init__ file I'm tired of fighting this. Every tool under the sun wants the tests to be an importable module, which doesn't make much sense to me, but it's whatever. I'm just adding this because pylint, mypy, and others get angry when I try to use them on just a directory without globbing --- tests/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/__init__.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29