mirror of
https://github.com/enpaul/tox-poetry-installer.git
synced 2024-10-29 19:47:00 +00:00
Merge pull request #29 from enpaul/enp/fix-platform
Fix dependency installation on incompatible platforms and with invalid python versions
This commit is contained in:
commit
4de5fea0e3
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "tox-poetry-installer"
|
name = "tox-poetry-installer"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"]
|
authors = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"]
|
||||||
description = "Tox plugin to install Tox environment dependencies using the Poetry backend and lockfile"
|
description = "Tox plugin to install Tox environment dependencies using the Poetry backend and lockfile"
|
||||||
|
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
@ -1,7 +1,7 @@
|
|||||||
# pylint: disable=missing-docstring
|
# pylint: disable=missing-docstring
|
||||||
__title__ = "tox-poetry-installer"
|
__title__ = "tox-poetry-installer"
|
||||||
__summary__ = "Tox plugin to install Tox environment dependencies using the Poetry backend and lockfile"
|
__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/"
|
__url__ = "https://github.com/enpaul/tox-poetry-installer/"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__authors__ = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"]
|
__authors__ = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"]
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
"""Helper utility functions, usually bridging Tox and Poetry functionality"""
|
"""Helper utility functions, usually bridging Tox and Poetry functionality"""
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
from typing import Set
|
from typing import Set
|
||||||
|
|
||||||
from poetry.core.packages import Package as PoetryPackage
|
from poetry.core.packages import Package as PoetryPackage
|
||||||
|
from poetry.core.semver.version import Version
|
||||||
from poetry.factory import Factory as PoetryFactory
|
from poetry.factory import Factory as PoetryFactory
|
||||||
from poetry.installation.pip_installer import PipInstaller as PoetryPipInstaller
|
from poetry.installation.pip_installer import PipInstaller as PoetryPipInstaller
|
||||||
from poetry.io.null_io import NullIO as PoetryNullIO
|
from poetry.io.null_io import NullIO as PoetryNullIO
|
||||||
@ -59,19 +61,44 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac
|
|||||||
|
|
||||||
try:
|
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:
|
if name in PoetryProvider.UNSAFE_PACKAGES:
|
||||||
reporter.warning(
|
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; 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:
|
else:
|
||||||
transients[name] = packages[name]
|
reporter.verbosity2(f"{constants.REPORTER_PREFIX} Include {package}")
|
||||||
for dep in packages[name].requires:
|
transients[name] = package
|
||||||
if dep.name not in transients.keys():
|
for dep in package.requires:
|
||||||
find_deps_of_deps(dep.name, transients)
|
if dep.name not in searched:
|
||||||
|
transients.update(find_deps_of_deps(dep.name, searched))
|
||||||
|
|
||||||
transients: PackageMap = {}
|
return transients
|
||||||
find_deps_of_deps(packages[dependency_name].name, transients)
|
|
||||||
|
searched: Set[str] = set()
|
||||||
|
transients: PackageMap = find_deps_of_deps(
|
||||||
|
packages[dependency_name].name, searched
|
||||||
|
)
|
||||||
|
|
||||||
return set(transients.values())
|
return set(transients.values())
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
Loading…
Reference in New Issue
Block a user