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,
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";