nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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.7.0";
23 pyproject = true;
24
25 src = fetchFromGitHub {
26 owner = "jaraco";
27 repo = "keyring";
28 tag = "v${version}";
29 hash = "sha256-v9s28vwx/5DJRa3dQyS/mdZppfvFcfBtafjBRi2c1oQ=";
30 };
31
32 postPatch = ''
33 substituteInPlace pyproject.toml \
34 --replace-fail '"coherent.licensed",' ""
35 '';
36
37 build-system = [ setuptools-scm ];
38
39 nativeBuildInputs = [
40 installShellFiles
41 shtab
42 ];
43
44 dependencies = [
45 jaraco-classes
46 jaraco-context
47 jaraco-functools
48 ]
49 ++ lib.optionals stdenv.hostPlatform.isLinux [
50 jeepney
51 secretstorage
52 ]
53 ++ lib.optionals (pythonOlder "3.12") [ importlib-metadata ];
54
55 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
56 installShellCompletion --cmd keyring \
57 --bash <($out/bin/keyring --print-completion bash) \
58 --zsh <($out/bin/keyring --print-completion zsh)
59 '';
60
61 pythonImportsCheck = [
62 "keyring"
63 "keyring.backend"
64 ];
65
66 nativeCheckInputs = [
67 pyfakefs
68 pytestCheckHook
69 ];
70
71 disabledTestPaths = [
72 "tests/backends/test_macOS.py"
73 ]
74 # These tests fail when sandboxing is enabled because they are unable to get a password from keychain.
75 ++ lib.optional stdenv.hostPlatform.isDarwin "tests/test_multiprocess.py";
76
77 meta = {
78 description = "Store and access your passwords safely";
79 homepage = "https://github.com/jaraco/keyring";
80 changelog = "https://github.com/jaraco/keyring/blob/${src.tag}/NEWS.rst";
81 license = lib.licenses.mit;
82 mainProgram = "keyring";
83 maintainers = with lib.maintainers; [
84 lovek323
85 dotlambda
86 ];
87 platforms = lib.platforms.unix;
88 };
89}