1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fetchurl,
6 setuptools,
7 cryptography,
8 mock,
9 python,
10}:
11
12buildPythonPackage rec {
13 pname = "stem";
14 version = "1.8.3";
15 pyproject = true;
16
17 src = fetchFromGitHub {
18 owner = "torproject";
19 repo = "stem";
20 tag = version;
21 hash = "sha256-FK7ldpOGEQ+VYLgwL7rGSGNtD/2iz11b0YOa78zNGDk=";
22 };
23
24 patches = [
25 (fetchurl {
26 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/python-stem/-/raw/729ce635a4dbf519bab0cd4195d507b0b9bf6c9a/fix-build-cryptography.patch";
27 hash = "sha256-RTh3RVpDaNRFrSoAEfMVAO1VPWmnhdd5W+M0N9AEr24=";
28 })
29 (fetchurl {
30 name = "cryptography-42-compat.patch";
31 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/python-stem/-/raw/main/9f1fa4ac.patch";
32 hash = "sha256-2pj5eeurGN9HC02U2gZibt8gNWHYU92tlETZlbaT35A=";
33 })
34 ];
35
36 postPatch = ''
37 # https://github.com/torproject/stem/pull/155
38 substituteInPlace stem/util/test_tools.py test/integ/*/*.py test/unit/*/*.py test/unit/version.py \
39 --replace-quiet assertRaisesRegexp assertRaisesRegex
40 '';
41
42 build-system = [ setuptools ];
43
44 nativeCheckInputs = [
45 cryptography
46 mock
47 ];
48
49 checkPhase = ''
50 runHook preCheck
51
52 ${python.interpreter} run_tests.py --unit
53
54 runHook postCheck
55 '';
56
57 meta = {
58 changelog = "https://github.com/torproject/stem/blob/${src.tag}/docs/change_log.rst";
59 description = "Controller library that allows applications to interact with Tor";
60 mainProgram = "tor-prompt";
61 downloadPage = "https://github.com/torproject/stem";
62 homepage = "https://stem.torproject.org/";
63 license = lib.licenses.lgpl3Only;
64 maintainers = with lib.maintainers; [ dotlambda ];
65 };
66}