1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 ansicolors,
12 click,
13 entrypoints,
14 nbclient,
15 nbformat,
16 pyyaml,
17 requests,
18 tenacity,
19 tqdm,
20 pythonAtLeast,
21 aiohttp,
22
23 # optional-dependencies
24 azure-datalake-store,
25 azure-identity,
26 azure-storage-blob,
27 gcsfs,
28 pygithub,
29 pyarrow,
30 boto3,
31
32 # tests
33 ipykernel,
34 moto,
35 pytest-mock,
36 pytestCheckHook,
37 versionCheckHook,
38 writableTmpDirAsHomeHook,
39}:
40
41buildPythonPackage rec {
42 pname = "papermill";
43 version = "2.6.0";
44 pyproject = true;
45
46 src = fetchFromGitHub {
47 owner = "nteract";
48 repo = "papermill";
49 tag = version;
50 hash = "sha256-NxC5+hRDdMCl/7ZIho5ml4hdENrgO+wzi87GRPeMv8Q=";
51 };
52
53 build-system = [ setuptools ];
54
55 dependencies = [
56 ansicolors
57 click
58 entrypoints
59 nbclient
60 nbformat
61 pyyaml
62 requests
63 tenacity
64 tqdm
65 ] ++ lib.optionals (pythonAtLeast "3.12") [ aiohttp ];
66
67 optional-dependencies = {
68 azure = [
69 azure-datalake-store
70 azure-identity
71 azure-storage-blob
72 ];
73 gcs = [ gcsfs ];
74 github = [ pygithub ];
75 hdfs = [ pyarrow ];
76 s3 = [ boto3 ];
77 };
78
79 nativeCheckInputs =
80 [
81 ipykernel
82 moto
83 pytest-mock
84 pytestCheckHook
85 versionCheckHook
86 writableTmpDirAsHomeHook
87 ]
88 ++ optional-dependencies.azure
89 ++ optional-dependencies.s3
90 ++ optional-dependencies.gcs;
91 versionCheckProgramArg = "--version";
92
93 pythonImportsCheck = [ "papermill" ];
94
95 # Using pytestFlagsArray to prevent disabling false positives
96 pytestFlagsArray = [
97 # AssertionError: 'error' != 'display_data'
98 "--deselect=papermill/tests/test_execute.py::TestBrokenNotebook2::test"
99
100 # AssertionError: '\x1b[31mSystemExit\x1b[39m\x1b[31m:\x1b[39m 1\n' != '\x1b[0;31mSystemExit\x1b[0m\x1b[0;31m:\x1b[0m 1\n'
101 "--deselect=papermill/tests/test_execute.py::TestOutputFormatting::test_output_formatting"
102 ];
103
104 disabledTests =
105 [
106 # pytest 8 compat
107 "test_read_with_valid_file_extension"
108 ]
109 ++ lib.optionals stdenv.hostPlatform.isDarwin [
110 # might fail due to the sandbox
111 "test_end2end_autosave_slow_notebook"
112 ];
113
114 disabledTestPaths = [
115 # ImportError: cannot import name 'mock_s3' from 'moto'
116 "papermill/tests/test_s3.py"
117 ];
118
119 __darwinAllowLocalNetworking = true;
120
121 meta = {
122 description = "Parametrize and run Jupyter and interact with notebooks";
123 homepage = "https://github.com/nteract/papermill";
124 changelog = "https://papermill.readthedocs.io/en/latest/changelog.html";
125 license = lib.licenses.bsd3;
126 maintainers = [ ];
127 mainProgram = "papermill";
128 };
129}