1{ lib
2, stdenv
3, bash
4, buildPythonPackage
5, fetchFromGitHub
6, fetchpatch
7, gnumake
8, httpx
9, openssl
10, paramiko
11, pytest-asyncio
12, pytest-mock
13, pytestCheckHook
14, pythonOlder
15, setuptools-scm
16, typing-extensions
17, wheel
18}:
19
20buildPythonPackage rec {
21 pname = "proxy-py";
22 version = "2.4.3";
23 format = "pyproject";
24
25 disabled = pythonOlder "3.7";
26
27 src = fetchFromGitHub {
28 owner = "abhinavsingh";
29 repo = "proxy.py";
30 rev = "refs/tags/v${version}";
31 hash = "sha256-dA7a9RicBFCSf6IoGX/CdvI8x/xMOFfNtyuvFn9YmHI=";
32 };
33
34 patches = [
35 # this patch is so that the one following it applies cleanly
36 # https://github.com/abhinavsingh/proxy.py/pull/1209
37 (fetchpatch {
38 name = "update-build-dependencies.patch";
39 url = "https://github.com/abhinavsingh/proxy.py/commit/2e535360ce5ed9734f2c00dc6aefe5ebd281cea5.patch";
40 hash = "sha256-eR3R4M7jwQMnY5ob0V6G71jXcrkV7YZvo1JOUG4gnrY=";
41 })
42 # https://github.com/abhinavsingh/proxy.py/pull/1345
43 (fetchpatch {
44 name = "remove-setuptools-scm-git-archive-dependency.patch";
45 url = "https://github.com/abhinavsingh/proxy.py/commit/027bfa6b912745f588d272f1a1082f6ca416f815.patch";
46 hash = "sha256-O2LlSrSrB3u2McAZRY+KviuU7Hv1tOuf0n+D/H4BWvI=";
47 })
48 ];
49
50 postPatch = ''
51 substituteInPlace Makefile \
52 --replace "SHELL := /bin/bash" "SHELL := ${bash}/bin/bash"
53 substituteInPlace pytest.ini \
54 --replace "-p pytest_cov" "" \
55 --replace "--no-cov-on-fail" ""
56 sed -i "/--cov/d" pytest.ini
57 '';
58
59 nativeBuildInputs = [
60 setuptools-scm
61 wheel
62 ];
63
64 propagatedBuildInputs = [
65 paramiko
66 typing-extensions
67 ];
68
69 nativeCheckInputs = [
70 httpx
71 openssl
72 gnumake
73 pytest-asyncio
74 pytest-mock
75 pytestCheckHook
76 ];
77
78 preCheck = ''
79 export HOME=$(mktemp -d);
80 '';
81
82 disabledTests = [
83 # Test requires network access
84 "test_http2_via_proxy"
85 # Tests run into a timeout
86 "integration"
87 ];
88
89 pythonImportsCheck = [
90 "proxy"
91 ];
92
93 meta = with lib; {
94 description = "Python proxy framework";
95 homepage = "https://github.com/abhinavsingh/proxy.py";
96 changelog = "https://github.com/abhinavsingh/proxy.py/releases/tag/v${version}";
97 license = with licenses; [ bsd3 ];
98 maintainers = with maintainers; [ fab ];
99 broken = (stdenv.isLinux && stdenv.isAarch64) || stdenv.isDarwin;
100 };
101}