diff --git a/pkgs/development/python-modules/experiment-utilities/default.nix b/pkgs/development/python-modules/experiment-utilities/default.nix index 46c50e1e2ec0f..5fd21994558e1 100644 --- a/pkgs/development/python-modules/experiment-utilities/default.nix +++ b/pkgs/development/python-modules/experiment-utilities/default.nix @@ -5,6 +5,7 @@ , fasteners , fetchFromGitLab , qgrid +, ipynbname , ipywidgets , odfpy , scipy @@ -28,6 +29,10 @@ buildPythonPackage rec { hash = "sha256-zjmmLUpGjUhpw2+stLJE6cImesnBSvrcid5bHMftX/Q="; }; + patches = [ + ./unvendor-ipynbname.patch + ]; + # This dependency constraint (<=7.6.5) was due to a bug in qgrid that has been patched in its # owned derivation postPatch = '' @@ -39,6 +44,7 @@ buildPythonPackage rec { cloudpickle dill fasteners + ipynbname ipywidgets odfpy plotly diff --git a/pkgs/development/python-modules/experiment-utilities/unvendor-ipynbname.patch b/pkgs/development/python-modules/experiment-utilities/unvendor-ipynbname.patch new file mode 100644 index 0000000000000..84f4467a83472 --- /dev/null +++ b/pkgs/development/python-modules/experiment-utilities/unvendor-ipynbname.patch @@ -0,0 +1,117 @@ +diff --git a/exputils/gui/jupyter/__init__.py b/exputils/gui/jupyter/__init__.py +index 6e9aefb..fdfdd28 100644 +--- a/exputils/gui/jupyter/__init__.py ++++ b/exputils/gui/jupyter/__init__.py +@@ -30,8 +30,8 @@ from exputils.gui.jupyter.misc import remove_children_from_widget + from exputils.gui.jupyter.misc import set_children_of_widget + from exputils.gui.jupyter.misc import generate_random_state_backup_name + +-from exputils.gui.jupyter.ipynbname import get_notebook_name +-from exputils.gui.jupyter.ipynbname import get_notebook_path ++from ipynbname import name as get_notebook_name ++from ipynbname import path as get_notebook_path + + DEFAULT_CONFIG_DIRECTORY = '.ipython_config' + +diff --git a/exputils/gui/jupyter/ipynbname.py b/exputils/gui/jupyter/ipynbname.py +deleted file mode 100644 +index 51e21b7..0000000 +--- a/exputils/gui/jupyter/ipynbname.py ++++ /dev/null +@@ -1,86 +0,0 @@ +-## +-## This file is part of the exputils package. +-## +-## Copyright: INRIA +-## Year: 2022, 2023 +-## Contact: chris.reinke@inria.fr +-## +-## exputils is provided under GPL-3.0-or-later +-## +-# Taken from https://pypi.org/project/ipynbname/ +-# TODO: add them to licence +- +-from notebook import notebookapp +-import urllib, json, os, ipykernel, ntpath +- +-FILE_ERROR = "Can't identify the notebook {}." +-CONN_ERROR = "Unable to access server;\n \ +- + ipynbname requires either no security or token based security." +- +-def _get_kernel_id(): +- """ Returns the kernel ID of the ipykernel. +- """ +- connection_file = os.path.basename(ipykernel.get_connection_file()) +- kernel_id = connection_file.split('-', 1)[1].split('.')[0] +- return kernel_id +- +- +-def _get_sessions(srv): +- """ Given a server, returns sessions, or HTTPError if access is denied. +- NOTE: Works only when either there is no security or there is token +- based security. An HTTPError is raised if unable to connect to a +- server. +- """ +- try: +- qry_str = "" +- token = srv['token'] +- if token: +- qry_str = f"?token={token}" +- url = f"{srv['url']}api/sessions{qry_str}" +- req = urllib.request.urlopen(url) +- return json.load(req) +- except: +- raise urllib.error.HTTPError(CONN_ERROR) +- +- +-def _get_nb_path(sess, kernel_id): +- """ Given a session and kernel ID, returns the notebook path for the +- session, or None if there is no notebook for the session. +- """ +- if sess['kernel']['id'] == kernel_id: +- return sess['notebook']['path'] +- return None +- +- +-def get_notebook_name(): +- """ Returns the short name of the notebook w/o the .ipynb extension, +- or raises a FileNotFoundError exception if it cannot be determined. +- """ +- kernel_id = _get_kernel_id() +- for srv in notebookapp.list_running_servers(): +- try: +- sessions = _get_sessions(srv) +- for sess in sessions: +- nb_path = _get_nb_path(sess, kernel_id) +- if nb_path: +- return ntpath.basename(nb_path).replace('.ipynb', '') +- except: +- pass # There may be stale entries in the runtime directory +- raise FileNotFoundError(FILE_ERROR.format('name')) +- +- +-def get_notebook_path(): +- """ Returns the absolute path of the notebook, +- or raises a FileNotFoundError exception if it cannot be determined. +- """ +- kernel_id = _get_kernel_id() +- for srv in notebookapp.list_running_servers(): +- try: +- sessions = _get_sessions(srv) +- for sess in sessions: +- nb_path = _get_nb_path(sess, kernel_id) +- if nb_path: +- return os.path.join(srv['notebook_dir'], nb_path) +- except: +- pass # There may be stale entries in the runtime directory +- raise FileNotFoundError(FILE_ERROR.format('path')) +\ No newline at end of file +diff --git a/setup.cfg b/setup.cfg +index 9d9cbb0..6080ed6 100644 +--- a/setup.cfg ++++ b/setup.cfg +@@ -25,3 +25,4 @@ install_requires = + tensorboard >= 1.15.0 + fasteners >= 0.18 + pyyaml >= 6.0 ++ ipynbname diff --git a/pkgs/development/python-modules/ipynbname/default.nix b/pkgs/development/python-modules/ipynbname/default.nix new file mode 100644 index 0000000000000..03a27ec19d8cc --- /dev/null +++ b/pkgs/development/python-modules/ipynbname/default.nix @@ -0,0 +1,32 @@ +{ lib +, buildPythonPackage +, fetchPypi +, ipykernel +}: + +buildPythonPackage rec { + pname = "ipynbname"; + version = "2023.2.0.0"; + format = "setuptools"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-Riu915VmJIdtxOqB+nkoRas4cOREyh9res2uo32Mnr8="; + }; + + propagatedBuildInputs = [ + ipykernel + ]; + + pythonImportsCheck = [ "ipynbname" ]; + + # upstream has no tests + doCheck = false; + + meta = { + description = "Simply returns either notebook filename or the full path to the notebook"; + homepage = "https://github.com/msm1089/ipynbname"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ dotlambda ]; + }; +} diff --git a/pkgs/development/python-modules/jupyter-server-ydoc/default.nix b/pkgs/development/python-modules/jupyter-collaboration/default.nix similarity index 55% rename from pkgs/development/python-modules/jupyter-server-ydoc/default.nix rename to pkgs/development/python-modules/jupyter-collaboration/default.nix index a60f74aefbdda..9f17874dfc325 100644 --- a/pkgs/development/python-modules/jupyter-server-ydoc/default.nix +++ b/pkgs/development/python-modules/jupyter-collaboration/default.nix @@ -1,29 +1,33 @@ { lib , buildPythonPackage , pythonOlder -, fetchFromGitHub +, fetchPypi +, hatch-jupyter-builder +, hatch-nodejs-version , hatchling , pythonRelaxDepsHook +, jupyter-events +, jupyter-server , jupyter-server-fileid , jupyter-ydoc , ypy-websocket +, pytest-asyncio , pytest-jupyter , pytestCheckHook }: buildPythonPackage rec { - pname = "jupyter-server-ydoc"; - version = "0.8.0"; + pname = "jupyter-collaboration"; + version = "1.0.1"; - disabled = pythonOlder "3.7"; + disabled = pythonOlder "3.8"; format = "pyproject"; - src = fetchFromGitHub { - owner = "jupyterlab"; - repo = "jupyter_collaboration"; - rev = "refs/tags/v${version}"; - hash = "sha256-KLb7kU5jsj6ihGO6HU3Y7uF+0PcwKoQlqQAhtO0oaJw="; + src = fetchPypi { + pname = "jupyter_collaboration"; + inherit version; + hash = "sha256-cf7BpF6WSoHQJQW0IXdpCAGTdkX9RNWZ4JovTHvcPho="; }; postPatch = '' @@ -31,6 +35,8 @@ buildPythonPackage rec { ''; nativeBuildInputs = [ + hatch-jupyter-builder + hatch-nodejs-version hatchling pythonRelaxDepsHook ]; @@ -40,14 +46,17 @@ buildPythonPackage rec { ]; propagatedBuildInputs = [ + jupyter-events + jupyter-server jupyter-server-fileid jupyter-ydoc ypy-websocket ]; - pythonImportsCheck = [ "jupyter_server_ydoc" ]; + pythonImportsCheck = [ "jupyter_collaboration" ]; nativeCheckInputs = [ + pytest-asyncio pytest-jupyter pytestCheckHook ]; @@ -57,10 +66,10 @@ buildPythonPackage rec { ''; meta = { - changelog = "https://github.com/jupyterlab/jupyter_collaboration/blob/${src.rev}/CHANGELOG.md"; - description = "A Jupyter Server Extension Providing Y Documents"; + changelog = "https://github.com/jupyterlab/jupyter_collaboration/blob/v${version}/CHANGELOG.md"; + description = "JupyterLab Extension enabling Real-Time Collaboration"; homepage = "https://github.com/jupyterlab/jupyter_collaboration"; license = lib.licenses.bsd3; - maintainers = with lib.maintainers; [ dotlambda ]; + maintainers = lib.teams.jupyter.members; }; } diff --git a/pkgs/development/python-modules/jupyter-nbextensions-configurator/default.nix b/pkgs/development/python-modules/jupyter-nbextensions-configurator/default.nix index ef0ff175268ff..c675542be1080 100644 --- a/pkgs/development/python-modules/jupyter-nbextensions-configurator/default.nix +++ b/pkgs/development/python-modules/jupyter-nbextensions-configurator/default.nix @@ -1,7 +1,13 @@ { lib , buildPythonPackage , fetchFromGitHub +, fetchpatch , jupyter-contrib-core +, jupyter-core +, jupyter-server +, notebook +, pyyaml +, tornado }: buildPythonPackage rec { @@ -15,7 +21,23 @@ buildPythonPackage rec { hash = "sha256-ovKYHATRAC5a5qTMv32ohU2gJd15/fRKXa5HI0zGp/0="; }; - propagatedBuildInputs = [ jupyter-contrib-core ]; + patches = [ + # https://github.com/Jupyter-contrib/jupyter_nbextensions_configurator/pull/166 + (fetchpatch { + name = "notebook-v7-compat.patch"; + url = "https://github.com/Jupyter-contrib/jupyter_nbextensions_configurator/commit/a600cef9222ca0c61a6912eb29d8fa0323409705.patch"; + hash = "sha256-Rt9r5ZOgnhBcs18+ET5+k0/t980I2DiVN8oHkGLp0iw="; + }) + ]; + + propagatedBuildInputs = [ + jupyter-contrib-core + jupyter-core + jupyter-server + notebook + pyyaml + tornado + ]; pythonImportsCheck = [ "jupyter_nbextensions_configurator" ]; diff --git a/pkgs/development/python-modules/jupyter-server/default.nix b/pkgs/development/python-modules/jupyter-server/default.nix index 317b42d8a17c7..9532e5ca68a9d 100644 --- a/pkgs/development/python-modules/jupyter-server/default.nix +++ b/pkgs/development/python-modules/jupyter-server/default.nix @@ -23,24 +23,27 @@ , jupyter-server-terminals , nbformat , nbconvert +, packaging , send2trash , terminado , prometheus-client , anyio , websocket-client +, overrides , requests +, flaky }: buildPythonPackage rec { pname = "jupyter-server"; - version = "2.0.6"; + version = "2.7.0"; format = "pyproject"; - disabled = pythonOlder "3.7"; + disabled = pythonOlder "3.8"; src = fetchPypi { pname = "jupyter_server"; inherit version; - hash= "sha256-jddZkukLfKVWeUoe1cylEmPGl6vG0N9WGvV0qhwKAz8="; + hash = "sha256-NtoKJm0xpBrDNaNmyIkzwX36W7gXpI9cAsFtMDvJR38="; }; nativeBuildInputs = [ @@ -60,22 +63,23 @@ buildPythonPackage rec { jupyter-server-terminals nbformat nbconvert + packaging send2trash terminado prometheus-client anyio websocket-client + overrides ]; nativeCheckInputs = [ ipykernel - pandoc pytestCheckHook pytest-console-scripts pytest-jupyter pytest-timeout - pytest-tornasync requests + flaky ]; preCheck = '' @@ -85,11 +89,16 @@ buildPythonPackage rec { disabledTests = [ "test_cull_idle" + "test_server_extension_list" ] ++ lib.optionals stdenv.isDarwin [ # attempts to use trashcan, build env doesn't allow this "test_delete" # test is presumable broken in sandbox "test_authorized_requests" + # Insufficient access privileges for operation + "test_regression_is_hidden" + ] ++ lib.optionals (stdenv.isLinux && stdenv.isAarch64) [ + "test_copy_big_dir" ]; disabledTestPaths = [ @@ -103,9 +112,10 @@ buildPythonPackage rec { __darwinAllowLocalNetworking = true; meta = with lib; { + changelog = "https://github.com/jupyter-server/jupyter_server/blob/v${version}/CHANGELOG.md"; description = "The backend—i.e. core services, APIs, and REST endpoints—to Jupyter web applications"; homepage = "https://github.com/jupyter-server/jupyter_server"; license = licenses.bsdOriginal; - maintainers = [ maintainers.elohmeier ]; + maintainers = lib.teams.jupyter.members; }; } diff --git a/pkgs/development/python-modules/jupyter-ydoc/default.nix b/pkgs/development/python-modules/jupyter-ydoc/default.nix index d2643155bff8c..e3294150bf62e 100644 --- a/pkgs/development/python-modules/jupyter-ydoc/default.nix +++ b/pkgs/development/python-modules/jupyter-ydoc/default.nix @@ -11,14 +11,14 @@ buildPythonPackage rec { pname = "jupyter-ydoc"; - version = "0.3.4"; + version = "1.0.2"; format = "pyproject"; src = fetchPypi { pname = "jupyter_ydoc"; inherit version; - hash = "sha256-WiJi5wvwBLgsxs5xZ16TMKoFj+MNsuh82BJa1N0a5OE="; + hash = "sha256-D5W+3j8eCB4H1cV8A8ZY46Ukfg7xiIkHT776IN0+ylM="; }; nativeBuildInputs = [ @@ -46,6 +46,6 @@ buildPythonPackage rec { description = "Document structures for collaborative editing using Ypy"; homepage = "https://github.com/jupyter-server/jupyter_ydoc"; license = lib.licenses.bsd3; - maintainers = with lib.maintainers; [ dotlambda ]; + maintainers = lib.teams.jupyter.members; }; } diff --git a/pkgs/development/python-modules/jupyterlab/default.nix b/pkgs/development/python-modules/jupyterlab/default.nix index 433031d73065a..81c7f862f6ad2 100644 --- a/pkgs/development/python-modules/jupyterlab/default.nix +++ b/pkgs/development/python-modules/jupyterlab/default.nix @@ -1,54 +1,50 @@ { lib , buildPythonPackage , fetchPypi -, ipython +, hatch-jupyter-builder +, hatchling +, async-lru , packaging , tornado +, ipykernel , jupyter-core +, jupyter-lsp , jupyterlab_server , jupyter-server -, jupyter-server-ydoc -, notebook +, notebook-shim , jinja2 , tomli , pythonOlder , jupyter-packaging -, pythonRelaxDepsHook -, nbclassic }: buildPythonPackage rec { pname = "jupyterlab"; - version = "3.6.3"; - format = "setuptools"; + version = "4.0.3"; + format = "pyproject"; - disabled = pythonOlder "3.7"; + disabled = pythonOlder "3.8"; src = fetchPypi { inherit pname version; - hash = "sha256-Nz6c+4py7dKUvhTxZmJWOiIM7PD7Jt56qxr5optom4I="; + hash = "sha256-4U0c5GphMCgRHQ1Hah19awlAA7dGK6xmn1tHgxeryzk="; }; nativeBuildInputs = [ - jupyter-packaging - pythonRelaxDepsHook - ]; - - pythonRelaxDeps = [ - "jupyter-ydoc" - "jupyter-server-ydoc" + hatch-jupyter-builder + hatchling ]; propagatedBuildInputs = [ - ipython + async-lru packaging tornado + ipykernel jupyter-core + jupyter-lsp jupyterlab_server jupyter-server - jupyter-server-ydoc - nbclassic - notebook + notebook-shim jinja2 ] ++ lib.optionals (pythonOlder "3.11") [ tomli @@ -68,10 +64,10 @@ buildPythonPackage rec { ]; meta = with lib; { - changelog = "https://github.com/jupyterlab/jupyterlab/releases/tag/v${version}"; + changelog = "https://github.com/jupyterlab/jupyterlab/blob/v${version}/CHANGELOG.md"; description = "Jupyter lab environment notebook server extension"; - license = with licenses; [ bsd3 ]; + license = licenses.bsd3; homepage = "https://jupyter.org/"; - maintainers = with maintainers; [ zimbatm ]; + maintainers = lib.teams.jupyter.members; }; } diff --git a/pkgs/development/python-modules/jupyterlab_server/default.nix b/pkgs/development/python-modules/jupyterlab_server/default.nix index b766f6d42e0f8..dfb6c23867fd1 100644 --- a/pkgs/development/python-modules/jupyterlab_server/default.nix +++ b/pkgs/development/python-modules/jupyterlab_server/default.nix @@ -19,14 +19,14 @@ buildPythonPackage rec { pname = "jupyterlab_server"; - version = "2.19.0"; + version = "2.24.0"; format = "pyproject"; disabled = pythonOlder "3.7"; src = fetchPypi { inherit pname version; - hash = "sha256-muwhohg7vt2fkahmKDVUSVdfGGLYiyitX5BQGdMebCE="; + hash = "sha256-Tm+Z4KVXm7vDLkScTbsDlWHU8aeCfVczJz7VZzjyHwc="; }; nativeBuildInputs = [ @@ -77,6 +77,6 @@ buildPythonPackage rec { homepage = "https://jupyterlab-server.readthedocs.io/"; changelog = "https://github.com/jupyterlab/jupyterlab_server/blob/v${version}/CHANGELOG.md"; license = licenses.bsdOriginal; - maintainers = with maintainers; [ ]; + maintainers = lib.teams.jupyter.members; }; } diff --git a/pkgs/development/python-modules/notebook/default.nix b/pkgs/development/python-modules/notebook/default.nix index 9cd1e9c37a1ea..628742c72f300 100644 --- a/pkgs/development/python-modules/notebook/default.nix +++ b/pkgs/development/python-modules/notebook/default.nix @@ -3,97 +3,66 @@ , buildPythonPackage , pythonOlder , fetchPypi -, argon2-cffi -, glibcLocales -, mock -, jinja2 +, hatch-jupyter-builder +, hatchling +, jupyter-server +, jupyterlab +, jupyterlab_server +, notebook-shim , tornado -, ipython_genutils -, traitlets -, jupyter-core -, jupyter-client -, nbformat -, nbclassic -, nbconvert -, ipykernel -, terminado -, requests -, send2trash -, pexpect -, prometheus-client +, pytest-jupyter , pytestCheckHook }: buildPythonPackage rec { pname = "notebook"; - version = "6.5.2"; - disabled = pythonOlder "3.7"; + version = "7.0.1"; + disabled = pythonOlder "3.8"; + + format = "pyproject"; src = fetchPypi { inherit pname version; - hash = "sha256-wYl+UxfiJfx4tFVJpqtLZo5MmW/QOgTpOP5eevK//9A="; + hash = "sha256-LhatTmPqiffvviEu58FpP8+lq1X/73UEdTD3SvS9kmw="; }; - LC_ALL = "en_US.utf8"; + postPatch = '' + substituteInPlace pyproject.toml \ + --replace "timeout = 300" "" + ''; - nativeCheckInputs = [ pytestCheckHook glibcLocales ]; + nativeBuildInputs = [ + hatch-jupyter-builder + hatchling + jupyterlab + ]; propagatedBuildInputs = [ - jinja2 + jupyter-server + jupyterlab + jupyterlab_server + notebook-shim tornado - ipython_genutils - traitlets - jupyter-core - send2trash - jupyter-client - nbformat - nbclassic - nbconvert - ipykernel - terminado - requests - pexpect - prometheus-client - argon2-cffi ]; - postPatch = '' - # Remove selenium tests - rm -rf notebook/tests/selenium - export HOME=$TMPDIR - ''; - - disabledTests = [ - # a "system_config" is generated, and fails many tests - "config" - "load_ordered" - # requires jupyter, but will cause circular imports - "test_run" - "TestInstallServerExtension" - "launch_socket" - "sock_server" - "test_list_formats" # tries to find python MIME type - "KernelCullingTest" # has a race condition failing on slower hardware - "test_connections" # tornado.simple_httpclient.HTTPTimeoutError: Timeout during request" - ] ++ lib.optionals stdenv.isDarwin [ - "test_delete" - "test_checkpoints_follow_file" + nativeCheckInputs = [ + pytest-jupyter + pytestCheckHook ]; - disabledTestPaths = lib.optionals stdenv.isDarwin [ - # requires local networking - "notebook/auth/tests/test_login.py" - "notebook/bundler/tests/test_bundler_api.py" - ]; + env = { + JUPYTER_PLATFORM_DIRS = 1; + }; # Some of the tests use localhost networking. __darwinAllowLocalNetworking = true; meta = { - description = "The Jupyter HTML notebook is a web-based notebook environment for interactive computing"; + changelog = "https://github.com/jupyter/notebook/blob/v${version}/CHANGELOG.md"; + description = "Web-based notebook environment for interactive computing"; homepage = "https://github.com/jupyter/notebook"; license = lib.licenses.bsd3; - maintainers = with lib.maintainers; [ fridh ]; + maintainers = lib.teams.jupyter.members; mainProgram = "jupyter-notebook"; }; } diff --git a/pkgs/top-level/python-aliases.nix b/pkgs/top-level/python-aliases.nix index a6ef2838bcb68..6ec506a144499 100644 --- a/pkgs/top-level/python-aliases.nix +++ b/pkgs/top-level/python-aliases.nix @@ -182,6 +182,7 @@ mapAliases ({ jupyter_client = jupyter-client; # added 2021-10-15 jupyter_core = jupyter-core; # added 2023-01-05 jupyter_server = jupyter-server; # added 2023-01-05 + jupyter-server-ydoc = jupyter-collaboration; # added 2023-07-18 Kajiki = kajiki; # added 2023-02-19 Keras = keras; # added 2021-11-25 larynx-train = piper-train; # added 2023-06-09 diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 83b45cde21b35..226542b310446 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5179,6 +5179,8 @@ self: super: with self; { ipydatawidgets = callPackage ../development/python-modules/ipydatawidgets { }; + ipynbname = callPackage ../development/python-modules/ipynbname { }; + ipyniivue = callPackage ../development/python-modules/ipyniivue { }; ipykernel = callPackage ../development/python-modules/ipykernel { }; @@ -5485,6 +5487,8 @@ self: super: with self; { jupyter-client = callPackage ../development/python-modules/jupyter-client { }; + jupyter-collaboration = callPackage ../development/python-modules/jupyter-collaboration { }; + jupyter-contrib-core = callPackage ../development/python-modules/jupyter-contrib-core { }; jupyter-contrib-nbextensions = callPackage ../development/python-modules/jupyter-contrib-nbextensions { }; @@ -5507,8 +5511,6 @@ self: super: with self; { jupyter-server-terminals = callPackage ../development/python-modules/jupyter-server-terminals { }; - jupyter-server-ydoc = callPackage ../development/python-modules/jupyter-server-ydoc { }; - jupyter-ui-poll = callPackage ../development/python-modules/jupyter-ui-poll { }; jupyter-ydoc = callPackage ../development/python-modules/jupyter-ydoc { };