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
34
35
36
37
38
39
40
41
42
| | Always provide the same date and time in 'Py_GetBuildInfo'.
This is the information shown at the REPL and in 'sys.version'.
We cannot pass it in CPPFLAGS due to whitespace in the DATE string.
--- Modules/getbuildinfo.c
+++ Modules/getbuildinfo.c
@@ -4,6 +4,10 @@
#include <stdio.h>
#endif
+/* Deterministic date and time. */
+#define DATE "Jan 1 1970"
+#define TIME "00:00:01"
+
#ifndef DATE
#ifdef __DATE__
#define DATE __DATE__
--- Lib/importlib/_bootstrap.py
+++ Lib/importlib/_bootstrap.py
@@ -1443,7 +1443,8 @@ class SourceLoader(_LoaderBasics):
Implementing this method allows the loader to read bytecode files.
Raises IOError when the path cannot be handled.
"""
- return {'mtime': self.path_mtime(path)}
+ return {'mtime': float(_os.environ.get(b'SOURCE_DATE_EPOCH',
+ st.st_mtime))}
def _cache_bytecode(self, source_path, cache_path, data):
"""Optional method which writes data (bytes) to a file path (a str).
@@ -1580,7 +1581,10 @@ class SourceFileLoader(FileLoader, SourceLoader):
def path_stats(self, path):
"""Return the metadata for the path."""
st = _path_stat(path)
- return {'mtime': st.st_mtime, 'size': st.st_size}
+ return {
+ 'mtime': float(_os.environ.get(b'SOURCE_DATE_EPOCH', st.st_mtime)),
+ 'size': st.st_size
+ }
def _cache_bytecode(self, source_path, bytecode_path, data):
# Adapt between the two APIs
|