#34 Python now means Python 3 + Move test.support module to python3-test subpackage + pyc TIMESTAMP invalidation
Merged 2 months ago by pviktori. Opened 2 months ago by churchyard.
rpms/ churchyard/python38 big_switch_backport  into  master

@@ -0,0 +1,55 @@ 

+ From 746a45acd333174c3174230833b45f537bd92889 Mon Sep 17 00:00:00 2001

+ 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

+ ---

+  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

+ index 21736896af..310bed5620 100644

+ --- 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

+ index d6677ab45f..88059b127e 100644

+ --- a/Lib/test/test_py_compile.py

+ +++ b/Lib/test/test_py_compile.py

+ @@ -17,6 +17,7 @@ def without_source_date_epoch(fxn):

+      def wrapper(*args, **kwargs):

+          with support.EnvironmentVarGuard() as env:

+              env.unset('SOURCE_DATE_EPOCH')

+ +            env.unset('RPM_BUILD_ROOT')

+              return fxn(*args, **kwargs)

+      return wrapper

+  

+ @@ -27,6 +28,7 @@ def with_source_date_epoch(fxn):

+      def wrapper(*args, **kwargs):

+          with support.EnvironmentVarGuard() as env:

+              env['SOURCE_DATE_EPOCH'] = '123456789'

+ +            env.unset('RPM_BUILD_ROOT')

+              return fxn(*args, **kwargs)

+      return wrapper

+  

+ -- 

+ 2.21.0

+ 

file modified
+81 -25

@@ -262,6 +262,11 @@ 

  # Upstream uses Debian-style architecture naming. Change to match Fedora.

  Patch274: 00274-fix-arch-names.patch

  

+ # 00328 #

+ # Restore pyc to TIMESTAMP invalidation mode as default in rpmbubild

+ # See https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/57#comment-27426

+ Patch328: 00328-pyc-timestamp-invalidation-mode.patch

+ 

  # (New patches go here ^^^)

  #

  # When adding new patches to "python" and "python3" in Fedora, EL, etc.,

@@ -304,6 +309,18 @@ 

  # replace python36-3.6.2.

  Obsoletes: python%{pyshortver}

  

+ # https://fedoraproject.org/wiki/Changes/Move_usr_bin_python_into_separate_package

+ # https://fedoraproject.org/wiki/Changes/Python_means_Python3

+ # We recommend /usr/bin/python so users get it by default

+ # Versioned recommends are problematic, and we know that the package requires

+ # python3 back with fixed version, so we just use the path here:

+ Recommends: %{_bindir}/python

+ 

+ # In Fedora 31, /usr/bin/pydoc was moved here from Python 2.

+ # Ideally we'd have an explicit conflict with "/usr/bin/pydoc < 3",

+ # but file provides aren't versioned and the file moved across packages.

+ # Instead, we rely on the conflict in python3-libs.

+ 

  # Previously, this was required for our rewheel patch to work.

  # This is technically no longer needed, but we keep it recommended

  # for the developer experience.

@@ -339,6 +356,22 @@ 

  the "%{name}-" prefix.

  

  

+ # https://fedoraproject.org/wiki/Changes/Move_usr_bin_python_into_separate_package

+ # https://fedoraproject.org/wiki/Changes/Python_means_Python3

+ %package -n python-unversioned-command

+ Summary: The "python" command that runs Python 3

+ BuildArch: noarch

+ 

+ # In theory this could require any python3 version

+ Requires: python3 == %{version}-%{release}

+ # But since we want to provide versioned python, we require exact version

+ Provides: python = %{version}-%{release}

+ # This also save us an explicit conflict for older python3 builds

+ 

+ %description -n python-unversioned-command

+ This package contains /usr/bin/python - the "python" command that runs Python 3.

+ 

+ 

  %package libs

  Summary:        Python runtime libraries

  

@@ -358,6 +391,18 @@ 

  # See https://bugzilla.redhat.com/show_bug.cgi?id=1547131

  Recommends: %{name}%{?_isa} = %{version}-%{release}

  

+ # https://fedoraproject.org/wiki/Changes/Move_usr_bin_python_into_separate_package

+ # In Fedora 31, several "unversioned" files like /usr/bin/pydoc and all the

+ # "unversioned" provides were moved from python2 to python3.

+ # So, newer python3 packages need to conflict with old Python 2 builds that

+ # still provided unversioned Python.

+ # Since all python packages, new and old, have versioned requires on

+ # python?-libs, we do it here:

+ Conflicts: python-libs < 3

+ # (We explicitly conflict with python-libs and not python2-libs, so only the

+ # old Python 2 builds that still provided unversioned Python are handled.)

+ 

+ 

  %description libs

  This package contains runtime libraries for use by Python:

  - the majority of the Python standard library

@@ -393,6 +438,10 @@ 

  

  Conflicts: %{name} < %{version}-%{release}

  

+ # In Fedora 31, several "unversioned" files were moved here from Python 2:

+ # pygettext.py, msgfmt.py, python-config, python.pc

+ Conflicts: python-devel < 3

+ 

  %description devel

  This package contains the header files and configuration needed to compile

  Python extension modules (typically written in C or C++), to embed Python

@@ -408,11 +457,15 @@ 

  Requires: %{name}-tkinter = %{version}-%{release}

  

  Provides: idle3 = %{version}-%{release}

+ Provides: idle = %{version}-%{release}

  

  Provides: %{name}-tools = %{version}-%{release}

  Provides: %{name}-tools%{?_isa} = %{version}-%{release}

  Obsoletes: %{name}-tools < %{version}-%{release}

  

+ # In Fedora 31, /usr/bin/idle was moved here from Python 2.

+ Conflicts: python-tools < 3

+ 

  %{?python_provide:%python_provide python3-idle}

  

  %description idle

@@ -468,6 +521,9 @@ 

  Requires: %{name}-tkinter%{?_isa} = %{version}-%{release}

  Requires: %{name}-idle%{?_isa} = %{version}-%{release}

  

+ # In Fedora 31, /usr/bin/python-debug was moved here from Python 2.

+ Conflicts: python-debug < 3

+ 

  %{?python_provide:%python_provide python3-debug}

  

  %description debug

@@ -546,6 +602,7 @@ 

  

  %patch251 -p1

  %patch274 -p1

+ %patch328 -p1

  

  

  # Remove files that should be generated by the build

@@ -892,6 +949,20 @@ 

  rm %{buildroot}%{_mandir}/man1/python3.1*

  rm %{buildroot}%{_libdir}/pkgconfig/python3.pc

  rm %{buildroot}%{_libdir}/pkgconfig/python3-embed.pc

+ %else

+ # Link the unversioned stuff

+ # https://fedoraproject.org/wiki/Changes/Python_means_Python3

+ ln -s ./python3 %{buildroot}%{_bindir}/python

+ ln -s ./pydoc3 %{buildroot}%{_bindir}/pydoc

+ ln -s ./pygettext3.py %{buildroot}%{_bindir}/pygettext.py

+ ln -s ./msgfmt3.py %{buildroot}%{_bindir}/msgfmt.py

+ ln -s ./idle3 %{buildroot}%{_bindir}/idle

+ ln -s ./python3-config %{buildroot}%{_bindir}/python-config

+ ln -s ./python3.1 %{buildroot}%{_mandir}/man1/python.1

+ ln -s ./python3.pc %{buildroot}%{_libdir}/pkgconfig/python.pc

+ %if %{with debug_build}

+ ln -s ./python3-debug %{buildroot}%{_bindir}/python-debug

+ %endif

  %endif

  

  

@@ -999,10 +1070,14 @@ 

  

  %{_bindir}/python%{pybasever}

  %{_bindir}/python%{LDVERSION_optimized}

- %{_mandir}/*/*

+ %{_mandir}/*/*3*

  

  

  %if %{without flatpackage}

+ %files -n python-unversioned-command

+ %{_bindir}/python

+ %{_mandir}/*/python.1*

+ 

  %files libs

  %license LICENSE

  %doc README.rst

@@ -1047,20 +1122,6 @@ 

  %{pylibdir}/ensurepip/_bundled/*.whl

  %endif

  

- # The majority of the test module lives in the test subpackage

- # However test.support is in libs - it contains stuff used when testing your code

- # https://bugzilla.redhat.com/show_bug.cgi?id=596258

- %if %{without flatpackage}

- %dir %{pylibdir}/test/

- %dir %{pylibdir}/test/__pycache__/

- %dir %{pylibdir}/test/support/

- %dir %{pylibdir}/test/support/__pycache__/

- %{pylibdir}/test/__init__.py

- %{pylibdir}/test/__pycache__/__init__%{bytecode_suffixes}

- %{pylibdir}/test/support/*.py

- %{pylibdir}/test/support/__pycache__/*%{bytecode_suffixes}

- %endif

- 

  %dir %{pylibdir}/concurrent/

  %dir %{pylibdir}/concurrent/__pycache__/

  %{pylibdir}/concurrent/*.py

@@ -1255,11 +1316,15 @@ 

  

  %if %{without flatpackage}

  %{_bindir}/python3-config

+ %{_bindir}/python-config

  %{_libdir}/pkgconfig/python3.pc

+ %{_libdir}/pkgconfig/python.pc

  %{_libdir}/pkgconfig/python3-embed.pc

  %{_bindir}/pathfix.py

  %{_bindir}/pygettext3.py

+ %{_bindir}/pygettext.py

  %{_bindir}/msgfmt3.py

+ %{_bindir}/msgfmt.py

  %endif

  

  %{_bindir}/pygettext%{pybasever}.py

@@ -1328,16 +1393,6 @@ 

  %{pylibdir}/tkinter/test

  %{pylibdir}/unittest/test

  

- # stuff already owned by the libs subpackage

- # test requires libs, so we are safe not owning those dirs

- %if %{without flatpackage}

- %exclude %dir %{pylibdir}/test/

- %exclude %dir %{pylibdir}/test/__pycache__/

- %exclude %{pylibdir}/test/__init__.py

- %exclude %{pylibdir}/test/__pycache__/__init__%{bytecode_suffixes}

- %exclude %{pylibdir}/test/support/

- %endif

- 

  # We don't bother splitting the debug build out into further subpackages:

  # if you need it, you're probably a developer.

  

@@ -1348,6 +1403,7 @@ 

  %if %{without flatpackage}

  %files debug

  %{_bindir}/python3-debug

+ %{_bindir}/python-debug

  %endif

  

  # Analog of the core subpackage's files:

1 new commit added

  • Move test.support module to python3-test subpackage
2 months ago

1 new commit added

  • Restore pyc to TIMESTAMP invalidation mode as default in rpmbubild
2 months ago

Note that the first 2 commits don't change anything here and the third one only changes the bytecode in this package and hence it can wait for the b3 update just fine.

Pull-Request has been merged by pviktori

2 months ago