pyproject-local-kernel


Namepyproject-local-kernel JSON
Version 0.5.5 PyPI version JSON
download
home_pageNone
SummaryPython Jupyter kernel using pyproject environment manangers like Rye, PDM, Poetry, Hatch etc.
upload_time2024-04-01 13:12:13
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords interactive interpreter jupyter pyproject
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI - Python Version](https://img.shields.io/pypi/v/pyproject-local-kernel)][pypi]

[pypi]: https://pypi.org/project/pyproject-local-kernel/


# 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.

Pyproject Local supports the following systems, and reads pyproject.toml to
figure out which kind of project it is:

- Rye
- Poetry
- Hatch
- Pdm
- Custom configuration (for other setups)

## Quick Start

1. Install pyproject-local-kernel in your jupyterlab environment and restart
   jupyterlab
2. Create a new directory and notebook, select the **Pyproject Local** kernel
   for the notebook
3. Run (Example for Rye)

   * `!rye init --virtual`
   * `!rye add --sync ipykernel`

4. 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.


## User Experience

If the Pyproject Local kernel is used in a project where rye (or the relevant
pyproject manager) is not installed, or the project does not have an ipykernel
in the environment, then starting the kernel fails.

In that case a fallback kernel is started which that shows a message that it is
not setup as expected in this environment. This is a regular ipython kernel which
allows you to run shell commands and hopefully fix the configuration of the project.

It will give you some hints in the Jupyter notebook interface about the next
steps to get it working. Example below is for Rye.

```diff
! 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.
```

## Configuration

By default python from the local pyproject is run (using rye run, poetry run, etc.).
A custom command can be configured in `pyproject.toml` - the pyproject file closest
to the notebook is used (and no other means of configuration are supported).

The key `tool.pyproject-local-kernel.python-cmd` should be a command that runs
python in the virtual environment you want to use for the project.

```toml
[tool.pyproject-local-kernel]
python-cmd = ["my", "custom", "python"]
```

## Project Status

Status: Working proof of concept, published to PyPI. Additional interest and
maintainer help is welcomed.

See also:

* Rye: https://github.com/mitsuhiko/rye
* https://github.com/goerz/python-localvenv-kernel
* Poetry-kernel: https://github.com/pathbird/poetry-kernel

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pyproject-local-kernel",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "Interactive, Interpreter, Jupyter, Pyproject",
    "author": null,
    "author_email": "Ulrik Sverdrup <ulrik.sverdrup@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/97/a5/418b477e09eec1238b584ac7d67799270ade07e4d29ed86994b23fbc2f8b/pyproject_local_kernel-0.5.5.tar.gz",
    "platform": null,
    "description": "[![PyPI - Python Version](https://img.shields.io/pypi/v/pyproject-local-kernel)][pypi]\n\n[pypi]: https://pypi.org/project/pyproject-local-kernel/\n\n\n# Pyproject Local Jupyter Kernel\n\n- Use per-directory python projects to run Python Jupyter kernels\n- Separate dependencies for notebooks in separate projects\n- Use Rye, PDM, Poetry, Hatch, or similar project setups to define and run\n  IPython kernels with dependencies for Jupyter notebooks.\n\nInstead of installing a myriad of jupyter kernelspecs, one per project, instead\nhave one \"meta\" kernel that enables the environment for the project the\nnotebook file resides in. This approach should be more portable, usable to\nanyone who checks out your project structure from git, and easier to use.\n\nPyproject Local supports the following systems, and reads pyproject.toml to\nfigure out which kind of project it is:\n\n- Rye\n- Poetry\n- Hatch\n- Pdm\n- Custom configuration (for other setups)\n\n## Quick Start\n\n1. Install pyproject-local-kernel in your jupyterlab environment and restart\n   jupyterlab\n2. Create a new directory and notebook, select the **Pyproject Local** kernel\n   for the notebook\n3. Run (Example for Rye)\n\n   * `!rye init --virtual`\n   * `!rye add --sync ipykernel`\n\n4. Restart the kernel and you are good to go. Use `!rye add` to add further\n   dependencies.\n\n- See the examples directory for how to setup jupyterlab and notebook projects\n  separately. JupyterLab and the notebook are installed in separate environments.\n\n\n## User Experience\n\nIf the Pyproject Local kernel is used in a project where rye (or the relevant\npyproject manager) is not installed, or the project does not have an ipykernel\nin the environment, then starting the kernel fails.\n\nIn that case a fallback kernel is started which that shows a message that it is\nnot setup as expected in this environment. This is a regular ipython kernel which\nallows you to run shell commands and hopefully fix the configuration of the project.\n\nIt will give you some hints in the Jupyter notebook interface about the next\nsteps to get it working. Example below is for Rye.\n\n```diff\n! Failed to start kernel! The detected project type is: Rye\n! Is the virtual environment created, and does it have ipykernel in the project?\n!\n! Run this:\n! !rye add --sync ipykernel\n!\n! Then restart the kernel to try again.\n```\n\n## Configuration\n\nBy default python from the local pyproject is run (using rye run, poetry run, etc.).\nA custom command can be configured in `pyproject.toml` - the pyproject file closest\nto the notebook is used (and no other means of configuration are supported).\n\nThe key `tool.pyproject-local-kernel.python-cmd` should be a command that runs\npython in the virtual environment you want to use for the project.\n\n```toml\n[tool.pyproject-local-kernel]\npython-cmd = [\"my\", \"custom\", \"python\"]\n```\n\n## Project Status\n\nStatus: Working proof of concept, published to PyPI. Additional interest and\nmaintainer help is welcomed.\n\nSee also:\n\n* Rye: https://github.com/mitsuhiko/rye\n* https://github.com/goerz/python-localvenv-kernel\n* Poetry-kernel: https://github.com/pathbird/poetry-kernel\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python Jupyter kernel using pyproject environment manangers like Rye, PDM, Poetry, Hatch etc.",
    "version": "0.5.5",
    "project_urls": {
        "Repository": "https://github.com/bluss/pyproject-local-kernel"
    },
    "split_keywords": [
        "interactive",
        " interpreter",
        " jupyter",
        " pyproject"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "818bf4056bcc8a017f5c3794a215cc8dedc64ac5f6e09a9ab585b9f02594d656",
                "md5": "baac4bb1ee3d5d63cc2a764a8dae0db3",
                "sha256": "009281d9c23acdafee34960bb80ccba1f4bce00a43ca56138458afae6bc62a48"
            },
            "downloads": -1,
            "filename": "pyproject_local_kernel-0.5.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "baac4bb1ee3d5d63cc2a764a8dae0db3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8261,
            "upload_time": "2024-04-01T13:12:12",
            "upload_time_iso_8601": "2024-04-01T13:12:12.616183Z",
            "url": "https://files.pythonhosted.org/packages/81/8b/f4056bcc8a017f5c3794a215cc8dedc64ac5f6e09a9ab585b9f02594d656/pyproject_local_kernel-0.5.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97a5418b477e09eec1238b584ac7d67799270ade07e4d29ed86994b23fbc2f8b",
                "md5": "c49d456d4ba9330fbc054a97a2f11e17",
                "sha256": "b31ac8b5026d20a894c5e50d06384fa94ccade9a9bbf00ab50abab889393b8f0"
            },
            "downloads": -1,
            "filename": "pyproject_local_kernel-0.5.5.tar.gz",
            "has_sig": false,
            "md5_digest": "c49d456d4ba9330fbc054a97a2f11e17",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9893,
            "upload_time": "2024-04-01T13:12:13",
            "upload_time_iso_8601": "2024-04-01T13:12:13.807708Z",
            "url": "https://files.pythonhosted.org/packages/97/a5/418b477e09eec1238b584ac7d67799270ade07e4d29ed86994b23fbc2f8b/pyproject_local_kernel-0.5.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-01 13:12:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bluss",
    "github_project": "pyproject-local-kernel",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyproject-local-kernel"
}
        
Elapsed time: 0.23245s