1{ lib
2, stdenv
3, fetchFromGitHub
4, buildPythonPackage
5, pythonOlder
6 # Mitmproxy requirements
7, asgiref
8, blinker
9, brotli
10, certifi
11, click
12, cryptography
13, flask
14, h11
15, h2
16, hyperframe
17, kaitaistruct
18, ldap3
19, msgpack
20, passlib
21, protobuf
22, publicsuffix2
23, pyasn1
24, pyopenssl
25, pyparsing
26, pyperclip
27, ruamel-yaml
28, setuptools
29, sortedcontainers
30, tornado
31, urwid
32, wsproto
33, zstandard
34 # Additional check requirements
35, beautifulsoup4
36, glibcLocales
37, hypothesis
38, parver
39, pytest-asyncio
40, pytest-timeout
41, pytest-xdist
42, pytestCheckHook
43, requests
44}:
45
46buildPythonPackage rec {
47 pname = "mitmproxy";
48 version = "7.0.4";
49 disabled = pythonOlder "3.8";
50
51 src = fetchFromGitHub {
52 owner = pname;
53 repo = pname;
54 rev = "v${version}";
55 sha256 = "sha256-424WNG9Yj+Zfo1UTh7emknZ7xTtpFPz7Ph+FpE149FM=";
56 };
57
58 propagatedBuildInputs = [
59 setuptools
60 # setup.py
61 asgiref
62 blinker
63 brotli
64 certifi
65 click
66 cryptography
67 flask
68 h11
69 h2
70 hyperframe
71 kaitaistruct
72 ldap3
73 msgpack
74 passlib
75 protobuf
76 publicsuffix2
77 pyasn1
78 pyopenssl
79 pyparsing
80 pyperclip
81 ruamel-yaml
82 sortedcontainers
83 tornado
84 urwid
85 wsproto
86 zstandard
87 ];
88
89 checkInputs = [
90 beautifulsoup4
91 glibcLocales
92 hypothesis
93 parver
94 pytest-asyncio
95 pytest-timeout
96 pytest-xdist
97 pytestCheckHook
98 requests
99 ];
100
101 doCheck = !stdenv.isDarwin;
102
103 postPatch = ''
104 # remove dependency constraints
105 sed 's/>=\([0-9]\.\?\)\+\( \?, \?<\([0-9]\.\?\)\+\)\?\( \?, \?!=\([0-9]\.\?\)\+\)\?//' -i setup.py
106 '';
107
108 preCheck = ''
109 export HOME=$(mktemp -d)
110 '';
111
112 disabledTests = [
113 # Tests require a git repository
114 "test_get_version"
115 # https://github.com/mitmproxy/mitmproxy/commit/36ebf11916704b3cdaf4be840eaafa66a115ac03
116 # Tests require terminal
117 "test_integration"
118 ];
119
120 pythonImportsCheck = [ "mitmproxy" ];
121
122 meta = with lib; {
123 description = "Man-in-the-middle proxy";
124 homepage = "https://mitmproxy.org/";
125 license = licenses.mit;
126 maintainers = with maintainers; [ fpletz kamilchm ];
127 };
128}