Add logging for package installation completion

Currently, tox-poetry-installer logs when it submits a dependency to the
(possibly-parallel) executor for installation, but not when the
installation is finished; this commit adds a log message when the
installation actually starts (in contrast with when the job is queued)
and a log message when the installation completes, along with the wall
time it took.

Rationale: I've noticed in some cases when running under Python 3.10
packages take much longer to install -- this logging should help
pinpoint culprits.
This commit is contained in:
Rebecca Turner 2021-07-07 14:29:15 -04:00
parent 3c0b76a30f
commit 1478e35c0b
No known key found for this signature in database
GPG Key ID: 1BBC076B481FCDFC

View File

@ -5,6 +5,7 @@
import concurrent.futures
import contextlib
import typing
from datetime import datetime
from typing import Sequence
from typing import Set
@ -46,6 +47,13 @@ def install(
installed: Set[PoetryPackage] = set()
def logged_install(dependency: PoetryPackage) -> None:
start = datetime.now()
logger.debug(f"Installing {dependency}")
pip.install(dependency)
end = datetime.now()
logger.debug(f"Finished installing {dependency} in {end - start}")
@contextlib.contextmanager
def _optional_parallelize():
"""A bit of cheat, really
@ -66,8 +74,8 @@ def install(
for dependency in packages:
if dependency not in installed:
installed.add(dependency)
logger.debug(f"Installing {dependency}")
executor(pip.install, dependency)
logger.debug(f"Queuing {dependency}")
executor(logged_install, dependency)
else:
logger.debug(f"Skipping {dependency}, already installed")
logger.debug("Waiting for installs to finish...")