python312Packages.jupyter-console: clean and fix on darwin

This commit is contained in:
Gaetan Lepage 2024-10-22 16:15:51 +02:00
parent c53153d5b8
commit 5ac5bf7f91

View File

@ -1,11 +1,13 @@
{ {
lib, lib,
buildPythonPackage, buildPythonPackage,
fetchPypi, fetchFromGitHub,
pythonOlder,
# build-system
hatchling, hatchling,
# dependencies
ipykernel, ipykernel,
exceptiongroup,
ipython, ipython,
jupyter-client, jupyter-client,
jupyter-core, jupyter-core,
@ -13,6 +15,8 @@
pygments, pygments,
pyzmq, pyzmq,
traitlets, traitlets,
# tests
flaky, flaky,
pexpect, pexpect,
pytestCheckHook, pytestCheckHook,
@ -21,27 +25,29 @@
buildPythonPackage rec { buildPythonPackage rec {
pname = "jupyter-console"; pname = "jupyter-console";
version = "6.6.3"; version = "6.6.3";
format = "pyproject"; pyproject = true;
disabled = pythonOlder "3.7"; src = fetchFromGitHub {
owner = "jupyter";
src = fetchPypi { repo = "jupyter_console";
pname = "jupyter_console"; rev = "refs/tags/v${version}";
inherit version; hash = "sha256-jdSeZCspcjEQVBpJyxVnwJ5SAq+SS1bW9kqp/F/zwCQ=";
hash = "sha256-VmpL8xyHrb+t8izfhG4wabWace1dpx1rpNiqrRSlNTk=";
}; };
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 = '' build-system = [ hatchling ];
# 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',"
'';
propagatedBuildInputs = [ dependencies = [
ipykernel ipykernel
ipython ipython
jupyter-client jupyter-client
@ -50,7 +56,7 @@ buildPythonPackage rec {
pygments pygments
pyzmq pyzmq
traitlets traitlets
] ++ lib.optionals (pythonOlder "3.11") [ exceptiongroup ]; ];
pythonImportsCheck = [ "jupyter_console" ]; pythonImportsCheck = [ "jupyter_console" ];
@ -64,6 +70,14 @@ buildPythonPackage rec {
export HOME=$TMPDIR export HOME=$TMPDIR
''; '';
disabledTests = [
# Flaky: pexpect.exceptions.TIMEOUT: Timeout exceeded
"test_console_starts"
"test_display_text"
];
__darwinAllowLocalNetworking = true;
meta = { meta = {
description = "Jupyter terminal console"; description = "Jupyter terminal console";
mainProgram = "jupyter-console"; mainProgram = "jupyter-console";