mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
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.
This commit is contained in:
parent
6f6eb35f9b
commit
ccbe5818af
4 changed files with 22 additions and 1 deletions
|
@ -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 ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue