[oe-commits] [openembedded-core] 04/05: python3: Reformat sysconfig

git at git.openembedded.org git at git.openembedded.org
Thu Jun 20 15:49:39 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 7c2ea2f7b0d202d353f2c205b25a286ff8cf5e04
Author: Joshua Watt <jpewhacker at gmail.com>
AuthorDate: Thu Jun 20 10:43:01 2019 -0500

    python3: Reformat sysconfig
    
    Reformats the sysconfig file when packaging. This file is output by
    using the python pprint function. This function will wrap long lines at
    80 characters by default, and will even split strings at whitespace
    boundaries to do so, e.g.:
    
     'A': 'B is really'
        ' long'
    
    This causes a problem for reproducibility however because there might be
    lines of differing lengths depending on the build path. These
    non-reproducible paths are removed, but their effect on string wrapping
    from pprint remains.
    
    To correct this, reformat the entire sysconfig file by re-printing using
    pprint with an (effectively) unlimited line length.
    
    Signed-off-by: Joshua Watt <JPEWhacker at gmail.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 .../python/python3/reformat_sysconfig.py            | 21 +++++++++++++++++++++
 meta/recipes-devtools/python/python3_3.7.3.bb       | 10 ++++++++++
 2 files changed, 31 insertions(+)

diff --git a/meta/recipes-devtools/python/python3/reformat_sysconfig.py b/meta/recipes-devtools/python/python3/reformat_sysconfig.py
new file mode 100644
index 0000000..c416431
--- /dev/null
+++ b/meta/recipes-devtools/python/python3/reformat_sysconfig.py
@@ -0,0 +1,21 @@
+#! /usr/bin/env python3
+#
+# SPDX-License-Identifier: MIT
+#
+# Copyright 2019 by Garmin Ltd. or its subsidiaries
+#
+# A script to reformat python sysconfig
+
+import sys
+import pprint
+l = {}
+g = {}
+with open(sys.argv[1], 'r') as f:
+    exec(f.read(), g, l)
+
+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)
+        f.write('\n')
+
diff --git a/meta/recipes-devtools/python/python3_3.7.3.bb b/meta/recipes-devtools/python/python3_3.7.3.bb
index 2444296..d14c938 100644
--- a/meta/recipes-devtools/python/python3_3.7.3.bb
+++ b/meta/recipes-devtools/python/python3_3.7.3.bb
@@ -27,6 +27,10 @@ SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
 	   file://crosspythonpath.patch \
            "
 
+SRC_URI_append_class-target = " \
+           file://reformat_sysconfig.py \
+           "
+
 SRC_URI_append_class-native = " \
            file://0001-distutils-sysconfig-append-STAGING_LIBDIR-python-sys.patch \
            file://12-distutils-prefix-is-inside-staging-area.patch \
@@ -157,6 +161,12 @@ py_package_preprocess () {
                 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py \
                 ${PKGD}/${bindir}/python${PYTHON_BINABI}-config
 
+        # Reformat _sysconfigdata after modifying it so that it remains
+        # reproducible
+        for c in ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do
+            python3 ${WORKDIR}/reformat_sysconfig.py $c
+        done
+
         # Recompile _sysconfigdata after modifying it
         cd ${PKGD}
         sysconfigfile=`find . -name _sysconfigdata_*.py`

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list