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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kernmini-0.1.2.tar.gz (31.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kernmini-0.1.2-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file kernmini-0.1.2.tar.gz.

File metadata

  • Download URL: kernmini-0.1.2.tar.gz
  • Upload date:
  • Size: 31.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for kernmini-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c08339a4f96d9fb5da1971a2c9dd6e5e534686d78675c2a1f953b6c35ce58d28
MD5 e3073d82271f6cf952125c89d9be91bd
BLAKE2b-256 d9f6f8578d0d1a0174b6c61db7f6cbc7bff7e68faaea5ed4678e8ac8109d90bb

See more details on using hashes here.

File details

Details for the file kernmini-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: kernmini-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for kernmini-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 11246559c6187fd74f1886f02bb6dbfc9994e2c6da34cfc84e7a675670be55ff
MD5 89975329019e2773e813fda0a41ca6c4
BLAKE2b-256 5ff2d4ee45452cfaba573664b11960b99ab7bbd4d9b05bc7b9eb948b0171f80e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page