at master 2.5 kB view raw
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.2"; 35 pyproject = true; 36 37 src = fetchFromGitHub { 38 owner = "mwouts"; 39 repo = "jupytext"; 40 tag = "v${version}"; 41 hash = "sha256-xMmtppXect+PRlEp2g0kJurALVvcfza+FBbZbK2SbHc="; 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 ] 80 ++ lib.optionals (pythonOlder "3.11") [ tomli ]; 81 82 nativeCheckInputs = [ 83 jupyter-client 84 notebook 85 pytest-asyncio 86 pytest-xdist 87 pytestCheckHook 88 versionCheckHook 89 ]; 90 versionCheckProgramArg = "--version"; 91 92 preCheck = '' 93 # Tests that use a Jupyter notebook require $HOME to be writable 94 export HOME=$(mktemp -d); 95 export PATH=$out/bin:$PATH; 96 97 substituteInPlace tests/functional/contents_manager/test_async_and_sync_contents_manager_are_in_sync.py \ 98 --replace-fail "from black import FileMode, format_str" "" \ 99 --replace-fail "format_str(sync_code, mode=FileMode())" "sync_code" 100 ''; 101 102 disabledTestPaths = [ 103 # Requires the `git` python module 104 "tests/external" 105 ]; 106 107 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [ 108 # requires access to trash 109 "test_load_save_rename" 110 ]; 111 112 pythonImportsCheck = [ 113 "jupytext" 114 "jupytext.cli" 115 ]; 116 117 meta = { 118 description = "Jupyter notebooks as Markdown documents, Julia, Python or R scripts"; 119 homepage = "https://github.com/mwouts/jupytext"; 120 changelog = "https://github.com/mwouts/jupytext/blob/${src.tag}/CHANGELOG.md"; 121 license = lib.licenses.mit; 122 teams = [ lib.teams.jupyter ]; 123 mainProgram = "jupytext"; 124 }; 125}