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