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