summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorNathan Rossi <nathan@nathanrossi.com>2020-08-10 12:47:36 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-08-11 20:35:39 +0100
commitdc74b6e8d5ac4de84aa56e2c418eaca8eb1e7d46 (patch)
tree9aa87d648688149458d19a41e6054c6b6eed7217 /meta/recipes-devtools
parent98549fd68c1273dfbf9ab6cdfa054b57521fb4d6 (diff)
downloadpoky-dc74b6e8d5ac4de84aa56e2c418eaca8eb1e7d46.tar.gz
python3: Improve handling of python3 manifest generation
Specifically cover detection of modules within a python package that do not import anything within their __init__.py. This is at least the case with the xmlrpc package which is only used via its modules xmlrpc.server and xmlrpc.client. Other important corner cases include ctypes.utils which depends on some modules not used by ctypes. This is implemented by generally assuming that importing all the modules of a package (aka *.py within a package, excluding _*.py) will provide enough information. Also due to this change some modules import sysconfig, resulting in sysconfigdata being imported. Handle the conversion of its path to a wildcard based on the platform dependent name being replaced. (From OE-Core rev: bef4be54e02df5f230d250487f85994a3b7bbd77) Signed-off-by: Nathan Rossi <nathan@nathanrossi.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/python/python3/get_module_deps3.py20
-rw-r--r--meta/recipes-devtools/python/python3/python3-manifest.json2
2 files changed, 19 insertions, 3 deletions
diff --git a/meta/recipes-devtools/python/python3/get_module_deps3.py b/meta/recipes-devtools/python/python3/get_module_deps3.py
index fd12baad84..6806f23172 100644
--- a/meta/recipes-devtools/python/python3/get_module_deps3.py
+++ b/meta/recipes-devtools/python/python3/get_module_deps3.py
@@ -9,6 +9,7 @@
9debug=False 9debug=False
10 10
11import sys 11import sys
12import os
12 13
13# We can get a list of the modules which are currently required to run python 14# We can get a list of the modules which are currently required to run python
14# so we run python-core and get its modules, we then import what we need 15# so we run python-core and get its modules, we then import what we need
@@ -48,8 +49,19 @@ current_module = str(sys.argv[1]).rstrip()
48if(debug==True): 49if(debug==True):
49 log = open('log_%s' % current_module,'w') 50 log = open('log_%s' % current_module,'w')
50 log.write('Module %s generated the following dependencies:\n' % current_module) 51 log.write('Module %s generated the following dependencies:\n' % current_module)
51try: 52try:
52 importlib.import_module('%s' % current_module) 53 m = importlib.import_module(current_module)
54 # handle python packages which may not include all modules in the __init__
55 if os.path.basename(m.__file__) == "__init__.py":
56 modulepath = os.path.dirname(m.__file__)
57 for i in os.listdir(modulepath):
58 if i.startswith("_") or not(i.endswith(".py")):
59 continue
60 submodule = "{}.{}".format(current_module, i[:-3])
61 try:
62 importlib.import_module(submodule)
63 except:
64 pass # ignore all import or other exceptions raised during import
53except ImportError as e: 65except ImportError as e:
54 if (debug==True): 66 if (debug==True):
55 log.write('Module was not found') 67 log.write('Module was not found')
@@ -107,6 +119,8 @@ for item in dif:
107 dep_path = dep_path.replace(soabi,'*') 119 dep_path = dep_path.replace(soabi,'*')
108 print (dep_path) 120 print (dep_path)
109 continue 121 continue
122 if "_sysconfigdata" in dep_path:
123 dep_path = dep_path.replace(sysconfig._get_sysconfigdata_name(), "_sysconfigdata*")
110 124
111 if (debug==True): 125 if (debug==True):
112 log.write(dep_path+'\n') 126 log.write(dep_path+'\n')
@@ -140,6 +154,8 @@ for item in dif:
140 log.write(cached) 154 log.write(cached)
141 cached = fix_path(cached) 155 cached = fix_path(cached)
142 cached = cached.replace(cpython_tag,'*') 156 cached = cached.replace(cpython_tag,'*')
157 if "_sysconfigdata" in cached:
158 cached = cached.replace(sysconfig._get_sysconfigdata_name(), "_sysconfigdata*")
143 print (cached) 159 print (cached)
144 160
145if debug==True: 161if debug==True:
diff --git a/meta/recipes-devtools/python/python3/python3-manifest.json b/meta/recipes-devtools/python/python3/python3-manifest.json
index 3bcc9b8662..07b084d48c 100644
--- a/meta/recipes-devtools/python/python3/python3-manifest.json
+++ b/meta/recipes-devtools/python/python3/python3-manifest.json
@@ -324,7 +324,7 @@
324 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/_compression.*.pyc", 324 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/_compression.*.pyc",
325 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/_markupbase.*.pyc", 325 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/_markupbase.*.pyc",
326 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/_sitebuiltins.*.pyc", 326 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/_sitebuiltins.*.pyc",
327 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/_sysconfigdata.*.pyc", 327 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/_sysconfigdata*.*.pyc",
328 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/_weakrefset.*.pyc", 328 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/_weakrefset.*.pyc",
329 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/abc.*.pyc", 329 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/abc.*.pyc",
330 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/argparse.*.pyc", 330 "${libdir}/python${PYTHON_MAJMIN}/__pycache__/argparse.*.pyc",