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 jaraco-classes
42 jaraco-context
43 jaraco-functools
44 ]
45 ++ lib.optionals stdenv.hostPlatform.isLinux [
46 jeepney
47 secretstorage
48 ]
49 ++ lib.optionals (pythonOlder "3.12") [ importlib-metadata ];
50
51 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
52 installShellCompletion --cmd keyring \
53 --bash <($out/bin/keyring --print-completion bash) \
54 --zsh <($out/bin/keyring --print-completion zsh)
55 '';
56
57 pythonImportsCheck = [
58 "keyring"
59 "keyring.backend"
60 ];
61
62 nativeCheckInputs = [
63 pyfakefs
64 pytestCheckHook
65 ];
66
67 disabledTestPaths = [
68 "tests/backends/test_macOS.py"
69 ]
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}