1{
2 lib,
3 stdenv,
4 aiofiles,
5 aiosqlite,
6 buildPythonPackage,
7 cryptography,
8 fetchFromGitHub,
9 hatchling,
10 pyopenssl,
11 pytest-asyncio_0_21,
12 pytest-mock,
13 pytestCheckHook,
14 python-dateutil,
15 pythonAtLeast,
16 pythonOlder,
17 pytz,
18 sortedcontainers,
19 typing-extensions,
20}:
21
22buildPythonPackage rec {
23 pname = "asyncua";
24 version = "1.1.8";
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-0eay/NlWn0I2oF0fTln9/d4y31zGfAj9ph3bWkgd8Nk=";
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 = [ hatchling ];
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 # Failed: DID NOT RAISE <class 'asyncio.exceptions.TimeoutError'>
67 "test_publish"
68 ]
69 ++ lib.optionals (pythonAtLeast "3.13") [
70 # dbm.sqlite3.error: SQLite objects created in a thread can only be used in that same thread.
71 # The object was created in thread id 140737220687552 and this is thread id 140737343690560.
72 "test_runTest"
73 ]
74 ++ lib.optionals stdenv.hostPlatform.isDarwin [
75 # OSError: [Errno 48] error while attempting to bind on address ('127.0.0.1',...
76 "test_anonymous_rejection"
77 "test_certificate_handling_success"
78 "test_encrypted_private_key_handling_success"
79 "test_encrypted_private_key_handling_success_with_cert_props"
80 "test_encrypted_private_key_handling_failure"
81 ];
82
83 meta = with lib; {
84 description = "OPC UA / IEC 62541 Client and Server for Python";
85 homepage = "https://github.com/FreeOpcUa/opcua-asyncio";
86 changelog = "https://github.com/FreeOpcUa/opcua-asyncio/releases/tag/${src.tag}";
87 license = licenses.lgpl3Plus;
88 maintainers = with maintainers; [ harvidsen ];
89 };
90}