Am 22.11.22 um 10:03 schrieb Johannes Kastl:
Hi Ben,
thanks for taking the time to answer. Appreciated!
On 22.11.22 at 09:50 Ben Greiner wrote:
`%primary_python` affects the behavior and contents of the python310{,-base} packages. The definition for the primary interpreter is where /usr/bin/python3 points to. Thus, for having any effect, you have to rebuild pythin310{,-base} too. Once you have this, every python module in your stack which you rebuild yourself will have a `Provides: python3-foo` and override the python3-foo for Python 3.6. OTOH, this will require a lot of "Prefer:" lines, because the distro will now have multiple providers of python3-foo. Otherwise I do not see why `%primary_python` would need to be set at all.
Objections, your honour! :-)
I am not building the python310 packages, those are delivered by Leap/SLES. And they do not change the default python (i.e. where /usr/bin/python3 links to) and should not.
Then you should not redefine %primary_python to python310!
I still do not get why?
If this only affects the python310 and python310-base packages during build and I am not rebuilding them, there is no negative impact?
It depends which specfiles from Factory you did reuse: bmwiedemann/openSUSE> git grep primary_python packages/_/_project/_config:%define primary_pythonpython310 packages/_/_project/_config:%primary_pythonpython310 packages/p/python-ctypeslib2/python-ctypeslib2.spec:%define primary_python3 python%{python3_version_nodots} packages/p/python-ctypeslib2/python-ctypeslib2.spec:Provides: %{primary_python3}-ctypeslib2 = %{version}-%{release} packages/p/python-ctypeslib2/python-ctypeslib2.spec:Obsoletes: %{primary_python3}-ctypeslib2 < %{version}-%{release} packages/p/python-flit-core/.rev: <comment>- Use prjconf provided primary_pythonif available packages/p/python-flit-core/python-flit-core.changes:- Use prjconf provided primary_pythonif available packages/p/python-flit-core/python-flit-core.spec:# fallback if primary_pythonis not available from the project configuration packages/p/python-flit-core/python-flit-core.spec:%{?!primary_python:%define primary_pythonpython3%{?!sle_version:10}} packages/p/python-flit-core/python-flit-core.spec:%define pprefix %{primary_python} packages/p/python-flit-core/python-flit-core.spec:%define pythons %{primary_python} packages/p/python-flit-core/python-flit-core.spec:%{expand:%%define skip_%{primary_python} 1} packages/p/python-flit-core/python-flit-core.spec:#!BuildIgnore: %{primary_python}-packaging packages/p/python-packaging/python-packaging.spec:# fallback if primary_pythonis not available from the project configuration packages/p/python-packaging/python-packaging.spec:%{?!primary_python:%define primary_pythonpython3%{?!sle_version:10}} packages/p/python-packaging/python-packaging.spec:%define pprefix %{primary_python} packages/p/python-packaging/python-packaging.spec:%define pythons %{primary_python} packages/p/python-packaging/python-packaging.spec:%{expand:%%define skip_%{primary_python} 1} packages/p/python-packaging/python-packaging.spec:Requires: %{primary_python}-pyparsing >= 2.0.2 packages/p/python-pyparsing/.rev:- Remove hardcoded primary_pythonvariable. packages/p/python-pyparsing/python-pyparsing.changes:- Remove hardcoded primary_pythonvariable. packages/p/python-pyparsing/python-pyparsing.spec:%define pprefix %{primary_python} packages/p/python-pyparsing/python-pyparsing.spec:%define pythons %{primary_python} packages/p/python-pyparsing/python-pyparsing.spec:%{expand:%%define skip_%{primary_python} 1} packages/p/python-qtconsole/python-qtconsole.spec:%if "%{python_flavor}" == "%{primary_python}" packages/p/python310/.rev: %primary_python(gh#openSUSE/python-rpm-macros#127). packages/p/python310/python310.changes: %primary_python(gh#openSUSE/python-rpm-macros#127). packages/p/python310/python310.spec:%if "%{python_pkg_name}" == "%{primary_python}" packages/p/python311/.rev: %primary_python(gh#openSUSE/python-rpm-macros#127). packages/p/python311/python311.changes: %primary_python(gh#openSUSE/python-rpm-macros#127). packages/p/python311/python311.spec:%if "%{python_pkg_name}" == "%{primary_python}" packages/p/python38/.rev: %primary_python(gh#openSUSE/python-rpm-macros#127). packages/p/python38/python38.changes: %primary_python(gh#openSUSE/python-rpm-macros#127). packages/p/python38/python38.spec:%if "%{python_pkg_name}" == "%{primary_python}" packages/p/python39/.rev: %primary_python(gh#openSUSE/python-rpm-macros#127). packages/p/python39/python39.changes: %primary_python(gh#openSUSE/python-rpm-macros#127). packages/p/python39/python39.spec:%if "%{python_pkg_name}" == "%{primary_python}" If you did not branch any of these, don't bother. %primary_python is not used by any of the python-rpm-macros.
And inside "my packages", everything just seems to work? I do not want those packages to use the default python (which is 3.6) and I do not want to replace it with 3.10. The SLES-packages are apparently built in a way, that they can be installed in parallel without changing the default python.
The crucial part is the redefinition of %pythons and that you are properly expanding "singlespec" through %python_subpackages, even though the expansion only contains one entry.
For everything else, change python3- to python310-, either directly or thourgh a macro-redirection like %mypython.
Then I would need to also add some if-condition to set this mypython macro inside the spec for Tumbleweed, where I cannot change the prjconf.
And hardcoding python310- will break, once Tumbleweed switches to python311 as its default python. But piggybacking on %primary_python everything works automagically (at least I hope so...).
Hence the non-singlespec packages in Tumbleweed using the python3- alias for the primary interpreter. Change your non-singlespec packages to: %if 0%{?suse_version} < 1550 %define mypython python310 %define __mypython %__python310 %define mypython_sitelib %python310_sitelib # and so on, whatever is used in the specfile %else %define mypython python3 %define __mypython %__python3 %define mypython_sitelib %python3_sitelib # and so on, whatever is used in the specfile %endif BuildRequires: %{mypython}-foo Requires: %{mypython}-foo %files %{mypython_sitelib}/foo %{mypython_sitelib}/foo-%{version}*-info The singlespec stuff works by just changing %pythons in the prjconf. - Ben