helpers: logging: reduce the risk of a cyclical import (MR 2463)

Lazy load pmb.config.styles and move the pmb.__version__ print elsewhere
so the logging module is (closer to) a standalone entity. This is
necessary to be able to import it in pmb/helpers/apk.py otherwise we get
a cyclical dependency.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-10-27 23:13:29 +01:00
parent 2f39edd584
commit af1bf53867
No known key found for this signature in database
GPG key ID: 0583312B195F64B6
2 changed files with 10 additions and 3 deletions

View file

@ -1,5 +1,7 @@
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import sys
import pmb.config
from pmb.core.context import Context
from pmb.core.pkgrepo import pkgrepo_default_path
@ -89,6 +91,7 @@ def init(args: PmbArgs) -> PmbArgs:
# Initialize logs (we could raise errors below)
pmb.helpers.logging.init(context.log, args.verbose, context.details_to_stdout)
pmb.helpers.logging.debug(f"Pmbootstrap v{pmb.__version__} (Python {sys.version})")
# Initialization code which may raise errors
if args.action not in [