mirror of
https://github.com/enpaul/tox-poetry-installer.git
synced 2025-10-27 06:54:23 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 18a74fab63 | |||
| 516515b347 | |||
| c9f1f41163 |
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "tox-poetry-installer"
|
name = "tox-poetry-installer"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
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"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from typing import Dict
|
|||||||
from typing import List
|
from typing import List
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
from typing import Set
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
from poetry.factory import Factory as PoetryFactory
|
from poetry.factory import Factory as PoetryFactory
|
||||||
@@ -29,7 +30,7 @@ from tox.venv import VirtualEnv as ToxVirtualEnv
|
|||||||
|
|
||||||
__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.2.0"
|
__version__ = "0.2.1"
|
||||||
__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>"]
|
||||||
@@ -139,7 +140,7 @@ def _install_to_venv(
|
|||||||
installer.install(dependency)
|
installer.install(dependency)
|
||||||
|
|
||||||
|
|
||||||
def _find_transients(poetry: Poetry, dependency_name: str) -> List[PoetryPackage]:
|
def _find_transients(poetry: Poetry, dependency_name: str) -> Set[PoetryPackage]:
|
||||||
"""Using a poetry object identify all dependencies of a specific dependency
|
"""Using a poetry object identify all dependencies of a specific dependency
|
||||||
|
|
||||||
:param poetry: Populated poetry object which can be used to build a populated locked
|
:param poetry: Populated poetry object which can be used to build a populated locked
|
||||||
@@ -170,7 +171,7 @@ def _find_transients(poetry: Poetry, dependency_name: str) -> List[PoetryPackage
|
|||||||
transients += find_deps_of_deps(dep.name)
|
transients += find_deps_of_deps(dep.name)
|
||||||
return transients
|
return transients
|
||||||
|
|
||||||
return find_deps_of_deps(top_level.name)
|
return set(find_deps_of_deps(top_level.name))
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if any(
|
if any(
|
||||||
@@ -187,17 +188,12 @@ def _find_transients(poetry: Poetry, dependency_name: str) -> List[PoetryPackage
|
|||||||
def _install_env_dependencies(venv: ToxVirtualEnv, poetry: Poetry):
|
def _install_env_dependencies(venv: ToxVirtualEnv, poetry: Poetry):
|
||||||
env_deps = _sort_env_deps(venv)
|
env_deps = _sort_env_deps(venv)
|
||||||
|
|
||||||
reporter.verbosity1(
|
|
||||||
f"{_REPORTER_PREFIX} updating env config with {len(env_deps.unlocked_deps)} unlocked env dependencies for installation using the default backend"
|
|
||||||
)
|
|
||||||
venv.envconfig.deps = env_deps.unlocked_deps
|
|
||||||
|
|
||||||
dependencies: List[PoetryPackage] = []
|
dependencies: List[PoetryPackage] = []
|
||||||
for dep in env_deps.locked_deps:
|
for dep in env_deps.locked_deps:
|
||||||
try:
|
try:
|
||||||
dependencies += _find_transients(poetry, dep.name)
|
dependencies += _find_transients(poetry, dep.name)
|
||||||
except ToxPoetryInstallerException as err:
|
except ToxPoetryInstallerException as err:
|
||||||
venv.status = "install-locked-deps-failed"
|
venv.status = "lockfile installation failed"
|
||||||
reporter.error(f"{_REPORTER_PREFIX} {err}")
|
reporter.error(f"{_REPORTER_PREFIX} {err}")
|
||||||
raise err
|
raise err
|
||||||
|
|
||||||
@@ -205,6 +201,11 @@ def _install_env_dependencies(venv: ToxVirtualEnv, poetry: Poetry):
|
|||||||
f"{_REPORTER_PREFIX} identified {len(dependencies)} actual dependencies from {len(venv.envconfig.deps)} specified env dependencies"
|
f"{_REPORTER_PREFIX} identified {len(dependencies)} actual dependencies from {len(venv.envconfig.deps)} specified env dependencies"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
reporter.verbosity1(
|
||||||
|
f"{_REPORTER_PREFIX} updating env config with {len(env_deps.unlocked_deps)} unlocked env dependencies for installation using the default backend"
|
||||||
|
)
|
||||||
|
venv.envconfig.deps = env_deps.unlocked_deps
|
||||||
|
|
||||||
reporter.verbosity0(
|
reporter.verbosity0(
|
||||||
f"{_REPORTER_PREFIX} ({venv.name}) installing {len(dependencies)} env dependencies from lockfile"
|
f"{_REPORTER_PREFIX} ({venv.name}) installing {len(dependencies)} env dependencies from lockfile"
|
||||||
)
|
)
|
||||||
@@ -276,9 +277,14 @@ def tox_testenv_install_deps(venv: ToxVirtualEnv, action: ToxAction):
|
|||||||
|
|
||||||
# Handle the installation of the package dependencies from the lockfile if the package is
|
# Handle the installation of the package dependencies from the lockfile if the package is
|
||||||
# being installed to this venv; otherwise skip installing the package dependencies
|
# being installed to this venv; otherwise skip installing the package dependencies
|
||||||
if not venv.envconfig.skip_install:
|
if not venv.envconfig.skip_install and not venv.envconfig.config.skipsdist:
|
||||||
_install_package_dependencies(venv, poetry)
|
_install_package_dependencies(venv, poetry)
|
||||||
else:
|
else:
|
||||||
reporter.verbosity1(
|
if venv.envconfig.skip_install:
|
||||||
f"{_REPORTER_PREFIX} env specifies 'skip_install = true', skipping installation of project package"
|
reporter.verbosity1(
|
||||||
)
|
f"{_REPORTER_PREFIX} env specifies 'skip_install = true', skipping installation of project package"
|
||||||
|
)
|
||||||
|
elif venv.envconfig.config.skipsdist:
|
||||||
|
reporter.verbosity1(
|
||||||
|
f"{_REPORTER_PREFIX} config specifies 'skipsdist = true', skipping installation of project package"
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user