1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchFromGitHub,
6 fetchpatch,
7 azure-common,
8 azure-core,
9 azure-storage-blob,
10 boto3,
11 google-cloud-storage,
12 requests,
13 moto,
14 paramiko,
15 pytestCheckHook,
16 responses,
17 setuptools,
18 wrapt,
19 zstandard,
20}:
21
22buildPythonPackage rec {
23 pname = "smart-open";
24 version = "7.0.4";
25 pyproject = true;
26
27 disabled = pythonOlder "3.7";
28
29 src = fetchFromGitHub {
30 owner = "RaRe-Technologies";
31 repo = "smart_open";
32 rev = "refs/tags/v${version}";
33 hash = "sha256-4HOTaF6AKXGlVCvSGKnnaH73aa4IO0aRxz03XQ4gSd8=";
34 };
35
36 patches = [
37 # https://github.com/RaRe-Technologies/smart_open/pull/822
38 # fix test_smart_open.py on python 3.12
39 (fetchpatch {
40 name = "fix-smart-open-test.patch";
41 url = "https://github.com/RaRe-Technologies/smart_open/commit/3d29564ca034a56d343c9d14b178aaa0ff4c937c.patch";
42 hash = "sha256-CrAeqaIMM8bctWiFnq9uamnIlkaslDyjaWL6k9wUjT8=";
43 })
44 ];
45
46 build-system = [ setuptools ];
47
48 dependencies = [ wrapt ];
49
50 optional-dependencies = {
51 s3 = [ boto3 ];
52 gcs = [ google-cloud-storage ];
53 azure = [
54 azure-storage-blob
55 azure-common
56 azure-core
57 ];
58 http = [ requests ];
59 webhdfs = [ requests ];
60 ssh = [ paramiko ];
61 zst = [ zstandard ];
62 };
63
64 pythonImportsCheck = [ "smart_open" ];
65
66 nativeCheckInputs = [
67 moto
68 pytestCheckHook
69 responses
70 ] ++ lib.flatten (builtins.attrValues optional-dependencies);
71
72 pytestFlagsArray = [ "smart_open" ];
73
74 disabledTests = [
75 # https://github.com/RaRe-Technologies/smart_open/issues/784
76 "test_https_seek_forward"
77 "test_seek_from_current"
78 "test_seek_from_end"
79 "test_seek_from_start"
80 ];
81
82 meta = with lib; {
83 changelog = "https://github.com/piskvorky/smart_open/releases/tag/v${version}";
84 description = "Library for efficient streaming of very large file";
85 homepage = "https://github.com/RaRe-Technologies/smart_open";
86 license = licenses.mit;
87 maintainers = with maintainers; [ jyp ];
88 };
89}