2020-07-20 19:52:13 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-07-15 13:38:52 +00:00
|
|
|
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
|
|
|
Date: Thu, 11 Jul 2019 13:44:13 +0200
|
|
|
|
Subject: [PATCH] 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
|
2020-07-20 19:52:13 +00:00
|
|
|
Downstream only: only used when building RPM packages
|
|
|
|
Ideally, we should talk to upstream and explain why we don't want this
|
2019-07-15 13:38:52 +00:00
|
|
|
---
|
|
|
|
Lib/py_compile.py | 3 ++-
|
|
|
|
Lib/test/test_py_compile.py | 2 ++
|
|
|
|
2 files changed, 4 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/Lib/py_compile.py b/Lib/py_compile.py
|
2021-11-08 07:25:56 +00:00
|
|
|
index 388614e51b..db52725016 100644
|
2019-07-15 13:38:52 +00:00
|
|
|
--- a/Lib/py_compile.py
|
|
|
|
+++ b/Lib/py_compile.py
|
|
|
|
@@ -70,7 +70,8 @@ class PycInvalidationMode(enum.Enum):
|
|
|
|
|
|
|
|
|
|
|
|
def _get_default_invalidation_mode():
|
|
|
|
- if os.environ.get('SOURCE_DATE_EPOCH'):
|
|
|
|
+ if (os.environ.get('SOURCE_DATE_EPOCH') and not
|
|
|
|
+ os.environ.get('RPM_BUILD_ROOT')):
|
|
|
|
return PycInvalidationMode.CHECKED_HASH
|
|
|
|
else:
|
|
|
|
return PycInvalidationMode.TIMESTAMP
|
|
|
|
diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py
|
2022-07-11 22:50:26 +00:00
|
|
|
index a4a52b180d..e53f5d92aa 100644
|
2019-07-15 13:38:52 +00:00
|
|
|
--- a/Lib/test/test_py_compile.py
|
|
|
|
+++ b/Lib/test/test_py_compile.py
|
2020-08-11 22:04:34 +00:00
|
|
|
@@ -19,6 +19,7 @@ def without_source_date_epoch(fxn):
|
2019-07-15 13:38:52 +00:00
|
|
|
def wrapper(*args, **kwargs):
|
2020-10-09 10:25:22 +00:00
|
|
|
with os_helper.EnvironmentVarGuard() as env:
|
2019-07-15 13:38:52 +00:00
|
|
|
env.unset('SOURCE_DATE_EPOCH')
|
|
|
|
+ env.unset('RPM_BUILD_ROOT')
|
|
|
|
return fxn(*args, **kwargs)
|
|
|
|
return wrapper
|
|
|
|
|
2020-08-11 22:04:34 +00:00
|
|
|
@@ -29,6 +30,7 @@ def with_source_date_epoch(fxn):
|
2019-07-15 13:38:52 +00:00
|
|
|
def wrapper(*args, **kwargs):
|
2020-10-09 10:25:22 +00:00
|
|
|
with os_helper.EnvironmentVarGuard() as env:
|
2019-07-15 13:38:52 +00:00
|
|
|
env['SOURCE_DATE_EPOCH'] = '123456789'
|
|
|
|
+ env.unset('RPM_BUILD_ROOT')
|
|
|
|
return fxn(*args, **kwargs)
|
|
|
|
return wrapper
|
|
|
|
|