diff options
author | 2018-01-24 22:26:18 +0100 | |
---|---|---|
committer | 2018-01-24 13:26:18 -0800 | |
commit | ccbe5818af20f8c12043f5c30c277a74714405e0 (patch) | |
tree | 5ca77fca24e3ec927647334dfb5e882560546039 /Lib/py_compile.py | |
parent | bpo-32248 - Implement `ResourceReader` and `get_resource_reader()` for zipim... (diff) | |
download | cpython-ccbe5818af20f8c12043f5c30c277a74714405e0.tar.gz cpython-ccbe5818af20f8c12043f5c30c277a74714405e0.tar.bz2 cpython-ccbe5818af20f8c12043f5c30c277a74714405e0.zip |
bpo-29708: Setting SOURCE_DATE_EPOCH forces hash-based .pyc files (GH-5200)
To support reproducible builds, the setting of of SOURCE_DATE_EPOCH triggers the py_compile module -- and by extension, compileall -- to forcibly compile with hash-based .pyc files. This eliminates the possibility of timestamp-based .pyc files which vary between builds.
Diffstat (limited to 'Lib/py_compile.py')
-rw-r--r-- | Lib/py_compile.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/py_compile.py b/Lib/py_compile.py index a0f4defdce6..16dc0a011ff 100644 --- a/Lib/py_compile.py +++ b/Lib/py_compile.py @@ -112,6 +112,8 @@ def compile(file, cfile=None, dfile=None, doraise=False, optimize=-1, the resulting file would be regular and thus not the same type of file as it was previously. """ + if os.environ.get('SOURCE_DATE_EPOCH'): + invalidation_mode = PycInvalidationMode.CHECKED_HASH if cfile is None: if optimize >= 0: optimization = optimize if optimize >= 1 else '' |