Files
nixpkgs/pkgs/development/python-modules/mitmproxy/default.nix
T
Dmitry Ivankov 0dd2238ac7 mitmproxy: fix macos build
https://hydra.nixos.org/build/240114924/nixlog/1
```
error: linking with `/nix/store/sa6hywsm1mqfyd1xakyzv4ljjsb3hawh-clang-wrapper-11.1.0/bin/cc` failed: exit status: 1
  |
...
  = note: ld: library not found for -liconv
          clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
```

after adding libiconv it starts to fail with
```
  File "/nix/store/ncs3h7zqjl3cl2cwflka40rrirb6qg1m-python3.11-mitmproxy-rs-0.3.11/lib/python3.11/site-packages/mitmproxy_rs/__init__.py", line 1, in <module>
    from .mitmproxy_rs import *
ModuleNotFoundError: No module named 'mitmproxy_macos'
```
so it needs extra module
https://github.com/mitmproxy/mitmproxy_rs/tree/main/mitmproxy-macos

So the fixes are
- add `libiconv` dependency to mitmproxy-rs
- add `mitmproxy-macos` python package and add it to dependencies of
  `mitmproxy-rs` and `mitmproxy` itself (otherwise import fails,
  looks like the import is sneaky because it is platform-conditional)
2023-11-18 17:04:59 +01:00

138 lines
2.3 KiB
Nix

{ lib
, fetchFromGitHub
, buildPythonPackage
, pythonOlder
, stdenv
# Mitmproxy requirements
, aioquic
, asgiref
, blinker
, brotli
, certifi
, cryptography
, flask
, h11
, h2
, hyperframe
, kaitaistruct
, ldap3
, mitmproxy-macos
, mitmproxy-rs
, msgpack
, passlib
, protobuf
, publicsuffix2
, pyopenssl
, pyparsing
, pyperclip
, ruamel-yaml
, setuptools
, sortedcontainers
, tornado
, urwid
, wsproto
, zstandard
# Additional check requirements
, hypothesis
, parver
, pytest-asyncio
, pytest-timeout
, pytest-xdist
, pytestCheckHook
, requests
}:
buildPythonPackage rec {
pname = "mitmproxy";
version = "10.1.1";
disabled = pythonOlder "3.9";
pyproject = true;
src = fetchFromGitHub {
owner = "mitmproxy";
repo = "mitmproxy";
rev = "refs/tags/${version}";
hash = "sha256-/ouMj7UVowvzwjOuusgVfXjvjNPKpuJUuoJf6Sl9P44=";
};
propagatedBuildInputs = [
setuptools
aioquic
asgiref
blinker
brotli
certifi
cryptography
flask
h11
h2
hyperframe
kaitaistruct
ldap3
mitmproxy-rs
msgpack
passlib
protobuf
pyopenssl
publicsuffix2
pyparsing
pyperclip
ruamel-yaml
sortedcontainers
tornado
urwid
wsproto
zstandard
] ++ lib.optionals stdenv.isDarwin [
mitmproxy-macos
];
nativeCheckInputs = [
hypothesis
parver
pytest-asyncio
pytest-timeout
pytest-xdist
pytestCheckHook
requests
];
__darwinAllowLocalNetworking = true;
preCheck = ''
export HOME=$(mktemp -d)
'';
disabledTests = [
# Tests require a git repository
"test_get_version"
# https://github.com/mitmproxy/mitmproxy/commit/36ebf11916704b3cdaf4be840eaafa66a115ac03
# Tests require terminal
"test_integration"
"test_contentview_flowview"
"test_flowview"
# ValueError: Exceeds the limit (4300) for integer string conversion
"test_roundtrip_big_integer"
"test_wireguard"
"test_commands_exist"
"test_statusbar"
];
disabledTestPaths = [
# teardown of half the tests broken
"test/mitmproxy/addons/test_onboarding.py"
];
dontUsePytestXdist = true;
pythonImportsCheck = [ "mitmproxy" ];
meta = with lib; {
description = "Man-in-the-middle proxy";
homepage = "https://mitmproxy.org/";
license = licenses.mit;
maintainers = with maintainers; [ kamilchm SuperSandro2000 ];
};
}