Building singlespec for only the default python on Tumbleweed (and SLES15/Leap15)?
Hi all, I finally have all the bits and pieces to get nitropy aka pynitrokey into Tumbleweed. The package itself is building and working, but I would like to polish it up a little. One thing I might have overlooked in the Python-Packaging documentation is how to build for only the default python on Tumbleweed. I currently have this in the spec: %{?sle15_python_module_pythons} %define skip_python38 1 %define skip_python39 1 %define skip_python310 1 %define skip_python312 1 This will build it for python3.11 now on Tumbleweed and SLES15 (if the dependencies are there). But it will break once Tumbleweed switches to 3.12. Is there a nice little macro to achieve that? The %primary_python macro is not set by the sles15 macro, AFAICT. If there is no other way, I'll use a "0%{?suse_version} < 1699" thingy to target SLES15. But if there is a nicer way I would like to use that... Kind Regards, Johannes -- Johannes Kastl Linux Consultant & Trainer Tel.: +49 (0) 151 2372 5802 Mail: kastl@b1-systems.de B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg http://www.b1-systems.de GF: Ralph Dehner Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
Am 01.07.23 um 10:16 schrieb Johannes Kastl:
Hi all,
I finally have all the bits and pieces to get nitropy aka pynitrokey into Tumbleweed. The package itself is building and working, but I would like to polish it up a little.
One thing I might have overlooked in the Python-Packaging documentation is how to build for only the default python on Tumbleweed.
...
Is there a nice little macro to achieve that? The %primary_python macro is not set by the sles15 macro, AFAICT. If there is no other way, I'll use a "0%{?suse_version} < 1699" thingy to target SLES15. But if there is a nicer way I would like to use that...
1. Clean solution: https://en.opensuse.org/openSUSE:Packaging_Python#Python_3_(Leap_and_Tumblew...) %define pythons python3 This will override all the shenanigangs with the %sle15* macros. I am not a big fan of those anyway, but if you need to make a distinction because you cannot work with python 3.6: 2. Explicit verbose solution: %if 0%{suse_version} < 1699 %{?sle15_python_module_pythons} %else %define pythons python3 %endif 3. Compact solution: %{?sle15_python_module_pythons}%{?!sle15_python_module_pythons:%define pythons python3} - Ben
Good morning Ben, On 01.07.23 at 14:30 Ben Greiner wrote:
Am 01.07.23 um 10:16 schrieb Johannes Kastl:
One thing I might have overlooked in the Python-Packaging documentation is how to build for only the default python on Tumbleweed.
2. Explicit verbose solution:
%if 0%{suse_version} < 1699 %{?sle15_python_module_pythons} %else %define pythons python3 %endif
Thanks, that works (and is easier to understand than the compact solution). Kind Regards, Johannes -- Johannes Kastl Linux Consultant & Trainer Tel.: +49 (0) 151 2372 5802 Mail: kastl@b1-systems.de B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg http://www.b1-systems.de GF: Ralph Dehner Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
On 2023-07-01, 12:30 GMT, Ben Greiner wrote:
1. Clean solution:
https://en.opensuse.org/openSUSE:Packaging_Python#Python_3_(Leap_and_Tumblew...) %define pythons python3
That’s crazily complicated. For applications which don’t want to be part of the Python stack but they just happen to be written in Python (classical examples are Mercurial and Breezy) the simplest correct solution is just not to use singlespec macros at all. 1. Remove %python_subpackages macro 2. All %{python_module foo} BuildRequires replace with python3-foo 3. All python-foo Requires replace with python3-foo 4. Replace %pyproject_wheel with %python3_pyproject_wheel and %pyproject_install with %python3_pyproject_install 5. Remove all %python_expand macros 6. Replace all $python* macros with python3* ones 7. In %files replace %{python_sitelib} with %{python3_sitelib} 8. Remove %{python_files} from %files 9. Remove all related %define-s. I hope that’s all. The result is exactly what I believe you want: program which uses just the primary Python interpreter and related packages. Best, Matěj -- https://matej.ceplovi.cz/blog/, @mcepl@floss.social GPG Finger: 3C76 A027 CA45 AD70 98B5 BC1D 7920 5802 880B C9D8 You either die a hero or you live long enough to see yourself become the villain. -- Harvey Dent in The Dark Knight
participants (3)
-
Ben Greiner
-
Johannes Kastl
-
Matěj Cepl