Python Jupyter kernel using pyproject environment manangers like Rye, PDM, Poetry, Hatch etc.
Project description
Pyproject Local Jupyter Kernel
- Use per-directory python projects to run Python Jupyter kernels
- Separate dependencies for notebooks in separate projects
- Use Rye, PDM, Poetry, Hatch, or similar project setups to define and run IPython kernels with dependencies for Jupyter notebooks.
Instead of installing a myriad of jupyter kernelspecs, one per project, instead have one "meta" kernel that enables the environment for the project the notebook file resides in. This approach should be more portable (usable to anyone who checks out your project structure from git) and easier to use.
Supports the following, reads pyproject.toml to figure out which kind of project it is:
- Rye
- Poetry
- Hatch
- Pdm
- Custom configuration (for other setups)
Quick Start
-
Install pyproject-local-kernel in your jupyterlab environment and restart jupyterlab
-
Create a new directory and notebook, select the Pyproject Local kernel for the notebook
-
Run (Example for Rye)
!rye init --virtual
!rye add --sync ipykernel
-
Restart the kernel and you are good to go. Use
!rye add
to add further dependencies.
- See the examples directory for how to setup jupyterlab and notebook projects separately. JupyterLab and the notebook are installed in separate environments.
Project Status
Status: Proof of Concept
- Rye: https://github.com/mitsuhiko/rye
- Poetry-kernel: https://github.com/pathbird/poetry-kernel See poetry-kernel for more documentation about the per-directory concept.
User Experience
If the Pyproject Local kernel is used in a project where rye (or the relevant pyproject manager) is not installed, or the rye project does not have an ipykernel, then starting the kernel fails.
It starts a "fallback" kernel which that shows a message that rye is not setup as expected in this environment, and provide a regular ipython kernel which lets you run shell commands to the project.
Example here is currently for Rye.
! Failed to start kernel! The detected project type is: Rye
! Is the virtual environment created, and does it have ipykernel in the project?
!
! Run this:
! !rye add --sync ipykernel
!
! Then restart the kernel to try again.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyproject_local_kernel-0.5.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 977b4d27bbd7bee9c0a95d336cf82c58ae80c541684e2ffd750b17cb1a6f0aa1 |
|
MD5 | 46273cfc9be8357c4580b0b4b63a9355 |
|
BLAKE2b-256 | d2eb3e7ba4c626b91183991fbb894c8049e28d27255f4baae01af1669f647233 |
Hashes for pyproject_local_kernel-0.5.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7498f2913a45891213dcf940b23aed67eb7740af6155b6112546d7d0c08bf612 |
|
MD5 | 4b44d7563cf4e3ae6ecf1ffa939d7628 |
|
BLAKE2b-256 | d69aac36f62baaaaaa5d3215dfd96908f2d3a70e0b8587dfc06ca4745ad0651d |