1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 pythonOlder,
7 installShellFiles,
8 setuptools-scm,
9 shtab,
10 importlib-metadata,
11 jaraco-classes,
12 jaraco-context,
13 jaraco-functools,
14 jeepney,
15 secretstorage,
16 pyfakefs,
17 pytestCheckHook,
18}:
19
20buildPythonPackage rec {
21 pname = "keyring";
22 version = "25.6.0";
23 pyproject = true;
24 disabled = pythonOlder "3.8";
25
26 src = fetchFromGitHub {
27 owner = "jaraco";
28 repo = "keyring";
29 tag = "v${version}";
30 hash = "sha256-qu9HAlZMLlIVs8c9ClzWUljezhrt88gu1kouklMNxMY=";
31 };
32
33 build-system = [ setuptools-scm ];
34
35 nativeBuildInputs = [
36 installShellFiles
37 shtab
38 ];
39
40 dependencies =
41 [
42 jaraco-classes
43 jaraco-context
44 jaraco-functools
45 ]
46 ++ lib.optionals stdenv.hostPlatform.isLinux [
47 jeepney
48 secretstorage
49 ]
50 ++ lib.optionals (pythonOlder "3.12") [ importlib-metadata ];
51
52 postInstall = ''
53 installShellCompletion --cmd keyring \
54 --bash <($out/bin/keyring --print-completion bash) \
55 --zsh <($out/bin/keyring --print-completion zsh)
56 '';
57
58 pythonImportsCheck = [
59 "keyring"
60 "keyring.backend"
61 ];
62
63 nativeCheckInputs = [
64 pyfakefs
65 pytestCheckHook
66 ];
67
68 disabledTestPaths =
69 [ "tests/backends/test_macOS.py" ]
70 # These tests fail when sandboxing is enabled because they are unable to get a password from keychain.
71 ++ lib.optional stdenv.hostPlatform.isDarwin "tests/test_multiprocess.py";
72
73 meta = with lib; {
74 description = "Store and access your passwords safely";
75 homepage = "https://github.com/jaraco/keyring";
76 changelog = "https://github.com/jaraco/keyring/blob/${src.tag}/NEWS.rst";
77 license = licenses.mit;
78 mainProgram = "keyring";
79 maintainers = with maintainers; [
80 lovek323
81 dotlambda
82 ];
83 platforms = platforms.unix;
84 };
85}