[elbe-devel] [PATCH 5/5] elbepack: aptpkgutils: reduce scope of apt import
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Wed Nov 13 13:18:35 CET 2024
We want to use elbepack.aptpkgutils also in environments which do not
have python-apt available. For example to use "elbe cyclonedx-sbom".
Reduce the scope of the imports to make that possible.
This is slightly iffy and the logic should be split over multiple
modules, which either depend on python-apt or don't.
However the internals of aptpkgutils are fairly intertwined and
splitting it up would make it only more ugly.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/aptpkgutils.py | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/elbepack/aptpkgutils.py b/elbepack/aptpkgutils.py
index 255adb104a2614426a0c5f3bf20c62521b1af4dd..64a80660a36f432a12f66c4526cbc56bb4bb8567 100644
--- a/elbepack/aptpkgutils.py
+++ b/elbepack/aptpkgutils.py
@@ -6,10 +6,6 @@
import dataclasses
import os
-import apt
-
-import apt_pkg
-
MARKED_INSTALL = 0
MARKED_UPGRADE = 1
MARKED_DELETE = 2
@@ -110,6 +106,8 @@ def pkgorigin(pkg):
def fetch_source(name, version, destdir, progress=None):
+ import apt
+ import apt_pkg
allow_untrusted = apt_pkg.config.find_b('APT::Get::AllowUnauthenticated', False)
@@ -174,6 +172,7 @@ def parse_built_using(value):
>>> list(parse_built_using('grub2 (= 1.99-9), loadlin (= 1.6e-1)'))
[('grub2', '1.99-9'), ('loadlin', '1.6e-1')]
"""
+ import apt_pkg
if value is None:
return
--
2.47.0
More information about the elbe-devel
mailing list