From 5308573c13f2cf45b4ee8ec6a09742ad2adcd8b8 Mon Sep 17 00:00:00 2001 From: K900 Date: Mon, 8 Jan 2024 18:56:29 +0300 Subject: [PATCH] python311Packages.streaming-form-data: excise smart_open dependency Causes massive closure bloat, does not do anything useful for the only consumer. --- .../streaming-form-data/default.nix | 13 ++++-- .../streaming-form-data/drop-smart-open.patch | 40 +++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/python-modules/streaming-form-data/drop-smart-open.patch diff --git a/pkgs/development/python-modules/streaming-form-data/default.nix b/pkgs/development/python-modules/streaming-form-data/default.nix index 8c631510ec43..18df3a778da2 100644 --- a/pkgs/development/python-modules/streaming-form-data/default.nix +++ b/pkgs/development/python-modules/streaming-form-data/default.nix @@ -1,5 +1,5 @@ { lib, fetchFromGitHub, buildPythonPackage, pythonOlder, -cython, smart-open, pytestCheckHook, moto, requests-toolbelt }: +cython, pytestCheckHook, requests-toolbelt }: buildPythonPackage rec { pname = "streaming-form-data"; @@ -14,11 +14,16 @@ buildPythonPackage rec { hash = "sha256-Ntiad5GZtfRd+2uDPgbDzLBzErGFroffK6ZAmMcsfXA="; }; + # streaming-form-data has a small bit of code that uses smart_open, which has a massive closure. + # The only consumer of streaming-form-data is Moonraker, which doesn't use that code. + # So, just drop the dependency to not have to deal with it. + patches = [ + ./drop-smart-open.patch + ]; + nativeBuildInputs = [ cython ]; - propagatedBuildInputs = [ smart-open ]; - - nativeCheckInputs = [ pytestCheckHook moto requests-toolbelt ]; + nativeCheckInputs = [ pytestCheckHook requests-toolbelt ]; pytestFlagsArray = [ "tests" ]; diff --git a/pkgs/development/python-modules/streaming-form-data/drop-smart-open.patch b/pkgs/development/python-modules/streaming-form-data/drop-smart-open.patch new file mode 100644 index 000000000000..6c0946c926ec --- /dev/null +++ b/pkgs/development/python-modules/streaming-form-data/drop-smart-open.patch @@ -0,0 +1,40 @@ +diff --git a/streaming_form_data/targets.py b/streaming_form_data/targets.py +index a399f3a..b816714 100644 +--- a/streaming_form_data/targets.py ++++ b/streaming_form_data/targets.py +@@ -1,6 +1,5 @@ + import hashlib + from pathlib import Path +-import smart_open # type: ignore + from typing import Callable, List, Optional + + +@@ -164,6 +163,7 @@ class S3Target(BaseTarget): + S3Target enables chunked uploads to S3 buckets (using smart_open)""" + + def __init__(self, file_path, mode, transport_params=None, **kwargs): ++ raise Exception("Nixpkgs: disabled") + super().__init__(**kwargs) + + self._file_path = file_path +diff --git a/tests/test_targets.py b/tests/test_targets.py +index 0cc79ab..78ab40b 100644 +--- a/tests/test_targets.py ++++ b/tests/test_targets.py +@@ -2,8 +2,6 @@ import os.path + import tempfile + + import pytest +-from moto import mock_s3 +-import boto3 + + from streaming_form_data.targets import ( + BaseTarget, +@@ -271,6 +269,7 @@ def mock_client(): + yield client + + ++@pytest.mark.skip + def test_s3_upload(mock_client): + test_key = "test.txt" + path = f"s3://{BUCKET_NAME}/{test_key}"