summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python/create_manifest2.py
diff options
context:
space:
mode:
authorAlejandro Enedino Hernandez Samaniego <alejandro.enedino.hernandez-samaniego@xilinx.com>2018-11-16 11:31:46 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-08 20:14:43 +0000
commit8bfb94cc9f85bd0893c7959997a9a17c211c998f (patch)
tree3a028a24503bf9ef6b8c8f431d34e39f6e3a560d /meta/recipes-devtools/python/python/create_manifest2.py
parent72c040ef58e21ef842ffb3808b589f212b90b5bd (diff)
downloadpoky-8bfb94cc9f85bd0893c7959997a9a17c211c998f.tar.gz
python: 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. (From OE-Core rev: 5641a24a70b54544012c04c6a082514d9a5aa49a) (From OE-Core rev: 3050a4c634da74eba53380bf23de515ed651bc03) 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> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/python/python/create_manifest2.py')
-rw-r--r--meta/recipes-devtools/python/python/create_manifest2.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/meta/recipes-devtools/python/python/create_manifest2.py b/meta/recipes-devtools/python/python/create_manifest2.py
index 87999991d7..b6748653b6 100644
--- a/meta/recipes-devtools/python/python/create_manifest2.py
+++ b/meta/recipes-devtools/python/python/create_manifest2.py
@@ -22,7 +22,7 @@
22# 22#
23# 23#
24# This way we will create a new manifest from the data structure that was built during 24# This way we will create a new manifest from the data structure that was built during
25# this process, ont this new manifest each package will contain specifically only 25# this process, on this new manifest each package will contain specifically only
26# what it needs to run. 26# what it needs to run.
27# 27#
28# There are some caveats which we try to deal with, such as repeated files on different 28# There are some caveats which we try to deal with, such as repeated files on different
@@ -30,7 +30,7 @@
30# Its also important to note that this method only works for python files, and shared 30# Its also important to note that this method only works for python files, and shared
31# libraries. Static libraries, header files and binaries need to be dealt with manually. 31# libraries. Static libraries, header files and binaries need to be dealt with manually.
32# 32#
33# Author: Alejandro Enedino Hernandez Samaniego "aehs29" <aehs29@gmail.com> 33# Author: Alejandro Enedino Hernandez Samaniego "aehs29" <aehs29 at gmail dot com>
34 34
35 35
36import sys 36import sys
@@ -62,10 +62,21 @@ def isFolder(value):
62 else: 62 else:
63 return False 63 return False
64 64
65def prepend_comments(comments, json_manifest):
66 with open(json_manifest, 'r+') as manifest:
67 json_contents = manifest.read()
68 manifest.seek(0, 0)
69 manifest.write(comments + json_contents)
70
65# Read existing JSON manifest 71# Read existing JSON manifest
66with open('python2-manifest.json') as manifest: 72with open('python2-manifest.json') as manifest:
67 old_manifest = json.load(manifest, object_pairs_hook=collections.OrderedDict) 73 # The JSON format doesn't allow comments so we hack the call to keep the comments using a marker
68 74 manifest_str = manifest.read()
75 json_start = manifest_str.find('# EOC') + 6 # EOC + \n
76 manifest.seek(0)
77 comments = manifest.read(json_start)
78 manifest_str = manifest.read()
79 old_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict)
69 80
70# First pass to get core-package functionality, because we base everything on the fact that core is actually working 81# First pass to get core-package functionality, because we base everything on the fact that core is actually working
71# Not exactly the same so it should not be a function 82# Not exactly the same so it should not be a function
@@ -277,3 +288,5 @@ for key in new_manifest:
277# Create the manifest from the data structure that was built 288# Create the manifest from the data structure that was built
278with open('python2-manifest.json.new','w') as outfile: 289with open('python2-manifest.json.new','w') as outfile:
279 json.dump(new_manifest,outfile, indent=4) 290 json.dump(new_manifest,outfile, indent=4)
291
292prepend_comments(comments,'python2-manifest.json.new')