Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,559 changes: 981 additions & 578 deletions pkgs/development/python-modules/mitmproxy-rs/Cargo.lock

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions pkgs/development/python-modules/mitmproxy-rs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,28 @@
rustPlatform,
darwin,
libiconv,
mitmproxy,
mitmproxy-macos,
}:

buildPythonPackage rec {
pname = "mitmproxy-rs";
version = "0.5.1";
version = "0.6.2";
pyproject = true;

src = fetchFromGitHub {
owner = "mitmproxy";
repo = "mitmproxy_rs";
rev = version;
hash = "sha256-nrm1T2yaGVmYsubwNJHPnPDC/A/jYiKVzwBKmuc9MD4=";
hash = "sha256-zBlt83mtJOsVqskDAkpk50yZHxJO6B8QP7iv8L1YPWA=";
};

cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; };
cargoDeps = rustPlatform.importCargoLock {
outputHashes = {
"smoltcp-0.11.0" = "sha256-KC9nTKd2gfZ1ICjrkLK//M2bbqYlfcCK18gBdN0RqWQ=";
};
lockFile = ./Cargo.lock;
};

buildAndTestSubdir = "mitmproxy-rs";

Expand All @@ -43,6 +49,6 @@ buildPythonPackage rec {
homepage = "https://github.com/mitmproxy/mitmproxy_rs";
changelog = "https://github.com/mitmproxy/mitmproxy_rs/blob/${src.rev}/CHANGELOG.md";
license = licenses.mit;
maintainers = with maintainers; [ fab ];
inherit (mitmproxy.meta) maintainers;
};
}
34 changes: 24 additions & 10 deletions pkgs/development/python-modules/mitmproxy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
mitmproxy-rs,
msgpack,
passlib,
protobuf,
protobuf5,
publicsuffix2,
pyopenssl,
pyparsing,
Expand All @@ -30,7 +30,7 @@
setuptools,
sortedcontainers,
tornado,
urwid-mitmproxy,
urwid,
wsproto,
zstandard,
# Additional check requirements
Expand All @@ -45,7 +45,7 @@

buildPythonPackage rec {
pname = "mitmproxy";
version = "10.3.1";
version = "10.4.0";
pyproject = true;

disabled = pythonOlder "3.9";
Expand All @@ -54,15 +54,12 @@ buildPythonPackage rec {
owner = "mitmproxy";
repo = "mitmproxy";
rev = "refs/tags/v${version}";
hash = "sha256-rIyRY1FolbdoaI4OgFG7D2/mot8NiRHalgittPzledw=";
hash = "sha256-W+m7PVphj4sP5+Um7dtPbdnaZ+edZn/fcE4XJGX1E6M=";
};


pythonRelaxDeps = [
"aioquic"
"cryptography"
"pyperclip"
"tornado"
"urwid"
];

propagatedBuildInputs = [
Expand All @@ -81,7 +78,7 @@ buildPythonPackage rec {
mitmproxy-rs
msgpack
passlib
protobuf
protobuf5
publicsuffix2
pyopenssl
pyparsing
Expand All @@ -90,7 +87,7 @@ buildPythonPackage rec {
setuptools
sortedcontainers
tornado
urwid-mitmproxy
urwid
wsproto
zstandard
] ++ lib.optionals stdenv.isDarwin [ mitmproxy-macos ];
Expand Down Expand Up @@ -126,6 +123,23 @@ buildPythonPackage rec {
# FileNotFoundError: [Errno 2] No such file or directory
# likely wireguard is also not working in the sandbox
"test_wireguard"
# test require a DNS server
# RuntimeError: failed to get dns servers: io error: entity not found
"test_errorcheck"
"test_errorcheck"
"test_dns"
"test_order"
];

disabledTestPaths = [
# test require a DNS server
# RuntimeError: failed to get dns servers: io error: entity not found
"test/mitmproxy/addons/test_dns_resolver.py"
"test/mitmproxy/tools/test_dump.py"
"test/mitmproxy/tools/test_main.py"
"test/mitmproxy/tools/web/test_app.py"
"test/mitmproxy/tools/web/test_app.py" # 2 out of 31 tests work
"test/mitmproxy/tools/web/test_master.py"
];

dontUsePytestXdist = true;
Expand Down
131 changes: 131 additions & 0 deletions pkgs/development/python-modules/protobuf/4.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
buildPackages,
buildPythonPackage,
fetchpatch,
isPyPy,
lib,
numpy,
protobuf,
pytestCheckHook,
pythonAtLeast,
substituteAll,
tzdata,
}:

assert lib.versionOlder protobuf.version "21" -> throw "Protobuf 21 or newer required";

let
protobufVersionMajor = lib.versions.major protobuf.version;
protobufVersionMinor = lib.versions.minor protobuf.version;
in
buildPythonPackage {
inherit (protobuf) pname src;

# protobuf 21 corresponds with its python library 4.21
version = "4.${protobufVersionMajor}.${protobufVersionMinor}";
format = "setuptools";

sourceRoot = "${protobuf.src.name}/python";

patches =
lib.optionals (lib.versionAtLeast protobuf.version "22") [
# Replace the vendored abseil-cpp with nixpkgs'
(substituteAll {
src = ./use-nixpkgs-abseil-cpp.patch;
abseil_cpp_include_path = "${lib.getDev protobuf.abseil-cpp}/include";
})
]
++ lib.optionals (pythonAtLeast "3.11" && lib.versionOlder protobuf.version "22") [
(fetchpatch {
name = "support-python311.patch";
url = "https://github.com/protocolbuffers/protobuf/commit/2206b63c4649cf2e8a06b66c9191c8ef862ca519.diff";
stripLen = 1; # because sourceRoot above
hash = "sha256-3GaoEyZIhS3QONq8LEvJCH5TdO9PKnOgcQF0GlEiwFo=";
})
];

prePatch = ''
if [[ "$(<../version.json)" != *'"python": "'"$version"'"'* ]]; then
echo "Python library version mismatch. Derivation version: $version, actual: $(<../version.json)"
exit 1
fi
'';

# Remove the line in setup.py that forces compiling with C++14. Upstream's
# CMake build has been updated to support compiling with other versions of
# C++, but the Python build has not. Without this, we observe compile-time
# errors using GCC.
#
# Fedora appears to do the same, per this comment:
#
# https://github.com/protocolbuffers/protobuf/issues/12104#issuecomment-1542543967
#
postPatch = ''
sed -i "/extra_compile_args.append('-std=c++14')/d" setup.py

# The former function has been renamed into the latter in Python 3.12.
# Does not apply to all protobuf versions, hence --replace-warn.
substituteInPlace google/protobuf/internal/json_format_test.py \
--replace-warn assertRaisesRegexp assertRaisesRegex
'';

nativeBuildInputs = lib.optional isPyPy tzdata;

buildInputs = [ protobuf ];

propagatedNativeBuildInputs = [
# For protoc of the same version.
buildPackages."protobuf_${protobufVersionMajor}"
];

setupPyGlobalFlags = [ "--cpp_implementation" ];

nativeCheckInputs = [
pytestCheckHook
] ++ lib.optionals (lib.versionAtLeast protobuf.version "22") [ numpy ];

disabledTests = lib.optionals isPyPy [
# error message differs
"testInvalidTimestamp"
# requires tracemalloc which pypy does not implement
# https://foss.heptapod.net/pypy/pypy/-/issues/3048
"testUnknownFieldsNoMemoryLeak"
# assertion is not raised for some reason
"testStrictUtf8Check"
];

disabledTestPaths =
lib.optionals (lib.versionAtLeast protobuf.version "23") [
# The following commit (I think) added some internal test logic for Google
# that broke generator_test.py. There is a new proto file that setup.py is
# not generating into a .py file. However, adding this breaks a bunch of
# conflict detection in descriptor_test.py that I don't understand. So let's
# just disable generator_test.py for now.
#
# https://github.com/protocolbuffers/protobuf/commit/5abab0f47e81ac085f0b2d17ec3b3a3b252a11f1
#
"google/protobuf/internal/generator_test.py"
]
++ lib.optionals (lib.versionAtLeast protobuf.version "25") [
"minimal_test.py" # ModuleNotFoundError: No module named 'google3'
];

pythonImportsCheck = [
"google.protobuf"
"google.protobuf.internal._api_implementation" # Verify that --cpp_implementation worked
];

passthru = {
inherit protobuf;
};

meta = with lib; {
description = "Protocol Buffers are Google's data interchange format";
homepage = "https://developers.google.com/protocol-buffers/";
license = licenses.bsd3;
maintainers = with maintainers; [ knedlsepp ];
# Tests are currently failing because backend is unavailable and causes tests to fail
# Progress tracked in https://github.com/NixOS/nixpkgs/pull/264902
broken = lib.versionAtLeast protobuf.version "26";
};
}
Loading