summaryrefslogtreecommitdiffstats
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:38:37 +0000
commit6c524c09067a57c6e78e41a3860387dd4b31dc2b (patch)
treebf24aaa5b511179ea6edbd8d8840c00c946e624b /meta/recipes-devtools/python/python3/create_manifest3.py
parenta1e2c4e9bde9af41d797a2d0b7e4a3448c47bd64 (diff)
downloadpoky-6c524c09067a57c6e78e41a3860387dd4b31dc2b.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. (From OE-Core rev: 3eab24c6dc095fd2305b9be8467aab1191141e35) 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 @@
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
@@ -36,7 +36,7 @@
36# Tha method to handle cached files does not work when a module includes a folder which 36# Tha method to handle cached files does not work when a module includes a folder which
37# itself contains the pycache folder, gladly this is almost never the case. 37# itself contains the pycache folder, gladly this is almost never the case.
38# 38#
39# Author: Alejandro Enedino Hernandez Samaniego "aehs29" <aehs29@gmail.com> 39# Author: Alejandro Enedino Hernandez Samaniego "aehs29" <aehs29 at gmail dot com>
40 40
41 41
42import sys 42import sys
@@ -78,9 +78,21 @@ def isCached(item):
78 else: 78 else:
79 return False 79 return False
80 80
81def prepend_comments(comments, json_manifest):
82 with open(json_manifest, 'r+') as manifest:
83 json_contents = manifest.read()
84 manifest.seek(0, 0)
85 manifest.write(comments + json_contents)
86
81# Read existing JSON manifest 87# Read existing JSON manifest
82with open('python3-manifest.json') as manifest: 88with open('python3-manifest.json') as manifest:
83 old_manifest = json.load(manifest, object_pairs_hook=collections.OrderedDict) 89 # The JSON format doesn't allow comments so we hack the call to keep the comments using a marker
90 manifest_str = manifest.read()
91 json_start = manifest_str.find('# EOC') + 6 # EOC + \n
92 manifest.seek(0)
93 comments = manifest.read(json_start)
94 manifest_str = manifest.read()
95 old_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict)
84 96
85# 97#
86# First pass to get core-package functionality, because we base everything on the fact that core is actually working 98# 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:
402 json.dump(new_manifest,outfile, indent=4) 414 json.dump(new_manifest,outfile, indent=4)
403 outfile.write('\n') 415 outfile.write('\n')
404 416
417prepend_comments(comments,'python3-manifest.json.new')
418
405if (repeated): 419if (repeated):
406 error_msg = '\n\nERROR:\n' 420 error_msg = '\n\nERROR:\n'
407 error_msg += 'The following files are repeated (contained in more than one package),\n' 421 error_msg += 'The following files are repeated (contained in more than one package),\n'