1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
nodejs,
yarn-berry_3,
# build-system
hatch-jupyter-builder,
hatchling,
jupyterlab,
# dependencies
markdown-it-py,
mdit-py-plugins,
nbformat,
packaging,
pyyaml,
pythonOlder,
tomli,
# tests
addBinToPathHook,
jupyter-client,
notebook,
pytest-asyncio,
pytest-xdist,
pytestCheckHook,
versionCheckHook,
writableTmpDirAsHomeHook,
}:
buildPythonPackage rec {
pname = "jupytext";
version = "1.17.3";
pyproject = true;
src = fetchFromGitHub {
owner = "mwouts";
repo = "jupytext";
tag = "v${version}";
hash = "sha256-qxQU3b+u9sQD0mtvZz6fw0jYmdfQmwtKaGxUc/qOcTE=";
};
patches = [
./fix-yarn-lock-typescript.patch
];
nativeBuildInputs = [
nodejs
yarn-berry_3.yarnBerryConfigHook
];
missingHashes = ./missing-hashes.json;
offlineCache = yarn-berry_3.fetchYarnBerryDeps {
inherit src missingHashes;
patches = [
./fix-yarn-lock-typescript-offline-cache.patch
];
sourceRoot = "${src.name}/jupyterlab";
hash = "sha256-k2lQnlSmCghIkp6VwNmq5KpSHS5tEbnFnsM+xqo3Ebw=";
};
env.HATCH_BUILD_HOOKS_ENABLE = true;
preConfigure = ''
pushd jupyterlab
'';
preBuild = ''
popd
'';
build-system = [
hatch-jupyter-builder
hatchling
jupyterlab
];
dependencies = [
markdown-it-py
mdit-py-plugins
nbformat
packaging
pyyaml
]
++ lib.optionals (pythonOlder "3.11") [ tomli ];
nativeCheckInputs = [
addBinToPathHook
jupyter-client
notebook
pytest-asyncio
pytest-xdist
pytestCheckHook
versionCheckHook
# Tests that use a Jupyter notebook require $HOME to be writable
writableTmpDirAsHomeHook
];
preCheck = ''
substituteInPlace tests/functional/contents_manager/test_async_and_sync_contents_manager_are_in_sync.py \
--replace-fail "from black import FileMode, format_str" "" \
--replace-fail "format_str(sync_code, mode=FileMode())" "sync_code"
'';
disabledTestPaths = [
# Requires the `git` python module
"tests/external"
];
disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
# requires access to trash
"test_load_save_rename"
];
pythonImportsCheck = [
"jupytext"
"jupytext.cli"
];
meta = {
description = "Jupyter notebooks as Markdown documents, Julia, Python or R scripts";
homepage = "https://github.com/mwouts/jupytext";
changelog = "https://github.com/mwouts/jupytext/blob/${src.tag}/CHANGELOG.md";
license = lib.licenses.mit;
teams = [ lib.teams.jupyter ];
mainProgram = "jupytext";
};
}
|