Skip to main content

PyPI CI

Basilisp Kernel for Jupyter

Basilisp is a Python-based Lisp implementation that offers broad compatibility with Clojure. Refer to documentation to get started.

Overview

The Basilisp Kernel enables running Basilisp Clojure code directly within Jupyter notebooks.

Features

  • Full integration with Jupyter Notebook and JupyterLab.
  • Enhanced autocompletion features using the Tab key.
  • Seamless interoperability with Python libraries.
  • Interactive development with your preferred editor, powered by the nREPL server running inside the notebook.

Installation

Ensure you have Jupyter installed. If not, install it using pip:

pip install jupyter

To install the Basilisp Kernel, run:

pip install basilisp-kernel

Usage

Start your Jupyter notebook server:

jupyter notebook

In the Jupyter interface, select the Basilisp Kernel when creating a new notebook.

Examples

This project includes a series of Jupyter notebooks that demonstrate various features and capabilities. You can find these notebooks in the notebooks directory of this repository.

notebook plotting example

nREPL support

See API.md.

The Basilisp Kernel includes an nREPL server, allowing remote interaction with notebooks using Clojure-Enabled Editors like Emacs (via CIDER) and VS code (via Calva). For detailed use cases, visit the Connecting Your Editor to the nREPL Server page.

Starting the nREPL Server

Start the nREPL in your notebook by running:

(require '[basilisp-kernel.nrepl-server :refer [server-start server-shut]])
(def server (server-start))
=> nREPL server started on port 58966 on host 127.0.0.1 - nrepl://127.0.0.1:58966
=> #'user/server

For additional configuration options, such as specifying a port with :port or directory for the .nrepl-port file with :dir, consult the server-start documentation.

Stopping the nREPL Server

(server-shut server)
=> :shut

Getting Started with Basilisp Notebooks Development

Below are various methods to help you start writing Basilisp code that can be loaded in a Basilisp notebook.

🔋 Batteries Included Project: basilex-notebook

The Basilisp Example Notebook repository, is an excellent resource for exploring Basilisp notebooks. It includes Jupyter, the Basilisp kernel, a skeleton Basilisp library, and a development notebook to help you get started.

  1. Install Poetry for dependency management.

  2. Clone the repository, install dependencies, activate the environment and start Jupyter:

$ git clone https://github.com/ikappaki/basilex-notebook.git
$ cd basilex-notebook
$ poetry install
$ poetry shell
(<env>) $ jupyter notebook
  1. Open the tutorial.ipynb notebook from the Jupyter interface. Refer to the basilex-notebook documentation for more details.

💾 Local Basilisp Files

You can seamlessly write and use Basilisp .lpy files in the same directory as your Notebook. These files can be required in the Notebook just like standard Basilisp namespaces.

For example, if you create a file named dev.lpy with the following content

./dev.lpy

(ns dev)

(defn hello []
  :hi)

You can load and use it in your Notebook as follows

[n]:   (require 'dev)
[n+1]: (dev/hello)
:hi

nREPL development

You can start an nREPL server directly within a Notebook and connect to it using a Clojure-enabled editor.

In a notebook cell:

  1. Load the nREPL server namespace:
[n]: (require '[basilisp-kernel.nrepl-server :as nrepl-server])
  1. Start the nREPL server at a random port
[n]: (def server (nrepl-server/server-start))
nREPL server started on port 59498 on host 127.0.0.1 - nrepl://127.0.0.1:59498
#'user/server

To connect your editor to the nREPL server create a basilisp.edn file in the same directory as your Notebook.

Open your Clojure-enabled editor and use its nREPL connection commands. The server generated a .nrepl-port file in the directory, which helps the editor locate the port.

Both Emacs/CIDER and VSCode/Calva offer explicit support for Basilisp.

CIDER (Emacs)

  1. Run M-x cider-connect-clj.
  2. Select localhost.
  3. Select the <project-dir>:<port number> option.

Calva (VSCode)

  1. Press Ctrl-Alt-P to open the Command Palette.
  2. Select Calva: Connect to a Running REPL Server, in your project>basilisp.
  3. The editor will automatically find the port using .nrepl-port.

The Editor should now connect seamlessly to the nREPL server.


📚 Basilisp Example Library Project: basilex-basilib

The Basilisp Example Library repository provides a starting point for setting up an external Basilisp library that can be integrated with your notebooks.

The instructions below assume you are working in a virtual environment where the Basilisp Notebooks will be launched (e.g. the basiliex-notebook setup above). This is indicated by the environment name prefix in your command prompt, such as <venv> in the examples below.

Setup

Clone the repository and install the basilib library as an editable package in in the same virtual environment as your Basilisp notebooks:

(<env>) $ git clone https://github.com/ikappaki/basilex-basilib.git
(<env>) $ cd basilex-basilib
# install example library in virtual environment as editable package
(<env>) $ pip install -e .

Usage

Load and interact with the library in your notebooks:

[n]:   (require '[basilib.core :as bc])
[n+1]: (bc/time-now)
=> '2024-11-30 14:53:00'

nREPL development

For interactive coding, you can connect your preferred Clojure-Enabled Editor to a running nREPL server in your Basilisp Notebook.

In a notebook cell:

  1. Load the nREPL server namespace:
[n]: (require '[basilisp-kernel.nrepl-server :as nrepl-server])
  1. Start the nREPL server on a fixed port:
[n]: (def server (server-start {:port 9998}))
nREPL server started on port 9998 on host 127.0.0.1 - nrepl://127.0.0.1:9998
#'user/server

In your code Editor, open the basilisp.edn file located in your project root directory (e.g. in basilex-notebook, basilex-basilib or your own Basilisp Project) to enable Clojure-specific features in your editor. Then, use your editor's commands to connect to the nREPL server.

Both Emacs/CIDER and VSCode/Calva offer explicit support for Basilisp.

Connecting via CIDER (Emacs)
  1. Run M-x cider-connect-clj
  2. Select localhost.
  3. Enter the port number from the nREPL server output.
Connecting Calva (VSCode)
  1. Press Ctrl-Shift-P to open the Command Palette.
  2. Select Calva: Connect to a Running REPL Server, not in your project>basilisp.
  3. Enter the port number from the nREPL server output.

Acknowledgments

This kernel was developed using the echo_kernel as a starting point.

Metadata

Release files for basilisp-kernel 1.3.0

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

Source distribution (sdist)

Source distribution for basilisp-kernel 1.3.0
File Size Uploaded Provenance Actions
basilisp_kernel-1.3.0.tar.gz 7.8 kB With provenance Details for basilisp_kernel-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for basilisp-kernel 1.3.0
File Interpreter ABI Platform Actions
basilisp_kernel-1.3.0-py3-none-any.whl Python 3 none any Details for basilisp_kernel-1.3.0-py3-none-any.whl

Total release size: 17.0 kB

Release files / basilisp_kernel-1.3.0.tar.gz

Download URL basilisp_kernel-1.3.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4e56358be7b84126ef4e4a73d922d8b52da06b6940bc3790b5c68d6087f94ec3
BLAKE2b-256 checksum
How to use checksums
401d89e73eae04c473a1399d9fddce8cf52212166a1317b39d8a986cc262be51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 1, 2025.

Transparency log

Release files / basilisp_kernel-1.3.0-py3-none-any.whl

Download URL basilisp_kernel-1.3.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fdc236e66569bac12e31bedd0375e05b35531350f6bf8d9c71c9d7024e65dcdf
BLAKE2b-256 checksum
How to use checksums
a300f554fd687c072b1547645db78a555fdec245f9e7a2796b7684f77cbb86aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 1, 2025.

Transparency log

Security for basilisp-kernel 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for basilisp_kernel-1.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 1, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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