Blame SOURCES/00328-pyc-timestamp-invalidation-mode.patch

1a5cfa
From aedd897c6371bc54d3b2e2c9420fce6730c2acff Mon Sep 17 00:00:00 2001
6551b0
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
6551b0
Date: Thu, 11 Jul 2019 13:44:13 +0200
6551b0
Subject: [PATCH] 00328: Restore pyc to TIMESTAMP invalidation mode as default
6551b0
 in rpmbuild
6551b0
6551b0
Since Fedora 31, the $SOURCE_DATE_EPOCH is set in rpmbuild to the latest
6551b0
%changelog date. This makes Python default to the CHECKED_HASH pyc
6551b0
invalidation mode, bringing more reproducible builds traded for an import
6551b0
performance decrease. To avoid that, we don't default to CHECKED_HASH
6551b0
when $RPM_BUILD_ROOT is set (i.e. when we are building RPM packages).
6551b0
6551b0
See https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/57#comment-27426
6551b0
---
6551b0
 Lib/py_compile.py           | 3 ++-
6551b0
 Lib/test/test_py_compile.py | 2 ++
6551b0
 2 files changed, 4 insertions(+), 1 deletion(-)
6551b0
6551b0
diff --git a/Lib/py_compile.py b/Lib/py_compile.py
6551b0
index 21736896af..310bed5620 100644
6551b0
--- a/Lib/py_compile.py
6551b0
+++ b/Lib/py_compile.py
6551b0
@@ -70,7 +70,8 @@ class PycInvalidationMode(enum.Enum):
6551b0
 
6551b0
 
6551b0
 def _get_default_invalidation_mode():
6551b0
-    if os.environ.get('SOURCE_DATE_EPOCH'):
6551b0
+    if (os.environ.get('SOURCE_DATE_EPOCH') and not
6551b0
+            os.environ.get('RPM_BUILD_ROOT')):
6551b0
         return PycInvalidationMode.CHECKED_HASH
6551b0
     else:
6551b0
         return PycInvalidationMode.TIMESTAMP
6551b0
diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py
1a5cfa
index d4a68c9320..ed09874023 100644
6551b0
--- a/Lib/test/test_py_compile.py
6551b0
+++ b/Lib/test/test_py_compile.py
6551b0
@@ -17,6 +17,7 @@ def without_source_date_epoch(fxn):
6551b0
     def wrapper(*args, **kwargs):
6551b0
         with support.EnvironmentVarGuard() as env:
6551b0
             env.unset('SOURCE_DATE_EPOCH')
6551b0
+            env.unset('RPM_BUILD_ROOT')
6551b0
             return fxn(*args, **kwargs)
6551b0
     return wrapper
6551b0
 
6551b0
@@ -27,6 +28,7 @@ def with_source_date_epoch(fxn):
6551b0
     def wrapper(*args, **kwargs):
6551b0
         with support.EnvironmentVarGuard() as env:
6551b0
             env['SOURCE_DATE_EPOCH'] = '123456789'
6551b0
+            env.unset('RPM_BUILD_ROOT')
6551b0
             return fxn(*args, **kwargs)
6551b0
     return wrapper
6551b0
 
6551b0
-- 
1a5cfa
2.26.2
6551b0