From 5ac5bf7f91fa0fa7f5dd4e2aa8bf207a3c034f66 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Tue, 22 Oct 2024 16:15:51 +0200 Subject: [PATCH] python312Packages.jupyter-console: clean and fix on darwin --- .../jupyter-console/default.nix | 54 ++++++++++++------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/pkgs/development/python-modules/jupyter-console/default.nix b/pkgs/development/python-modules/jupyter-console/default.nix index 5ae844ad91ed..e699d4d25187 100644 --- a/pkgs/development/python-modules/jupyter-console/default.nix +++ b/pkgs/development/python-modules/jupyter-console/default.nix @@ -1,11 +1,13 @@ { lib, buildPythonPackage, - fetchPypi, - pythonOlder, + fetchFromGitHub, + + # build-system hatchling, + + # dependencies ipykernel, - exceptiongroup, ipython, jupyter-client, jupyter-core, @@ -13,6 +15,8 @@ pygments, pyzmq, traitlets, + + # tests flaky, pexpect, pytestCheckHook, @@ -21,27 +25,29 @@ buildPythonPackage rec { pname = "jupyter-console"; version = "6.6.3"; - format = "pyproject"; + pyproject = true; - disabled = pythonOlder "3.7"; - - src = fetchPypi { - pname = "jupyter_console"; - inherit version; - hash = "sha256-VmpL8xyHrb+t8izfhG4wabWace1dpx1rpNiqrRSlNTk="; + src = fetchFromGitHub { + owner = "jupyter"; + repo = "jupyter_console"; + rev = "refs/tags/v${version}"; + hash = "sha256-jdSeZCspcjEQVBpJyxVnwJ5SAq+SS1bW9kqp/F/zwCQ="; }; - nativeBuildInputs = [ hatchling ]; + postPatch = + # Use wrapped executable in tests + let + binPath = "${placeholder "out"}/bin/jupyter-console"; + in + '' + substituteInPlace jupyter_console/tests/test_console.py \ + --replace-fail "'-m', 'jupyter_console', " "" \ + --replace-fail "sys.executable" "'${binPath}'" + ''; - postPatch = '' - # use wrapped executable in tests - substituteInPlace jupyter_console/tests/test_console.py \ - --replace "args = ['-m', 'jupyter_console', '--colors=NoColor']" "args = ['--colors=NoColor']" \ - --replace "cmd = sys.executable" "cmd = '${placeholder "out"}/bin/jupyter-console'" \ - --replace "check_output([sys.executable, '-m', 'jupyter_console'," "check_output(['${placeholder "out"}/bin/jupyter-console'," - ''; + build-system = [ hatchling ]; - propagatedBuildInputs = [ + dependencies = [ ipykernel ipython jupyter-client @@ -50,7 +56,7 @@ buildPythonPackage rec { pygments pyzmq traitlets - ] ++ lib.optionals (pythonOlder "3.11") [ exceptiongroup ]; + ]; pythonImportsCheck = [ "jupyter_console" ]; @@ -64,6 +70,14 @@ buildPythonPackage rec { export HOME=$TMPDIR ''; + disabledTests = [ + # Flaky: pexpect.exceptions.TIMEOUT: Timeout exceeded + "test_console_starts" + "test_display_text" + ]; + + __darwinAllowLocalNetworking = true; + meta = { description = "Jupyter terminal console"; mainProgram = "jupyter-console";