1{
2 lib,
3 stdenv,
4 aiofiles,
5 aiosqlite,
6 buildPythonPackage,
7 cryptography,
8 fetchFromGitHub,
9 pyopenssl,
10 pytest-asyncio_0_21,
11 pytest-mock,
12 pytestCheckHook,
13 python-dateutil,
14 pythonAtLeast,
15 pythonOlder,
16 pytz,
17 setuptools,
18 sortedcontainers,
19 typing-extensions,
20}:
21
22buildPythonPackage rec {
23 pname = "asyncua";
24 version = "1.1.5";
25 pyproject = true;
26
27 disabled = pythonOlder "3.8";
28
29 src = fetchFromGitHub {
30 owner = "FreeOpcUa";
31 repo = "opcua-asyncio";
32 tag = "v${version}";
33 hash = "sha256-XXjzYDOEBdA4uk0VCzscHrPCY2Lgin0JBAVDdxmSOio=";
34 fetchSubmodules = true;
35 };
36
37 postPatch = ''
38 # Workaround hardcoded paths in test
39 # "test_cli_tools_which_require_sigint"
40 substituteInPlace tests/test_tools.py \
41 --replace-fail "tools/" "$out/bin/"
42 '';
43
44 build-system = [ setuptools ];
45
46 dependencies = [
47 aiofiles
48 aiosqlite
49 cryptography
50 pyopenssl
51 python-dateutil
52 pytz
53 sortedcontainers
54 typing-extensions
55 ];
56
57 nativeCheckInputs = [
58 pytestCheckHook
59 pytest-asyncio_0_21
60 pytest-mock
61 ];
62
63 pythonImportsCheck = [ "asyncua" ];
64
65 disabledTests =
66 [
67 # Failed: DID NOT RAISE <class 'asyncio.exceptions.TimeoutError'>
68 "test_publish"
69 ]
70 ++ lib.optionals (pythonAtLeast "3.13") [
71 # dbm.sqlite3.error: SQLite objects created in a thread can only be used in that same thread.
72 # The object was created in thread id 140737220687552 and this is thread id 140737343690560.
73 "test_runTest"
74 ]
75 ++ lib.optionals stdenv.hostPlatform.isDarwin [
76 # OSError: [Errno 48] error while attempting to bind on address ('127.0.0.1',...
77 "test_anonymous_rejection"
78 "test_certificate_handling_success"
79 "test_encrypted_private_key_handling_success"
80 "test_encrypted_private_key_handling_success_with_cert_props"
81 "test_encrypted_private_key_handling_failure"
82 ];
83
84 meta = with lib; {
85 description = "OPC UA / IEC 62541 Client and Server for Python";
86 homepage = "https://github.com/FreeOpcUa/opcua-asyncio";
87 changelog = "https://github.com/FreeOpcUa/opcua-asyncio/releases/tag/v${version}";
88 license = licenses.lgpl3Plus;
89 maintainers = with maintainers; [ harvidsen ];
90 };
91}