summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/gpgme/default.nix
blob: 1aa561bee7935ad38384a4116e319946aded5540 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
  autoreconfHook,
  buildPythonPackage,
  fetchurl,
  gnupg,
  gpgme,
  lib,
  libgpg-error,
  setuptools,
  swig,
}:

buildPythonPackage rec {
  pname = "gpgme";
  version = "2.0.0";
  pyproject = true;

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

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail ', "swig"' ""

    # 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" ];

  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/gpgmepy/";
    license = lib.licenses.lgpl21Plus;
    maintainers = [ lib.maintainers.dotlambda ];
  };
}