gnu: Ceph: Update to 14.2.5.
[jackhill/guix/guix.git] / gnu / packages / patches / python-2.7-source-date-epoch.patch
1 Honor the 'SOURCE_DATE_EPOCH' environment variable to allow for
2 determinitic builds.
3
4 --- a/Lib/py_compile.py
5 +++ b/Lib/py_compile.py
6 @@ -105,7 +105,10 @@ def compile(file, cfile=None, dfile=None, doraise=False):
7 """
8 with open(file, 'U') as f:
9 try:
10 - timestamp = long(os.fstat(f.fileno()).st_mtime)
11 + if 'SOURCE_DATE_EPOCH' in os.environ:
12 + timestamp = long(os.environ['SOURCE_DATE_EPOCH'])
13 + else:
14 + timestamp = long(os.fstat(f.fileno()).st_mtime)
15 except AttributeError:
16 timestamp = long(os.stat(file).st_mtime)
17 codestring = f.read()
18 diff --git a/Python/import.c b/Python/import.c
19 index e47ce63..7eecf9c 100644
20 --- a/Python/import.c
21 +++ b/Python/import.c
22 @@ -945,6 +945,11 @@ write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat, t
23 /* Now write the true mtime (as a 32-bit field) */
24 fseek(fp, 4L, 0);
25 assert(mtime <= 0xFFFFFFFF);
26 + if (Py_GETENV("SOURCE_DATE_EPOCH") != NULL) {
27 + const char *epoch = Py_GETENV("SOURCE_DATE_EPOCH");
28 + mtime = atoi(epoch);
29 + }
30 +
31 PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION);
32 fflush(fp);
33 fclose(fp);