Commit 251c0dbf authored by Robert Schütz's avatar Robert Schütz
Browse files

python3Packages.gpgme: 1.24.3 -> 2.0.0

parent 60ec65bb
Loading
Loading
Loading
Loading
+39 −19
Original line number Diff line number Diff line
{
  autoreconfHook,
  buildPythonPackage,
  fetchurl,
  gnupg,
  gpgme,
  lib,
  libgpg-error,
  setuptools,
  swig,
}:

buildPythonPackage {
buildPythonPackage rec {
  pname = "gpgme";
  inherit (gpgme) version src;
  version = "2.0.0";
  pyproject = true;

  patches = gpgme.patches or [ ];
  src = fetchurl {
    url = "mirror://gnupg/gpgmepy/gpgmepy-${version}.tar.bz2";
    hash = "sha256-B+EmVkj/UdojjJr3oYs/HcewxmtPIacvJ8dLOWzTM20=";
  };

  postPatch = ''
    substituteInPlace lang/python/setup.py.in \
      --replace-fail "gpgme_h = '''" "gpgme_h = '${lib.getDev gpgme}/include/gpgme.h'" \
      --replace-fail "@VERSION@" "${gpgme.version}"
  '';

  configureFlags = gpgme.configureFlags ++ [
    "--enable-languages=python"
  ];
    substituteInPlace pyproject.toml \
      --replace-fail ', "swig"' ""

  postConfigure = "
    cd lang/python
  ";

  preBuild = ''
    make copystamp
    # prevent `packaging.version.InvalidVersion: Invalid version: '2.0.0-unknown'`
    substituteInPlace autogen.sh \
      --replace-fail 'tmp="-unknown"' 'tmp=""'
  '';

  build-system = [ setuptools ];

  nativeBuildInputs = [
    autoreconfHook
    gpgme # for gpgme-config
    libgpg-error # for gpg-error-config
    swig
  ];

  preBuild = ''
    # prevent `error: package directory 'gpg' does not exist`
    mv src gpg
  '';

  buildInputs = [
    gpgme
    libgpg-error
  ];

  pythonImportsCheck = [ "gpg" ];

  meta = gpgme.meta // {
  nativeCheckInputs = [
    gnupg
  ];

  checkPhase = ''
    runHook preCheck

    make -C tests

    runHook postCheck
  '';

  meta = {
    changelog = "https://dev.gnupg.org/source/gpgmepy/browse/master/NEWS;gpgmepy-${version}?as=remarkup";
    description = "Python bindings to the GPGME API of the GnuPG cryptography library";
    homepage = "https://dev.gnupg.org/source/gpgme/browse/master/lang/python/";
    homepage = "https://dev.gnupg.org/source/gpgmepy/";
    license = lib.licenses.lgpl21Plus;
    maintainers = [ lib.maintainers.dotlambda ];
  };
}