1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fetchpatch,
6 setuptools,
7 dissononce,
8 python-axolotl-curve25519,
9 transitions,
10 protobuf,
11 pytestCheckHook,
12 pythonOlder,
13}:
14
15buildPythonPackage rec {
16 pname = "consonance";
17 version = "0.1.5";
18 pyproject = true;
19
20 disabled = pythonOlder "3.7";
21
22 src = fetchFromGitHub {
23 owner = "tgalal";
24 repo = "consonance";
25 tag = version;
26 hash = "sha256-BhgxLxjKZ4dSL7DqkaoS+wBPCd1SYZomRKrtDLdGmYQ=";
27 };
28
29 patches = [
30 # https://github.com/tgalal/consonance/pull/9
31 (fetchpatch {
32 name = "fix-type-error.patch";
33 url = "https://github.com/tgalal/consonance/pull/9/commits/92fb78af98a18f0533ec8a286136968174fb0baf.patch";
34 hash = "sha256-wVUGxZ4W2zPyrcQPQTc85LcRUtsLbTBVzS10NEolpQY=";
35 })
36 ];
37
38 env = {
39 # make protobuf compatible with old versions
40 # https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
41 PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION = "python";
42 };
43
44 build-system = [ setuptools ];
45
46 dependencies = [
47 dissononce
48 python-axolotl-curve25519
49 transitions
50 protobuf
51 ];
52
53 nativeCheckInputs = [ pytestCheckHook ];
54
55 enabledTestPaths = [ "tests/test_handshakes_offline.py" ];
56
57 pythonImportsCheck = [ "consonance" ];
58
59 meta = {
60 description = "WhatsApp's handshake implementation using Noise Protocol";
61 homepage = "https://github.com/tgalal/consonance";
62 license = lib.licenses.gpl3Plus;
63 maintainers = [ ];
64 };
65}