Skip to contentSkip to conversation

python3: Fix sysroot reproducibility

PATCH New Joshua Watt 1 participant 1 message Sep 30, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 python3: Fix sysroot reproducibility

Fixes the reformatting of the sysconfigdata to be reproducible in the sysroot as well as in the package. During this a bug was uncovered in the way that the data was reformatted where it appears that python cannot parse a single line of code over 40000 characters. To work around this, pass a maximum with of "1" to pprint instead of sys.maxsize which will cause it to wrap as often as possible and should keep it reproducible.

---
 meta/recipes-devtools/python/python3/reformat_sysconfig.py | 2 +-
 meta/recipes-devtools/python/python3_3.9.6.bb              | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
meta/recipes-devtools/python/python3/reformat_sysconfig.py +1 -1
index c4164313e8..5e2b12879d 100644
@@ -16,6 +16,6 @@ with open(sys.argv[1], 'r') as f:
 with open(sys.argv[1], 'w') as f:
     for k in sorted(l.keys()):
         f.write('%s = ' % k)
-        pprint.pprint(l[k], stream=f, width=sys.maxsize)
+        pprint.pprint(l[k], stream=f, width=1)
         f.write('\n')
 
meta/recipes-devtools/python/python3_3.9.6.bb +4 -0
index f04bfc3053..aae7837180 100644
@@ -161,6 +161,10 @@ do_install:append:class-native() {
 }
 
 do_install:append() {
+        for c in ${D}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do
+            python3 ${WORKDIR}/reformat_sysconfig.py $c
+        done
+
         mkdir -p ${D}${libdir}/python-sysconfigdata
         sysconfigfile=`find ${D} -name _sysconfig*.py`
         cp $sysconfigfile ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py
Signature · 1 line
2.33.0