1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, poetry-core
6, libsodium
7, pytestCheckHook
8}:
9
10buildPythonPackage rec {
11 pname = "libnacl";
12 version = "2.1.0";
13 pyproject = true;
14
15 src = fetchFromGitHub {
16 owner = "saltstack";
17 repo = pname;
18 rev = "v${version}";
19 hash = "sha256-phECLGDcBfDi/r2y0eGtqgIX/hvirtBqO8UUvEJ66zo=";
20 };
21
22 nativeBuildInputs = [ poetry-core ];
23
24 buildInputs = [ libsodium ];
25
26 postPatch =
27 let soext = stdenv.hostPlatform.extensions.sharedLibrary; in
28 ''
29 substituteInPlace "./libnacl/__init__.py" \
30 --replace \
31 "l_path = ctypes.util.find_library('sodium')" \
32 "l_path = None" \
33 --replace \
34 "ctypes.cdll.LoadLibrary('libsodium${soext}')" \
35 "ctypes.cdll.LoadLibrary('${libsodium}/lib/libsodium${soext}')"
36 '';
37
38 nativeCheckInputs = [ pytestCheckHook ];
39
40 pythonImportsCheck = [ "libnacl" ];
41
42 meta = with lib; {
43 description = "Python bindings for libsodium based on ctypes";
44 homepage = "https://libnacl.readthedocs.io/";
45 license = licenses.asl20;
46 platforms = platforms.unix;
47 maintainers = with maintainers; [ xvapx ];
48 };
49}