unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob be1f8e010eafd19b758d87869169c41ba959d695 1224 bytes (raw)
name: patches/python-2.7-source-date-epoch.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 
Honor the 'SOURCE_DATE_EPOCH' environment variable to allow for
determinitic builds.

--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -105,7 +105,10 @@ def compile(file, cfile=None, dfile=None, doraise=False):
     """
     with open(file, 'U') as f:
         try:
-            timestamp = long(os.fstat(f.fileno()).st_mtime)
+            if 'SOURCE_DATE_EPOCH' in os.environ:
+                timestamp = long(os.environ['SOURCE_DATE_EPOCH'])
+            else:
+                timestamp = long(os.fstat(f.fileno()).st_mtime)
         except AttributeError:
             timestamp = long(os.stat(file).st_mtime)
         codestring = f.read()
diff --git a/Python/import.c b/Python/import.c
index e47ce63..7eecf9c 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -945,6 +945,11 @@ write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat, t
     /* Now write the true mtime (as a 32-bit field) */
     fseek(fp, 4L, 0);
     assert(mtime <= 0xFFFFFFFF);
+    if (Py_GETENV("SOURCE_DATE_EPOCH") != NULL) {
+	const char *epoch = Py_GETENV("SOURCE_DATE_EPOCH");
+	mtime = atoi(epoch);
+    }
+
     PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION);
     fflush(fp);
     fclose(fp);

debug log:

solving be1f8e010eafd19b758d87869169c41ba959d695 ...
found be1f8e010eafd19b758d87869169c41ba959d695 in https://git.savannah.gnu.org/cgit/guix.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).