Skip to content

Commit bc022fe

Browse files
committed
00328: Restore pyc to TIMESTAMP invalidation mode as default in rpmbuild
Since Fedora 31, the $SOURCE_DATE_EPOCH is set in rpmbuild to the latest %changelog date. This makes Python default to the CHECKED_HASH pyc invalidation mode, bringing more reproducible builds traded for an import performance decrease. To avoid that, we don't default to CHECKED_HASH when $RPM_BUILD_ROOT is set (i.e. when we are building RPM packages). See https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/57#comment-27426 Downstream only: only used when building RPM packages Ideally, we should talk to upstream and explain why we don't want this
1 parent 284acf0 commit bc022fe

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/py_compile.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ class PycInvalidationMode(enum.Enum):
7070

7171

7272
def _get_default_invalidation_mode():
73-
if os.environ.get('SOURCE_DATE_EPOCH'):
73+
if (os.environ.get('SOURCE_DATE_EPOCH') and not
74+
os.environ.get('RPM_BUILD_ROOT')):
7475
return PycInvalidationMode.CHECKED_HASH
7576
else:
7677
return PycInvalidationMode.TIMESTAMP

Lib/test/test_py_compile.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def without_source_date_epoch(fxn):
1919
def wrapper(*args, **kwargs):
2020
with os_helper.EnvironmentVarGuard() as env:
2121
env.unset('SOURCE_DATE_EPOCH')
22+
env.unset('RPM_BUILD_ROOT')
2223
return fxn(*args, **kwargs)
2324
return wrapper
2425

@@ -29,6 +30,7 @@ def with_source_date_epoch(fxn):
2930
def wrapper(*args, **kwargs):
3031
with os_helper.EnvironmentVarGuard() as env:
3132
env['SOURCE_DATE_EPOCH'] = '123456789'
33+
env.unset('RPM_BUILD_ROOT')
3234
return fxn(*args, **kwargs)
3335
return wrapper
3436

0 commit comments

Comments
 (0)