summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pysodium/default.nix
blob: 6d0213e8348192161ebf4bed4c0571a0f4b7dcdd (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
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  setuptools,
  libsodium,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "pysodium";
  version = "0.7.18";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "stef";
    repo = "pysodium";
    tag = "v${version}";
    hash = "sha256-F2215AAI8UIvn6UbaJ/YxI4ZolCzlwY6nS5IafTs+i4=";
  };

  postPatch =
    let
      soext = stdenv.hostPlatform.extensions.sharedLibrary;
    in
    ''
      substituteInPlace ./pysodium/__init__.py --replace-fail \
        "ctypes.util.find_library('sodium') or ctypes.util.find_library('libsodium')" "'${libsodium}/lib/libsodium${soext}'"
    '';

  build-system = [ setuptools ];

  buildInputs = [ libsodium ];

  nativeCheckInputs = [ pytestCheckHook ];

  pythonImportsCheck = [ "pysodium" ];

  meta = {
    description = "Wrapper for libsodium providing high level crypto primitives";
    homepage = "https://github.com/stef/pysodium";
    changelog = "https://github.com/stef/pysodium/releases/tag/v${version}";
    maintainers = [ lib.maintainers.ethancedwards8 ];
    license = lib.licenses.bsd2;
  };
}