summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3/support_SOURCE_DATE_EPOCH_in_py_compile.patch
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2019-02-06 17:26:34 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-02-08 10:57:19 +0000
commite2c3247c233876ab090c9ce3d5325a6d46ab350f (patch)
treecf38957a3510be612cde924f6184a5251b968a43 /meta/recipes-devtools/python/python3/support_SOURCE_DATE_EPOCH_in_py_compile.patch
parentcd6c61a26177296e24b442e2eda1514b5f931c0a (diff)
downloadpoky-e2c3247c233876ab090c9ce3d5325a6d46ab350f.tar.gz
python3: upgrade to 3.7.2
I took the same approach as the recent perl upgrade: write recipe from scratch, taking the pieces from the old recipe only when they were proven to be necessary. The pgo, manifest and ptest features are all preserved. New features: - native and target recipes are now unified into one recipe - check_build_completeness.py runs right after do_compile() and verifies that all optional modules have been built (a notorious source of regressions) - a new approach to sysconfig.py and distutils/sysconfig.py returning values appropriate for native or target builds: we copy the configuration file to a separate folder, add that folder to sys.path (through environment variable that differs between native and target builds), and point python to the file through another environment variable. There were a few other patches where it was difficult to decide if the patch is still relevant, and how to test that it works correctly; please add those as-needed by testing the new python. (From OE-Core rev: 02714c105426b0d687620913c1a7401b386428b6) Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/python/python3/support_SOURCE_DATE_EPOCH_in_py_compile.patch')
-rw-r--r--meta/recipes-devtools/python/python3/support_SOURCE_DATE_EPOCH_in_py_compile.patch97
1 files changed, 0 insertions, 97 deletions
diff --git a/meta/recipes-devtools/python/python3/support_SOURCE_DATE_EPOCH_in_py_compile.patch b/meta/recipes-devtools/python/python3/support_SOURCE_DATE_EPOCH_in_py_compile.patch
deleted file mode 100644
index 32ecab9fec..0000000000
--- a/meta/recipes-devtools/python/python3/support_SOURCE_DATE_EPOCH_in_py_compile.patch
+++ /dev/null
@@ -1,97 +0,0 @@
1The compiled .pyc files contain time stamp corresponding to the compile time.
2This prevents binary reproducibility. This patch allows to achieve binary
3reproducibility by overriding the build time stamp by the value
4exported via SOURCE_DATE_EPOCH.
5
6Upstream-Status: Backport
7
8Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
9
10
11From aeab488630fdb1b56a8d0b0c13fa88706b2afe9b Mon Sep 17 00:00:00 2001
12From: "Bernhard M. Wiedemann" <bwiedemann@suse.de>
13Date: Sat, 25 Feb 2017 06:42:28 +0100
14Subject: [PATCH] bpo-29708: support SOURCE_DATE_EPOCH env var in py_compile
15
16to allow for reproducible builds of python packages
17
18See https://reproducible-builds.org/ for why this is good
19and https://reproducible-builds.org/specs/source-date-epoch/
20for the definition of this variable.
21
22Background:
23In some distributions like openSUSE, binary rpms contain precompiled .pyc files.
24
25And packages like amqp or twisted dynamically generate .py files at build time
26so those have the current time and that timestamp gets embedded
27into the .pyc file header.
28When we then adapt file timestamps in rpms to be constant,
29the timestamp in the .pyc header will no more match
30the .py timestamp in the filesystem.
31The software will still work, but it will not use the .pyc file as it should.
32---
33 Doc/library/py_compile.rst | 4 ++++
34 Lib/py_compile.py | 4 ++++
35 Lib/test/test_py_compile.py | 19 +++++++++++++++++++
36 3 files changed, 27 insertions(+)
37
38diff --git a/Doc/library/py_compile.rst b/Doc/library/py_compile.rst
39index 0af8fb1..841f3e8 100644
40--- a/Doc/library/py_compile.rst
41+++ b/Doc/library/py_compile.rst
42@@ -53,6 +53,10 @@ byte-code cache files in the directory containing the source code.
43 :func:`compile` function. The default of ``-1`` selects the optimization
44 level of the current interpreter.
45
46+ If the SOURCE_DATE_EPOCH environment variable is set, the .py file mtime
47+ and timestamp entry in .pyc file header, will be limited to this value.
48+ See https://reproducible-builds.org/specs/source-date-epoch/ for more info.
49+
50 .. versionchanged:: 3.2
51 Changed default value of *cfile* to be :PEP:`3147`-compliant. Previous
52 default was *file* + ``'c'`` (``'o'`` if optimization was enabled).
53diff --git a/Lib/py_compile.py b/Lib/py_compile.py
54index 11c5b50..62dcdc7 100644
55--- a/Lib/py_compile.py
56+++ b/Lib/py_compile.py
57@@ -137,6 +137,10 @@ def compile(file, cfile=None, dfile=None, doraise=False, optimize=-1):
58 except FileExistsError:
59 pass
60 source_stats = loader.path_stats(file)
61+ sde = os.environ.get('SOURCE_DATE_EPOCH')
62+ if sde and source_stats['mtime'] > int(sde):
63+ source_stats['mtime'] = int(sde)
64+ os.utime(file, (source_stats['mtime'], source_stats['mtime']))
65 bytecode = importlib._bootstrap_external._code_to_bytecode(
66 code, source_stats['mtime'], source_stats['size'])
67 mode = importlib._bootstrap_external._calc_mode(file)
68diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py
69index 4a6caa5..3d09963 100644
70--- a/Lib/test/test_py_compile.py
71+++ b/Lib/test/test_py_compile.py
72@@ -98,6 +98,25 @@ def test_bad_coding(self):
73 self.assertFalse(os.path.exists(
74 importlib.util.cache_from_source(bad_coding)))
75
76+ def test_source_date_epoch(self):
77+ testtime = 123456789
78+ orig_sde = os.getenv("SOURCE_DATE_EPOCH")
79+ os.environ["SOURCE_DATE_EPOCH"] = str(testtime)
80+ py_compile.compile(self.source_path, self.pyc_path)
81+ if orig_sde:
82+ os.environ["SOURCE_DATE_EPOCH"] = orig_sde
83+ else:
84+ del os.environ["SOURCE_DATE_EPOCH"]
85+ self.assertTrue(os.path.exists(self.pyc_path))
86+ self.assertFalse(os.path.exists(self.cache_path))
87+ statinfo = os.stat(self.source_path)
88+ self.assertEqual(statinfo.st_mtime, testtime)
89+ f = open(self.pyc_path, "rb")
90+ f.read(4)
91+ timebytes = f.read(4) # read timestamp from pyc header
92+ f.close()
93+ self.assertEqual(timebytes, (testtime).to_bytes(4, 'little'))
94+
95 @unittest.skipIf(sys.flags.optimize > 0, 'test does not work with -O')
96 def test_double_dot_no_clobber(self):
97 # http://bugs.python.org/issue22966