From e4c0623005014d87c85b97b900d6cbb3d32a4009354ce673ab5e3d65b8a9c3b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Thu, 1 Feb 2024 14:07:57 +0000 Subject: [PATCH] Use cmake for compiling and installing the python modules OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=655 --- cmake_python_version.diff | 15 +++++++++ python-rpm.changes | 4 +-- python-rpm.spec | 23 ++++++-------- python_setup.diff | 64 --------------------------------------- rpm.spec | 5 +-- 5 files changed, 29 insertions(+), 82 deletions(-) create mode 100644 cmake_python_version.diff delete mode 100644 python_setup.diff diff --git a/cmake_python_version.diff b/cmake_python_version.diff new file mode 100644 index 0000000..70177d3 --- /dev/null +++ b/cmake_python_version.diff @@ -0,0 +1,15 @@ +--- CMakeLists.txt.orig 2024-02-01 13:24:18.665660569 +0000 ++++ CMakeLists.txt 2024-02-01 13:25:07.917586376 +0000 +@@ -238,7 +238,11 @@ endif() + list(APPEND db_backends dummy) + + if (ENABLE_PYTHON) +- find_package(Python3 3.2 COMPONENTS Interpreter Development REQUIRED) ++ if (WITH_PYTHON_VERSION) ++ find_package(Python3 ${WITH_PYTHON_VERSION} EXACT COMPONENTS Interpreter Development REQUIRED) ++ else() ++ find_package(Python3 3.2 COMPONENTS Interpreter Development REQUIRED) ++ endif() + endif() + + if (WITH_CAP) diff --git a/python-rpm.changes b/python-rpm.changes index f8b3fb2..1dd8a77 100644 --- a/python-rpm.changes +++ b/python-rpm.changes @@ -1,7 +1,7 @@ ------------------------------------------------------------------- -Thu Feb 1 11:59:47 UTC 2024 - Dirk Müller +Thu Feb 1 15:07:34 CET 2024 - mls@suse.de -- buildrequire setuptools +- Use cmake for compiling and installing the python modules ------------------------------------------------------------------- Mon Oct 30 14:13:37 UTC 2023 - Matej Cepl diff --git a/python-rpm.spec b/python-rpm.spec index bdd3c01..91ef653 100644 --- a/python-rpm.spec +++ b/python-rpm.spec @@ -28,9 +28,6 @@ Group: Development/Libraries/Python URL: https://rpm.org/ #Git-Clone: https://github.com/rpm-software-management/rpm BuildRequires: %{python_module devel} -BuildRequires: %{python_module pip} -BuildRequires: %{python_module setuptools} -BuildRequires: %{python_module wheel} BuildRequires: cmake BuildRequires: fdupes BuildRequires: file-devel @@ -70,18 +67,16 @@ that will manipulate RPM packages and databases. %prep %{expand:%(sed -n -e '/^%%prep/,/^%%install/p' <%{_sourcedir}/rpm.spec | sed -e '1d' -e '$d')} -# The build stage is already declared and pulled in from rpm.spec -cd .. -cp _build/python/setup.py python -pushd python -%pyproject_wheel -popd - %install -pushd python -%pyproject_install -popd -%python_expand %fdupes %{buildroot}%{$python_sitearch} +cd _build +%{python_expand # +cmake .. -U\*Python3\* -DWITH_PYTHON_VERSION=%{$python_version} +make DESTDIR=%{buildroot} -C python clean +make DESTDIR=%{buildroot} -C python install +} + +%python_compileall +rm -rf %{buildroot}/%{_defaultdocdir}/%{NAME} %files %{python_files} %{python_sitearch}/rpm diff --git a/python_setup.diff b/python_setup.diff deleted file mode 100644 index 8f115fd..0000000 --- a/python_setup.diff +++ /dev/null @@ -1,64 +0,0 @@ ---- python/CMakeLists.txt.orig 2023-10-11 14:55:22.453584792 +0000 -+++ python/CMakeLists.txt 2023-10-11 14:56:41.989429746 +0000 -@@ -28,5 +28,6 @@ install(DIRECTORY examples TYPE DOC) - - set(egginfo ${PROJECT_NAME}-${PROJECT_VERSION}-py${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}.egg-info) - configure_file(rpm.egg-info.in ${egginfo} @ONLY) -+configure_file(setup.py.in setup.py @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${egginfo} - DESTINATION ${Python3_SITEARCH}) ---- python/setup.py.in.orig 2023-10-11 14:55:17.769593923 +0000 -+++ python/setup.py.in 2023-10-11 14:58:39.401200867 +0000 -@@ -0,0 +1,52 @@ -+#!/usr/bin/env python -+ -+from distutils.core import setup, Extension -+import subprocess -+import os -+ -+def pkgconfig(what): -+ out = [] -+ cmd = 'pkg-config %s %s' % (what, '@PROJECT_NAME@') -+ pcout = subprocess.check_output(cmd.split()).decode() -+ for token in pcout.split(): -+ out.append(token[2:]) -+ return out -+ -+cflags = ['-std=c99', '-Wno-strict-aliasing'] -+additional_link_args = [] -+ -+# See if we're building in-tree -+if True: -+ cflags.append('-I../include') -+ additional_link_args.extend(['-Wl,-L../_build/rpmio', -+ '-Wl,-L../_build/lib', -+ '-Wl,-L../_build/build', -+ '-Wl,-L../_build/sign']) -+ os.environ['PKG_CONFIG_PATH'] = '../_build' -+ -+rpmmod = Extension('rpm._rpm', -+ sources = ['header-py.c', 'rpmds-py.c', 'rpmfd-py.c', -+ 'rpmii-py.c', 'rpmkeyring-py.c', -+ 'rpmmacro-py.c', 'rpmmi-py.c', 'rpmps-py.c', -+ 'rpmstrpool-py.c', 'rpmfiles-py.c', -+ 'rpmarchive-py.c', 'rpmtd-py.c', -+ 'rpmte-py.c', 'rpmts-py.c', 'rpmver-py.c', -+ 'spec-py.c', -+ 'rpmmodule.c'], -+ include_dirs = pkgconfig('--cflags'), -+ library_dirs = pkgconfig('--libs-only-L'), -+ libraries = pkgconfig('--libs-only-l') + ['rpmbuild', 'rpmsign'], -+ extra_compile_args = cflags, -+ extra_link_args = additional_link_args -+ ) -+ -+setup(name='@PROJECT_NAME@', -+ version='@PROJECT_VERSION@', -+ description='Python bindings for rpm', -+ maintainer_email='rpm-maint@lists.rpm.org', -+ url='@PROJECT_HOMEPAGE_URL@', -+ license='GNU General Public License v2', -+ packages=['rpm'], -+ ext_modules=[rpmmod] -+ ) -+ diff --git a/rpm.spec b/rpm.spec index f135fe7..d09115a 100644 --- a/rpm.spec +++ b/rpm.spec @@ -111,8 +111,8 @@ Patch133: zstdpool.diff Patch134: zstdthreaded.diff Patch135: selinux_transactional_update.patch Patch136: rpmsort_reverse.diff -Patch137: python_setup.diff Patch138: canongnu.diff +Patch139: cmake_python_version.diff Patch6464: auto-config-update-aarch64-ppc64le.diff BuildRoot: %{_tmppath}/%{name}-%{version}-build # @@ -225,7 +225,8 @@ rm -rf sqlite %patch -P 100 -P 102 -P 103 %patch -P 117 %patch -P 122 -P 123 -%patch -P 131 -P 133 -P 134 -P 135 -P 136 -P 137 -P 138 +%patch -P 131 -P 133 -P 134 -P 135 -P 136 -P 138 +%patch -P 139 %ifarch aarch64 ppc64le riscv64 %patch6464