1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 cryptography,
6 setuptools,
7 jinja2,
8 proton-core,
9 pynacl,
10 aiohttp,
11 pyopenssl,
12 pytest-asyncio,
13 requests,
14 sentry-sdk,
15 pyxdg,
16 distro,
17 pytestCheckHook,
18 pytest-cov-stub,
19}:
20
21buildPythonPackage rec {
22 pname = "proton-vpn-api-core";
23 version = "0.42.5";
24 pyproject = true;
25
26 src = fetchFromGitHub {
27 owner = "ProtonVPN";
28 repo = "python-proton-vpn-api-core";
29 rev = "v${version}";
30 hash = "sha256-sSLBo2nTn7rvtSZqCWZLwca5DRIgqSkImRM6U6/xJ70=";
31 };
32
33 build-system = [
34 setuptools
35 ];
36
37 dependencies = [
38 cryptography
39 distro
40 jinja2
41 pynacl
42 proton-core
43 sentry-sdk
44 pyxdg
45 ];
46
47 pythonImportsCheck = [
48 "proton.vpn.core"
49 "proton.vpn.connection"
50 "proton.vpn.killswitch.interface"
51 "proton.vpn.logging"
52 "proton.vpn.session"
53 ];
54
55 nativeCheckInputs = [
56 aiohttp
57 pyopenssl
58 pytest-asyncio
59 requests
60 pytestCheckHook
61 pytest-cov-stub
62 ];
63
64 # Needed for `pythonImportsCheck`, `preCheck` happens between `pythonImportsCheckPhase` and `pytestCheckPhase`.
65 postInstall = ''
66 # Needed for Permission denied: '/homeless-shelter'
67 export HOME=$(mktemp -d)
68 export XDG_RUNTIME_DIR=$(mktemp -d)
69 '';
70
71 disabledTests = [
72 # Permission denied: '/run'
73 "test_ensure_configuration_file_is_created"
74 "test_ovpnconfig_with_certificate"
75 "test_ovpnconfig_with_settings"
76 "test_wireguard_config_content_generation"
77 "test_wireguard_with_non_certificate"
78 "test_ensure_generate_is_returning_expected_content"
79 "test_ensure_same_configuration_file_in_case_of_duplicate"
80 "test_ensure_configuration_file_is_deleted"
81 ];
82
83 meta = {
84 description = "Acts as a facade to the other Proton VPN components, exposing a uniform API to the available Proton VPN services";
85 homepage = "https://github.com/ProtonVPN/python-proton-vpn-api-core";
86 license = lib.licenses.gpl3Only;
87 platforms = lib.platforms.linux;
88 maintainers = with lib.maintainers; [
89 sebtm
90 rapiteanu
91 ];
92 };
93}