mirror of
https://https.git.savannah.gnu.org/git/guix.git/
synced 2025-07-17 20:40:40 +02:00
gnu: python-2: Honor 'SOURCE_DATE_EPOCH'.
* gnu/packages/patches/python-2.7-source-date-epoch.patch: New file. * gnu/packages/python.scm (python-2)[source]: Use it. [arguments]: Set SOURCE_DATE_EPOCH in 'patch-lib-shells' phase. * guix/build/python-build-system.scm (set-SOURCE-DATE-EPOCH): New procedure. (%standard-phases): Add it. * gnu-system.am (dist_patch_DATA): Add patch.
This commit is contained in:
parent
f8e7fdc416
commit
dedc832070
4 changed files with 49 additions and 1 deletions
33
gnu/packages/patches/python-2.7-source-date-epoch.patch
Normal file
33
gnu/packages/patches/python-2.7-source-date-epoch.patch
Normal file
|
@ -0,0 +1,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);
|
Loading…
Add table
Add a link
Reference in a new issue