1{ 2 lib, 3 fetchFromGitHub, 4 buildPythonPackage, 5 pythonOlder, 6 cython, 7 pytestCheckHook, 8 requests-toolbelt, 9}: 10 11buildPythonPackage rec { 12 pname = "streaming-form-data"; 13 version = "1.13.0"; 14 format = "setuptools"; 15 disabled = pythonOlder "3.6"; 16 17 src = fetchFromGitHub { 18 owner = "siddhantgoel"; 19 repo = "streaming-form-data"; 20 rev = "v${version}"; 21 hash = "sha256-Ntiad5GZtfRd+2uDPgbDzLBzErGFroffK6ZAmMcsfXA="; 22 }; 23 24 # streaming-form-data has a small bit of code that uses smart_open, which has a massive closure. 25 # The only consumer of streaming-form-data is Moonraker, which doesn't use that code. 26 # So, just drop the dependency to not have to deal with it. 27 patches = [ ./drop-smart-open.patch ]; 28 29 # The repo has a vendored copy of the cython output, which doesn't build on 3.13, 30 # so regenerate it with our cython, which does. 31 preBuild = '' 32 cython streaming_form_data/_parser.pyx 33 ''; 34 35 nativeBuildInputs = [ cython ]; 36 37 nativeCheckInputs = [ 38 pytestCheckHook 39 requests-toolbelt 40 ]; 41 42 enabledTestPaths = [ "tests" ]; 43 44 pythonImportsCheck = [ "streaming_form_data" ]; 45 46 preCheck = '' 47 # remove in-tree copy to make pytest find the installed one, with the native parts already built 48 rm -rf streaming_form_data 49 ''; 50 51 meta = with lib; { 52 description = "Streaming parser for multipart/form-data"; 53 homepage = "https://github.com/siddhantgoel/streaming-form-data"; 54 license = licenses.mit; 55 maintainers = with maintainers; [ zhaofengli ]; 56 }; 57}