aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3/create_manifest3.py
diff options
context:
space:
mode:
authorAlejandro Enedino Hernandez Samaniego <alejandro.enedino.hernandez-samaniego@xilinx.com>2018-11-16 11:31:45 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-12-01 11:37:49 +0000
commit3eab24c6dc095fd2305b9be8467aab1191141e35 (patch)
tree0d7b2b15f5b82244deca80ac0eb4bcac7f740606 /meta/recipes-devtools/python/python3/create_manifest3.py
parent8b7d74aa7bb73daf84593fafde3eef4595918b63 (diff)
downloadopenembedded-core-contrib-3eab24c6dc095fd2305b9be8467aab1191141e35.tar.gz
python3: Adds instructions to the manifest file
While there is a bit of documentation regarding building a new manifest file for python, it seems that users usually only read the manifest file. The manifest file is in JSON format which doesn't allow comments, hence why instructions were initially put elsewhere. This patch hacks the call to open the JSON manifest file by using a marker to trick it into reading only part of the file as the manifest itself, and keep the other part as comments, which contain instructions for the user to run the create_manifest task after an upgrade or when adding a new package. Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr@xilinx.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/python/python3/create_manifest3.py')
-rw-r--r--meta/recipes-devtools/python/python3/create_manifest3.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/meta/recipes-devtools/python/python3/create_manifest3.py b/meta/recipes-devtools/python/python3/create_manifest3.py
index fddb23cdc4..f7d4587030 100644
--- a/meta/recipes-devtools/python/python3/create_manifest3.py
+++ b/meta/recipes-devtools/python/python3/create_manifest3.py
@@ -22,7 +22,7 @@
#
#
# This way we will create a new manifest from the data structure that was built during
-# this process, ont this new manifest each package will contain specifically only
+# this process, on this new manifest each package will contain specifically only
# what it needs to run.
#
# There are some caveats which we try to deal with, such as repeated files on different
@@ -36,7 +36,7 @@
# Tha method to handle cached files does not work when a module includes a folder which
# itself contains the pycache folder, gladly this is almost never the case.
#
-# Author: Alejandro Enedino Hernandez Samaniego "aehs29" <aehs29@gmail.com>
+# Author: Alejandro Enedino Hernandez Samaniego "aehs29" <aehs29 at gmail dot com>
import sys
@@ -78,9 +78,21 @@ def isCached(item):
else:
return False
+def prepend_comments(comments, json_manifest):
+ with open(json_manifest, 'r+') as manifest:
+ json_contents = manifest.read()
+ manifest.seek(0, 0)
+ manifest.write(comments + json_contents)
+
# Read existing JSON manifest
with open('python3-manifest.json') as manifest:
- old_manifest = json.load(manifest, object_pairs_hook=collections.OrderedDict)
+ # The JSON format doesn't allow comments so we hack the call to keep the comments using a marker
+ manifest_str = manifest.read()
+ json_start = manifest_str.find('# EOC') + 6 # EOC + \n
+ manifest.seek(0)
+ comments = manifest.read(json_start)
+ manifest_str = manifest.read()
+ old_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict)
#
# First pass to get core-package functionality, because we base everything on the fact that core is actually working
@@ -402,6 +414,8 @@ with open('python3-manifest.json.new','w') as outfile:
json.dump(new_manifest,outfile, indent=4)
outfile.write('\n')
+prepend_comments(comments,'python3-manifest.json.new')
+
if (repeated):
error_msg = '\n\nERROR:\n'
error_msg += 'The following files are repeated (contained in more than one package),\n'