diff mbox series

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

Message ID 20261111141726.1496785-5-ross.burton@arm.com
State New
Headers show
Series [v2,1/6] python3: remove obsolete reformatting of _sysconfigdata*.py | expand

Commit Message

Ross Burton Nov. 11, 2026, 2:17 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 029d9235c1a..b713dba5ee9 100644
--- a/meta/recipes-devtools/python/python3/create_manifest3.py
+++ b/meta/recipes-devtools/python/python3/create_manifest3.py
@@ -81,6 +81,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:
@@ -109,6 +117,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 coredep not in old_manifest['core']['files']:
         old_manifest['core']['files'].append(coredep)
@@ -152,6 +162,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 pymodule_dep not in old_manifest['core']['files']:
@@ -197,6 +209,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'] = []
 
     # All packages should depend on core
@@ -272,6 +286,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