diff mbox series

[v3,4/5] python3: add support for skipping dependencies when building the manifest

Message ID 20261113143038.1651404-4-ross.burton@arm.com
State Changes Requested
Headers show
Series [v3,1/5] python3: remove obsolete reformatting of _sysconfigdata*.py | expand

Commit Message

Ross Burton Nov. 13, 2026, 2:30 p.m. UTC
The manifest generation works by importing modules and seeing what other
modules also get included.  This means the manifest is maximal, for example
shutil tries to import all of the compression modules to determine what
compression types are available.

Add a "skip_depends" element to the manifest so we can mark up specific
dependencies that should be ignored when generating the manifest.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../python/python3/create_manifest3.py           | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/python/python3/create_manifest3.py b/meta/recipes-devtools/python/python3/create_manifest3.py
index 6d3108e46f7..9ce04fdd2aa 100644
--- a/meta/recipes-devtools/python/python3/create_manifest3.py
+++ b/meta/recipes-devtools/python/python3/create_manifest3.py
@@ -93,6 +93,14 @@  def print_indent(msg, offset):
         msg = ' ' * offset + l
         print(msg)
 
+def is_dependency_skipped(manifest, package, dependency):
+    """
+    Check to see if this dependency should be ignored by matching substrings
+    from the optional skip_depends element in the manifest.
+    """
+    skiplist = manifest.get('skip_depends', {}).get(package, [])
+    return any((skip in dependency for skip in skiplist))
+
 
 # Read existing JSON manifest
 with open('python3-manifest.json') as manifest:
@@ -121,6 +129,8 @@  print_indent('Getting dependencies for package: core', 0)
 
 output = subprocess.check_output([sys.executable, 'get_module_deps3.py', 'python-core-package', '%s' % debugFlag]).decode('utf8')
 for coredep in output.split():
+    if is_dependency_skipped(old_manifest['core'], "core", coredep):
+        continue
     coredep = coredep.replace(pyversion,'${PYTHON_MAJMIN}')
     if isCached(coredep):
         if coredep not in old_manifest['core']['cached']:
@@ -172,6 +182,8 @@  for filedep in old_manifest['core']['files']:
 
 
     for pymodule_dep in output.split():
+        if is_dependency_skipped(old_manifest['core'], pymodule, pymodule_dep):
+            continue
         pymodule_dep = pymodule_dep.replace(pyversion,'${PYTHON_MAJMIN}')
 
         if isCached(pymodule_dep):
@@ -221,6 +233,8 @@  for pypkg in old_manifest:
     new_manifest[pypkg] = {}
     new_manifest[pypkg]['summary'] = old_manifest[pypkg]['summary']
     new_manifest[pypkg]['rdepends'] = []
+    if "skip_depends" in old_manifest[pypkg]:
+        new_manifest[pypkg]['skip_depends'] = old_manifest[pypkg]['skip_depends']
     new_manifest[pypkg]['files'] = []
     new_manifest[pypkg]['cached'] = old_manifest[pypkg]['cached']
 
@@ -298,6 +312,8 @@  for pypkg in old_manifest:
         reportRDEPS = []
 
         for pymodule_dep in output.split():
+            if is_dependency_skipped(new_manifest[pypkg], pymodule, pymodule_dep):
+                continue
 
             # Warning: This first part is ugly
             # One of the dependencies that was found, could be inside of one of the folders included by another package