From 29c88a0ce64fed33d93d02605c8420ff42d570ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Fri, 8 Nov 2024 15:06:50 -0800 Subject: [PATCH] python312Packages.gpgme: build out of tree --- pkgs/development/libraries/gpgme/default.nix | 37 +++----------- .../python-modules/gpgme/default.nix | 51 +++++++++++++++++++ .../gpgme/python313-support.patch | 0 pkgs/top-level/python-packages.nix | 7 ++- 4 files changed, 60 insertions(+), 35 deletions(-) create mode 100644 pkgs/development/python-modules/gpgme/default.nix rename pkgs/development/{libraries => python-modules}/gpgme/python313-support.patch (100%) diff --git a/pkgs/development/libraries/gpgme/default.nix b/pkgs/development/libraries/gpgme/default.nix index ee2003a393bc..58dccbfa2375 100644 --- a/pkgs/development/libraries/gpgme/default.nix +++ b/pkgs/development/libraries/gpgme/default.nix @@ -10,12 +10,9 @@ pth, libassuan, which, - ncurses, texinfo, buildPackages, qtbase ? null, - pythonSupport ? false, - swig ? null, # only for passthru.tests libsForQt5, qt6Packages, @@ -41,8 +38,6 @@ stdenv.mkDerivation rec { }; patches = [ - # Support Python 3.13 - ./python313-support.patch # Fix a test after disallowing compressed signatures in gpg (PR #180336) ./test_t-verify_double-plaintext.patch # Don't use deprecated LFS64 APIs (removed in musl 1.2.4) @@ -50,31 +45,12 @@ stdenv.mkDerivation rec { ./LFS64.patch ]; - postPatch = '' - # autoconf's beta detection requires a git repo to work - # and otherwise appends -unknown to the version number used in the python package which pip stumbles upon - substituteInPlace autogen.sh \ - --replace-fail 'tmp="-unknown"' 'tmp=""' - ''; - - nativeBuildInputs = - [ - autoreconfHook - gnupg - pkg-config - texinfo - ] - ++ lib.optionals pythonSupport [ - python3.pythonOnBuildForHost - python3.pkgs.pip - python3.pkgs.setuptools - python3.pkgs.wheel - ncurses - swig - which - ]; - - buildInputs = lib.optionals pythonSupport [ python3 ]; + nativeBuildInputs = [ + autoreconfHook + gnupg + pkg-config + texinfo + ]; propagatedBuildInputs = [ glib @@ -95,7 +71,6 @@ stdenv.mkDerivation rec { "--with-libgpg-error-prefix=${libgpg-error.dev}" "--with-libassuan-prefix=${libassuan.dev}" ] - ++ lib.optional pythonSupport "--enable-languages=python" # Tests will try to communicate with gpg-agent instance via a UNIX socket # which has a path length limit. Nix on darwin is using a build directory # that already has quite a long path and the resulting socket path doesn't diff --git a/pkgs/development/python-modules/gpgme/default.nix b/pkgs/development/python-modules/gpgme/default.nix new file mode 100644 index 000000000000..18604bf1d535 --- /dev/null +++ b/pkgs/development/python-modules/gpgme/default.nix @@ -0,0 +1,51 @@ +{ + buildPythonPackage, + gpgme, + lib, + setuptools, + swig, +}: + +buildPythonPackage { + pname = "gpgme"; + inherit (gpgme) version src; + pyproject = true; + + patches = gpgme.patches or [ ] ++ [ + ./python313-support.patch + ]; + + postPatch = '' + substituteInPlace lang/python/setup.py.in \ + --replace-fail "gpgme_h = '''" "gpgme_h = '${lib.getDev gpgme}/include/gpgme.h'" + ''; + + configureFlags = gpgme.configureFlags ++ [ + "--enable-languages=python" + ]; + + postConfigure = " + cd lang/python + "; + + preBuild = '' + make copystamp + ''; + + build-system = [ setuptools ]; + + nativeBuildInputs = [ + swig + ]; + + buildInputs = [ + gpgme + ]; + + pythonImportsCheck = [ "gpg" ]; + + meta = gpgme.meta // { + description = "Python bindings to the GPGME API of the GnuPG cryptography library"; + homepage = "https://dev.gnupg.org/source/gpgme/browse/master/lang/python/"; + }; +} diff --git a/pkgs/development/libraries/gpgme/python313-support.patch b/pkgs/development/python-modules/gpgme/python313-support.patch similarity index 100% rename from pkgs/development/libraries/gpgme/python313-support.patch rename to pkgs/development/python-modules/gpgme/python313-support.patch diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 594b9a9197e1..c2087fdd2234 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5421,10 +5421,9 @@ self: super: with self; { gplaycli = callPackage ../development/python-modules/gplaycli { }; - gpgme = toPythonModule (pkgs.gpgme.override { - pythonSupport = true; - python3 = python; - }); + gpgme = callPackage ../development/python-modules/gpgme { + inherit (pkgs) gpgme; + }; gphoto2 = callPackage ../development/python-modules/gphoto2 { };