Skip to main content

kernmini

Everything a Jupyter kernel needs except the language.

kernmini is the language-agnostic core of a Jupyter kernel: connection files, HMAC-signed wire sessions, the full socket thread cast (shell/control async routers, IOPub with a bounded queue and JEP 65 welcomes, stdin routing, heartbeat), busy/idle and abort discipline, stop-on-error, interrupts, JEP 91 subshells, kernelspec installation, and process lifecycle (signal handling, process-group isolation and teardown, parent-watch crash safety). A kernel author supplies only an executor (the shell) and gets a correct, tested kernel around it.

ipymini is the reference kernel (IPython). Its integration suite is kernmini's main proving ground.

A complete kernel

from contextlib import contextmanager
from kernmini import run_kernel

class EchoShell:
    def __init__(self, request_input=None, **kw): self.execution_count,self._stream = 0,None

    def set_stream_sender(self, sender): self._stream = sender

    @contextmanager
    def execution_context(self, allow_stdin, silent): yield

    def kernel_info(self):
        return dict(implementation="echokernel", implementation_version="0.0.1", banner="echo",
            language_info=dict(name="echo", version="1.0", mimetype="text/plain", file_extension=".txt"))

    async def execute(self, code, silent=False, store_history=True, user_expressions=None, allow_stdin=False):
        self.execution_count += 1
        if self._stream: self._stream("stdout", f"echo: {code}\n")
        return dict(execution_count=self.execution_count, result={"text/plain": code.upper()})

run_kernel(connection_file, EchoShell, subshells=False)

That's the whole kernel. Every Jupyter client (JupyterLab, nbclient, jupygate, ...) can now launch it, execute against it, stream its output, and interrupt and shut it down. kernmini.install_kernelspec(name, argv, display_name, language) registers it with Jupyter.

The shell contract is documented in DEV.md. Beyond the four members above, everything is opt-in by capability: implement complete/inspect/is_complete/history for language services, debug_request for a DAP debugger, interrupt for language-specific sync interruption, bind_kernel for a backref, and pass subshells=True when the shell supports concurrent instances.

Install

pip install kernmini

Release files for kernmini 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kernmini 0.1.3
File Size Uploaded
kernmini-0.1.3.tar.gz 33.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kernmini 0.1.3
File Interpreter ABI Platform
kernmini-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 65.6 kB

Release files / kernmini-0.1.3.tar.gz

Download URL kernmini-0.1.3.tar.gz
Size 33.6 kB
Tags Source
SHA-256 checksum
How to use checksums
774c4d1ae8be56f60b80a2d1f6bab76595b6213dd090d3441243e765dcdf4457
BLAKE2b-256 checksum
How to use checksums
987233f148134a2b4a90185a7139625ea180ea68dbe6ad8a2f5a8794939467cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / kernmini-0.1.3-py3-none-any.whl

Download URL kernmini-0.1.3-py3-none-any.whl
Size 32.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4f6ab5833ac343fe1e3e62e875fce336db4448c34f0a26b4d276a6104b6d4e2
BLAKE2b-256 checksum
How to use checksums
7ab66ba0a1c3b427ecdbad211abb31d51685face289c6cb34b36ba886c421cf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release history Release notifications | RSS feed

0.1.9

13 release files

0.1.4

2 release files

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page