2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
|
|
|
poetry-core,
|
|
|
|
libsodium,
|
|
|
|
pytestCheckHook,
|
2021-02-17 17:02:09 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "libnacl";
|
2023-10-19 13:55:26 +00:00
|
|
|
version = "2.1.0";
|
|
|
|
pyproject = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "saltstack";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2023-10-19 13:55:26 +00:00
|
|
|
hash = "sha256-phECLGDcBfDi/r2y0eGtqgIX/hvirtBqO8UUvEJ66zo=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
nativeBuildInputs = [ poetry-core ];
|
2022-01-03 16:56:52 +00:00
|
|
|
|
2021-02-17 17:02:09 +00:00
|
|
|
buildInputs = [ libsodium ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postPatch =
|
2024-06-05 15:53:02 +00:00
|
|
|
let
|
|
|
|
soext = stdenv.hostPlatform.extensions.sharedLibrary;
|
|
|
|
in
|
2021-02-17 17:02:09 +00:00
|
|
|
''
|
2023-10-19 13:55:26 +00:00
|
|
|
substituteInPlace "./libnacl/__init__.py" \
|
|
|
|
--replace \
|
|
|
|
"l_path = ctypes.util.find_library('sodium')" \
|
|
|
|
"l_path = None" \
|
|
|
|
--replace \
|
|
|
|
"ctypes.cdll.LoadLibrary('libsodium${soext}')" \
|
|
|
|
"ctypes.cdll.LoadLibrary('${libsodium}/lib/libsodium${soext}')"
|
2021-02-17 17:02:09 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ pytestCheckHook ];
|
2021-02-17 17:02:09 +00:00
|
|
|
|
|
|
|
pythonImportsCheck = [ "libnacl" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Python bindings for libsodium based on ctypes";
|
2021-02-17 17:02:09 +00:00
|
|
|
homepage = "https://libnacl.readthedocs.io/";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
platforms = platforms.unix;
|
2021-02-17 17:02:09 +00:00
|
|
|
maintainers = with maintainers; [ xvapx ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|