libdnf: enable python bindings

This commit is contained in:
Paul Meyer 2023-11-09 16:52:37 +01:00
parent a222ff94ba
commit 77cdfc9f62
4 changed files with 44 additions and 2 deletions

View File

@ -16,12 +16,18 @@
, rpm
, zchunk
, cppunit
, python
, swig
, glib
, sphinx
}:
stdenv.mkDerivation rec {
pname = "libdnf";
version = "0.72.0";
outputs = [ "out" "dev" "py" ];
src = fetchFromGitHub {
owner = "rpm-software-management";
repo = pname;
@ -44,6 +50,9 @@ stdenv.mkDerivation rec {
libyaml
libmodulemd
zchunk
python
swig
sphinx
];
propagatedBuildInputs = [
@ -58,18 +67,32 @@ stdenv.mkDerivation rec {
cp ${libsolv}/share/cmake/Modules/FindLibSolv.cmake cmake/modules/
'';
patches = [
./fix-python-install-dir.patch
];
postPatch = ''
# https://github.com/rpm-software-management/libdnf/issues/1518
substituteInPlace libdnf/libdnf.pc.in \
--replace '$'{prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@
substituteInPlace cmake/modules/FindPythonInstDir.cmake \
--replace "@PYTHON_INSTALL_DIR@" "$out/${python.sitePackages}"
'';
cmakeFlags = [
"-DWITH_GTKDOC=OFF"
"-DWITH_HTML=OFF"
"-DWITH_BINDINGS=OFF"
"-DPYTHON_DESIRED=${lib.head (lib.splitString ["."] python.version)}"
];
postInstall = ''
rm -r $out/${python.sitePackages}/hawkey/test
'';
postFixup = ''
moveToOutput "lib/${python.libPrefix}" "$py"
'';
meta = with lib; {
description = "Package management library";
homepage = "https://github.com/rpm-software-management/libdnf";

View File

@ -0,0 +1,12 @@
diff --git a/cmake/modules/FindPythonInstDir.cmake b/cmake/modules/FindPythonInstDir.cmake
index ed098ded..2a2e1543 100644
--- a/cmake/modules/FindPythonInstDir.cmake
+++ b/cmake/modules/FindPythonInstDir.cmake
@@ -1,6 +1 @@
-EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "
-from sys import stdout
-from sysconfig import get_path
-path=get_path(name='platlib', vars={'platbase':'${CMAKE_INSTALL_PREFIX}'})
-stdout.write(path)"
-OUTPUT_VARIABLE PYTHON_INSTALL_DIR)
+SET(PYTHON_INSTALL_DIR "@PYTHON_INSTALL_DIR@")

View File

@ -22658,7 +22658,7 @@ with pkgs;
libdnet = callPackage ../development/libraries/libdnet { };
libdnf = callPackage ../tools/package-management/libdnf { };
libdnf = callPackage ../tools/package-management/libdnf { python = python3; };
libdovi = callPackage ../development/libraries/libdovi { };

View File

@ -6139,6 +6139,13 @@ self: super: with self; {
libcst = callPackage ../development/python-modules/libcst { };
libdnf = lib.pipe pkgs.libdnf [
toPythonModule
(p: p.overrideAttrs (super: { meta = super.meta // { outputsToInstall = [ "py" ]; }; }))
(p: p.override { inherit python; })
(p: p.py)
];
libevdev = callPackage ../development/python-modules/libevdev { };
libfdt = toPythonModule (pkgs.dtc.override {