Fix duplicate installation of env dependencies

Fix always logging post-sorted unlocked env dependencies
This commit is contained in:
Ethan Paul 2020-09-27 15:20:12 -04:00
parent c9f1f41163
commit 516515b347
No known key found for this signature in database
GPG Key ID: D0E2CBF1245E92BF

View File

@ -10,6 +10,7 @@ from typing import Dict
from typing import List
from typing import NamedTuple
from typing import Sequence
from typing import Set
from typing import Tuple
from poetry.factory import Factory as PoetryFactory
@ -139,7 +140,7 @@ def _install_to_venv(
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
: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)
return transients
return find_deps_of_deps(top_level.name)
return set(find_deps_of_deps(top_level.name))
except KeyError:
if any(
@ -187,17 +188,12 @@ def _find_transients(poetry: Poetry, dependency_name: str) -> List[PoetryPackage
def _install_env_dependencies(venv: ToxVirtualEnv, poetry: Poetry):
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] = []
for dep in env_deps.locked_deps:
try:
dependencies += _find_transients(poetry, dep.name)
except ToxPoetryInstallerException as err:
venv.status = "install-locked-deps-failed"
venv.status = "lockfile installation failed"
reporter.error(f"{_REPORTER_PREFIX} {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"
)
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(
f"{_REPORTER_PREFIX} ({venv.name}) installing {len(dependencies)} env dependencies from lockfile"
)