Skip to content

Commit bc9440c

Browse files
committed
Original version which doesn't force hashed *.pyc files
Created by Bernhard M. Wiedemann <[email protected]> -- gh#python#296 Patch: 0001-allow-for-reproducible-builds-of-python-packages.patch
1 parent 2dfaad1 commit bc9440c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Lib/py_compile.py

+7
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ def compile(file, cfile=None, dfile=None, doraise=False, optimize=-1):
137137
except FileExistsError:
138138
pass
139139
source_stats = loader.path_stats(file)
140+
sde = os.environ.get('SOURCE_DATE_EPOCH')
141+
if sde and source_stats['mtime'] > int(sde):
142+
source_stats['mtime'] = int(sde)
143+
try:
144+
os.utime(file, (source_stats['mtime'], source_stats['mtime']))
145+
except PermissionError:
146+
pass
140147
bytecode = importlib._bootstrap_external._code_to_bytecode(
141148
code, source_stats['mtime'], source_stats['size'])
142149
mode = importlib._bootstrap_external._calc_mode(file)

0 commit comments

Comments
 (0)