1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, fetchpatch
6, gitpython
7, isort
8, jupyter-client
9, jupyter-packaging
10, jupyterlab
11, markdown-it-py
12, mdit-py-plugins
13, nbformat
14, notebook
15, pytestCheckHook
16, pythonOlder
17, pyyaml
18, toml
19}:
20
21buildPythonPackage rec {
22 pname = "jupytext";
23 version = "1.14.1";
24 format = "pyproject";
25
26 disabled = pythonOlder "3.6";
27
28 src = fetchFromGitHub {
29 owner = "mwouts";
30 repo = pname;
31 rev = "refs/tags/v${version}";
32 hash = "sha256-DDF4aTLkhEl4xViYh/E0/y6swcwZ9KbeS0qKm+HdFz8=";
33 };
34
35 patches = [
36 (fetchpatch {
37 url = "https://github.com/mwouts/jupytext/commit/be9b65b03600227b737b5f10ea259a7cdb762b76.patch";
38 hash = "sha256-3klx8I+T560EVfsKe/FlrSjF6JzdKSCt6uhAW2cSwtc=";
39 })
40 ];
41
42 buildInputs = [
43 jupyter-packaging
44 jupyterlab
45 ];
46
47 propagatedBuildInputs = [
48 markdown-it-py
49 mdit-py-plugins
50 nbformat
51 pyyaml
52 toml
53 ];
54
55 nativeCheckInputs = [
56 gitpython
57 isort
58 jupyter-client
59 notebook
60 pytestCheckHook
61 ];
62
63 preCheck = ''
64 # Tests that use a Jupyter notebook require $HOME to be writable
65 export HOME=$(mktemp -d);
66 '';
67
68 pytestFlagsArray = [
69 # Pre-commit tests expect the source directory to be a Git repository
70 "--ignore-glob='tests/test_pre_commit_*.py'"
71 ];
72
73 disabledTests = [
74 "test_apply_black_through_jupytext" # we can't do anything about ill-formatted notebooks
75 ] ++ lib.optionals stdenv.isDarwin [
76 # requires access to trash
77 "test_load_save_rename"
78 ];
79
80 pythonImportsCheck = [
81 "jupytext"
82 "jupytext.cli"
83 ];
84
85 meta = with lib; {
86 description = "Jupyter notebooks as Markdown documents, Julia, Python or R scripts";
87 homepage = "https://github.com/mwouts/jupytext";
88 license = licenses.mit;
89 maintainers = with maintainers; [ timokau ];
90 };
91}