1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6 pytestCheckHook,
7
8 # build-system
9 setuptools,
10 setuptools-scm,
11
12 # dependencies
13 urllib3,
14 requests,
15 requests-toolbelt,
16 pyjwt,
17 importlib-metadata,
18 packaging,
19
20 # tests
21 arangodb,
22 mock,
23}:
24
25let
26 testDBOpts = {
27 host = "127.0.0.1";
28 port = "8529";
29 password = "test";
30 secret = "secret";
31 };
32in
33
34buildPythonPackage rec {
35 pname = "python-arango";
36 version = "8.2.1";
37 format = "pyproject";
38
39 disabled = pythonOlder "3.9";
40
41 src = fetchFromGitHub {
42 owner = "arangodb";
43 repo = "python-arango";
44 tag = version;
45 hash = "sha256-ZLjCcH6cSG+LcoeSifBm6HGjnRFJwYNTXbcw9b/BeQY=";
46 };
47
48 nativeBuildInputs = [
49 setuptools
50 setuptools-scm
51 ];
52
53 propagatedBuildInputs = [
54 importlib-metadata
55 requests
56 requests-toolbelt
57 packaging
58 pyjwt
59 setuptools
60 urllib3
61 ];
62
63 nativeCheckInputs = [
64 arangodb
65 mock
66 pytestCheckHook
67 ];
68
69 # arangodb is compiled only for particular target architectures
70 # (i.e. "haswell"). Thus, these tests may not pass reproducibly,
71 # failing with: `166: Illegal instruction` if not run on arangodb's
72 # specified architecture.
73 #
74 # nonetheless, the client library should remain in nixpkgs - since
75 # the client library will talk to arangodb across the network and
76 # architecture issues will be irrelevant.
77 doCheck = false;
78
79 preCheck = lib.optionalString doCheck ''
80 # Start test DB
81 mkdir -p .nix-test/{data,work}
82
83 ICU_DATA=${arangodb}/share/arangodb3 \
84 GLIBCXX_FORCE_NEW=1 \
85 TZ=UTC \
86 TZ_DATA=${arangodb}/share/arangodb3/tzdata \
87 ARANGO_ROOT_PASSWORD=${testDBOpts.password} \
88 ${arangodb}/bin/arangod \
89 --server.uid=$(id -u) \
90 --server.gid=$(id -g) \
91 --server.authentication=true \
92 --server.endpoint=http+tcp://${testDBOpts.host}:${testDBOpts.port} \
93 --server.descriptors-minimum=4096 \
94 --server.jwt-secret=${testDBOpts.secret} \
95 --javascript.app-path=.nix-test/app \
96 --log.file=.nix-test/log \
97 --database.directory=.nix-test/data \
98 --foxx.api=false &
99 '';
100
101 pytestFlags = [
102 "--host=${testDBOpts.host}"
103 "--port=${testDBOpts.port}"
104 "--passwd=${testDBOpts.password}"
105 "--secret=${testDBOpts.secret}"
106 ];
107
108 disabledTests = [
109 # AssertionError geo-related - try enabling later
110 "test_document_find_in_box"
111
112 # maybe arangod misconfig - try enabling later
113 # arango.exceptions.JWTAuthError: [HTTP 401][ERR 401] Wrong credentials
114 "test_auth_jwt"
115
116 # ValueError - try enabling later
117 # maybe missed 3.9.3->3.10.0 changes
118 # most caused by key change: isNewlyCreated->new
119 "test_add_hash_index"
120 "test_add_skiplist_index"
121 "test_add_persistent_index"
122 "test_add_ttl_index"
123 "test_delete_index"
124 "test_pregel_management"
125
126 # formatting error - try enabling later
127 # maybe missed 3.9.3->3.10.0 changes
128 # caused by: body["computedValues"] = None
129 "test_permission_management"
130 "test_collection_misc_methods"
131 "test_collection_management"
132 "test_replication_inventory"
133
134 # want outgoing network to update foxx apis
135 # so foxx.api disabled in arangod startup
136 "test_foxx_service_management_file"
137 "test_foxx_service_management_json"
138 "test_foxx_config_management"
139 "test_foxx_dependency_management"
140 "test_foxx_development_toggle"
141 "test_foxx_misc_functions"
142
143 # no replication configured via arangod invocation
144 "test_replication_applier"
145 ];
146
147 pythonImportsCheck = [ "arango" ];
148
149 meta = with lib; {
150 description = "Python Driver for ArangoDB";
151 homepage = "https://github.com/ArangoDB-Community/python-arango";
152 changelog = "https://github.com/ArangoDB-Community/python-arango/releases/tag/${src.tag}";
153 license = licenses.mit;
154 maintainers = with maintainers; [ jsoo1 ];
155 };
156}