From ad11fa56e0981df69ce1f58e50c7204893f14b77 Mon Sep 17 00:00:00 2001 From: Miro Hrončok Date: Jul 17 2019 09:29:56 +0000 Subject: [PATCH 1/5] Remove the OPENSSL_CONF=/non-existing-file workaround The test was fixed upstream to expect different config on Fedora. Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1618753 (Note that we still keep that on the CI for older Python versions.) --- diff --git a/python38.spec b/python38.spec index 99ab116..c4dcb51 100644 --- a/python38.spec +++ b/python38.spec @@ -924,12 +924,6 @@ CheckPython() { ConfName=$1 ConfDir=$(pwd)/build/$ConfName - # Fedora sets TLSv1 as explicit minimum version. - # Python's test suite assumes that the minimum protocol version is set to - # a magic marker. We workaround the test problem by setting: - export OPENSSL_CONF=/non-existing-file - # https://bugzilla.redhat.com/show_bug.cgi?id=1618753 - echo STARTING: CHECKING OF PYTHON FOR CONFIGURATION: $ConfName # Note that we're running the tests using the version of the code in the From c76264c26b6286b47ba0d0bbc2e56331584925d6 Mon Sep 17 00:00:00 2001 From: Miro Hrončok Date: Jul 17 2019 09:30:02 +0000 Subject: [PATCH 2/5] Add %python_provide provides This allows easier compatibility back and forth once (and if) https://fedoraproject.org/wiki/Changes/Python_means_Python3 happens. This is not the full implementation of the change, as the python-unversioned package still needs to be added. This is currently a no-op as %python_provide does nothing for python3. --- diff --git a/python38.spec b/python38.spec index c4dcb51..f4af0de 100644 --- a/python38.spec +++ b/python38.spec @@ -197,6 +197,9 @@ BuildRequires: /usr/bin/dtrace # workaround http://bugs.python.org/issue19804 (test_uuid requires ifconfig) BuildRequires: /usr/sbin/ifconfig +# For %%python_provide +BuildRequires: python-rpm-macros + %if %{with rpmwheels} BuildRequires: python-setuptools-wheel BuildRequires: python-pip-wheel @@ -346,6 +349,8 @@ Provides: bundled(python3-pip) = 19.0.3 Provides: bundled(python3-setuptools) = 40.8.0 %endif +%{?python_provide:%python_provide python3-libs} + # There are files in the standard library that have python shebang. # We've filtered the automatic requirement out so libs are installable without # the main package. This however makes it pulled in by default. @@ -367,6 +372,8 @@ BuildRequires: python-rpm-macros Requires: python-rpm-macros Requires: python3-rpm-macros +%{?python_provide:%python_provide python3-devel} + %if %{without bootstrap} # This is not "API" (packages that need setuptools should still BuildRequire it) # However some packages apparently can build both with and without setuptools @@ -411,6 +418,8 @@ Provides: %{name}-tools = %{version}-%{release} Provides: %{name}-tools%{?_isa} = %{version}-%{release} Obsoletes: %{name}-tools < %{version}-%{release} +%{?python_provide:%python_provide python3-idle} + %description idle IDLE is Python’s Integrated Development and Learning Environment. @@ -428,6 +437,8 @@ configuration, browsers, and other dialogs. Summary: A GUI toolkit for Python Requires: %{name} = %{version}-%{release} +%{?python_provide:%python_provide python3-tkinter} + %description tkinter The Tkinter (Tk interface) library is a graphical user interface toolkit for the Python programming language. @@ -438,6 +449,8 @@ Summary: The self-test suite for the main python3 package Requires: %{name} = %{version}-%{release} Requires: %{name}-libs%{?_isa} = %{version}-%{release} +%{?python_provide:%python_provide python3-test} + %description test The self-test suite for the Python interpreter. @@ -460,6 +473,8 @@ Requires: %{name}-test%{?_isa} = %{version}-%{release} Requires: %{name}-tkinter%{?_isa} = %{version}-%{release} Requires: %{name}-idle%{?_isa} = %{version}-%{release} +%{?python_provide:%python_provide python3-debug} + %description debug python3-debug provides a version of the Python runtime with numerous debugging features enabled, aimed at advanced Python users such as developers of Python From 1de59aaeafb7e08c78a4455c1630ad9f1f910208 Mon Sep 17 00:00:00 2001 From: Miro Hrončok Date: Jul 17 2019 09:30:07 +0000 Subject: [PATCH 3/5] Python now means Python 3 - https://fedoraproject.org/wiki/Changes/Python_means_Python3 - The python-unversioned-command package is no longer Python 2, but 3 - The python, pydoc, python-config, python-debug, idle, pygettext.py and msgfmt.py commands are now in python3 --- diff --git a/python38.spec b/python38.spec index f4af0de..9a4c2c1 100644 --- a/python38.spec +++ b/python38.spec @@ -303,6 +303,18 @@ Provides: python%{pyshortver} = %{version}-%{release} # 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. @@ -338,6 +350,22 @@ Packages containing additional libraries for Python are generally named with 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 @@ -357,6 +385,18 @@ Provides: bundled(python3-setuptools) = 40.8.0 # 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 @@ -398,6 +438,10 @@ Provides: 2to3 = %{version}-%{release} 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 @@ -413,11 +457,15 @@ Requires: %{name} = %{version}-%{release} 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 @@ -473,6 +521,9 @@ Requires: %{name}-test%{?_isa} = %{version}-%{release} 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 @@ -891,6 +942,20 @@ rm %{buildroot}%{_libdir}/libpython3.so 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 @@ -998,10 +1063,14 @@ CheckPython optimized %{_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 @@ -1254,11 +1323,15 @@ CheckPython optimized %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 @@ -1347,6 +1420,7 @@ CheckPython optimized %if %{without flatpackage} %files debug %{_bindir}/python3-debug +%{_bindir}/python-debug %endif # Analog of the core subpackage's files: From 3c11304c077826a68f8c582d3488b707933b311a Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Jul 17 2019 09:30:13 +0000 Subject: [PATCH 4/5] Move test.support module to python3-test subpackage More info: https://fedoraproject.org/wiki/Changes/Move_test.support_module_to_python3-test_subpackage --- diff --git a/python38.spec b/python38.spec index 9a4c2c1..c18063f 100644 --- a/python38.spec +++ b/python38.spec @@ -1115,20 +1115,6 @@ CheckPython optimized %{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 @@ -1400,16 +1386,6 @@ CheckPython optimized %{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. From b1d162edf5f1814b54a84dd8bbd0cebd1e1d5a81 Mon Sep 17 00:00:00 2001 From: Miro Hrončok Date: Jul 17 2019 09:30:32 +0000 Subject: [PATCH 5/5] Restore pyc to TIMESTAMP invalidation mode as default in rpmbubild See https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/57#comment-27426 --- diff --git a/00328-pyc-timestamp-invalidation-mode.patch b/00328-pyc-timestamp-invalidation-mode.patch new file mode 100644 index 0000000..87515c4 --- /dev/null +++ b/00328-pyc-timestamp-invalidation-mode.patch @@ -0,0 +1,55 @@ +From 746a45acd333174c3174230833b45f537bd92889 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +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 + diff --git a/python38.spec b/python38.spec index c18063f..a65d843 100644 --- a/python38.spec +++ b/python38.spec @@ -261,6 +261,11 @@ Patch251: 00251-change-user-install-location.patch # 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., @@ -604,6 +609,7 @@ rm Lib/ensurepip/_bundled/*.whl %patch251 -p1 %patch274 -p1 +%patch328 -p1 # Remove files that should be generated by the build