poetry-kernel


Namepoetry-kernel JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/pathbird/poetry-kernel
SummaryPython Jupyter kernel using Poetry for dependency management
upload_time2023-08-04 22:49:51
maintainer
docs_urlNone
authorPathbird Inc
requires_python>=3.7
licenseMIT
keywords interactive interpreter shell web
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Poetry Kernel

Use per-directory Poetry environments to run Jupyter kernels. No need to install
a Jupyter kernel per Python virtual environment!

The idea behind this project is to allow you to capture the exact state of your
environment. This means you can email your work to your peers, and they'll have
_exactly_ the same set of packages that you do! Reproducibility!

## Why not virtual environments (venvs)?

Virtual environments were (and are) an important advancement to Python's package
management story, but they have a few shortcomings:

- They are not great for reproducibility. Usually, you'll create a new virtual
  environment using a `requirements.txt` which includes all the direct
  dependencies (numpy, pandas, etc.), but not transient dependencies (pandas
  depends on pytz for timezone support, for example). And usually, even the
  direct dependencies are specified only as minimum (or semver) ranges (e.g.,
  `numpy>=1.21`) which can make it hard or impossible to accurately recreate the
  `venv` later.
- With Jupyter, they usually require that the kernels be installed globally.
  This means you'll need need to have a separate kernelspec for every venv you
  want to use with Jupyter.

Poetry uses venvs transparently under the hood by constructing them from the
`pyproject.toml` and `poetry.lock` files. The `poetry.lock` file records the
exact state of dependencies (and transient dependencies) and can be used to more
accurately reproduce the environment.

Additionally, Poetry Kernel means you only have to install one kernelspec. It
then uses the `pyproject.toml` file from the directory of the notebook (or any
parent directory) to choose which environment to run the notebook in.

## Shameless plug

The reason we created this package was to make sure that the code environments
created for running student code on Pathbird exactly match your development
environment. Interested in developing interactive, engaging, inquiry-based
lessons for your students?
[Check out Pathbird for more information!](https://pathbird.com/)

# Usage

1. [Install Poetry](https://python-poetry.org/docs/#installation) if not yet
   installed.
1. Install this package:
   ```sh
   # NOTE: Do **NOT** install this package in your Poetry project, it should be
   # installed at the system or user level.
   pip3 install --user poetry-kernel
   ```
1. Initialize a Poetry project (only required if you do not have an existing
   Poetry project ready to use):
   ```sh
   poetry init -n
   ```
1. **IMPORTANT:** Add `ipykernel` to your project's dependencies:
   ```sh
   # In the directory of your Poetry project
   poetry add ipykernel
   ```
1. Start a "Poetry" Jupyter kernel and see it in action!
   ![Jupyter launcher screenshot](.static/jupyter-screenshot.png)

# Troubleshooting

## Kernel isn't starting ("No Kernel" message)

**Pro-tip:** Check the output of the terminal window where you launched Jupyter.
It will usually explain why the kernel is failing to start.

1. Make sure that you are launching a notebook in a directory/folder that
   contains a Poetry project (`pyproject.toml` and `poetry.lock` files). You can
   turn a directory into a Poetry project by running:

```sh
poetry init -n
```

2. Make sure that you've installed `ipykernel` into your project:

```sh
poetry add ipykernel
```

3. Make sure the Poetry project is installed! This is especially important for
   projects that you have downloaded from others (**warning:** installing a
   Poetry project could run arbitrary code on your computer, make sure you trust
   your download first!):

   ```sh
   poetry install
   ```

4. Still can't figure it out? Open an issue!

## A package I added won't import properly

If you added the package **after** starting the kernel, you might need to
restart the kernel for it to see the new package.

# FAQ

[See FAQ.md.](FAQ.md)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pathbird/poetry-kernel",
    "name": "poetry-kernel",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "Interactive,Interpreter,Shell,Web",
    "author": "Pathbird Inc",
    "author_email": "oss@pathbird.com",
    "download_url": "https://files.pythonhosted.org/packages/be/4d/5ad6340a3c1ffaccb1d58067a6af079eed2d4190a80ebab2d1f2b543f14d/poetry-kernel-0.1.3.tar.gz",
    "platform": null,
    "description": "# Poetry Kernel\n\nUse per-directory Poetry environments to run Jupyter kernels. No need to install\na Jupyter kernel per Python virtual environment!\n\nThe idea behind this project is to allow you to capture the exact state of your\nenvironment. This means you can email your work to your peers, and they'll have\n_exactly_ the same set of packages that you do! Reproducibility!\n\n## Why not virtual environments (venvs)?\n\nVirtual environments were (and are) an important advancement to Python's package\nmanagement story, but they have a few shortcomings:\n\n- They are not great for reproducibility. Usually, you'll create a new virtual\n  environment using a `requirements.txt` which includes all the direct\n  dependencies (numpy, pandas, etc.), but not transient dependencies (pandas\n  depends on pytz for timezone support, for example). And usually, even the\n  direct dependencies are specified only as minimum (or semver) ranges (e.g.,\n  `numpy>=1.21`) which can make it hard or impossible to accurately recreate the\n  `venv` later.\n- With Jupyter, they usually require that the kernels be installed globally.\n  This means you'll need need to have a separate kernelspec for every venv you\n  want to use with Jupyter.\n\nPoetry uses venvs transparently under the hood by constructing them from the\n`pyproject.toml` and `poetry.lock` files. The `poetry.lock` file records the\nexact state of dependencies (and transient dependencies) and can be used to more\naccurately reproduce the environment.\n\nAdditionally, Poetry Kernel means you only have to install one kernelspec. It\nthen uses the `pyproject.toml` file from the directory of the notebook (or any\nparent directory) to choose which environment to run the notebook in.\n\n## Shameless plug\n\nThe reason we created this package was to make sure that the code environments\ncreated for running student code on Pathbird exactly match your development\nenvironment. Interested in developing interactive, engaging, inquiry-based\nlessons for your students?\n[Check out Pathbird for more information!](https://pathbird.com/)\n\n# Usage\n\n1. [Install Poetry](https://python-poetry.org/docs/#installation) if not yet\n   installed.\n1. Install this package:\n   ```sh\n   # NOTE: Do **NOT** install this package in your Poetry project, it should be\n   # installed at the system or user level.\n   pip3 install --user poetry-kernel\n   ```\n1. Initialize a Poetry project (only required if you do not have an existing\n   Poetry project ready to use):\n   ```sh\n   poetry init -n\n   ```\n1. **IMPORTANT:** Add `ipykernel` to your project's dependencies:\n   ```sh\n   # In the directory of your Poetry project\n   poetry add ipykernel\n   ```\n1. Start a \"Poetry\" Jupyter kernel and see it in action!\n   ![Jupyter launcher screenshot](.static/jupyter-screenshot.png)\n\n# Troubleshooting\n\n## Kernel isn't starting (\"No Kernel\" message)\n\n**Pro-tip:** Check the output of the terminal window where you launched Jupyter.\nIt will usually explain why the kernel is failing to start.\n\n1. Make sure that you are launching a notebook in a directory/folder that\n   contains a Poetry project (`pyproject.toml` and `poetry.lock` files). You can\n   turn a directory into a Poetry project by running:\n\n```sh\npoetry init -n\n```\n\n2. Make sure that you've installed `ipykernel` into your project:\n\n```sh\npoetry add ipykernel\n```\n\n3. Make sure the Poetry project is installed! This is especially important for\n   projects that you have downloaded from others (**warning:** installing a\n   Poetry project could run arbitrary code on your computer, make sure you trust\n   your download first!):\n\n   ```sh\n   poetry install\n   ```\n\n4. Still can't figure it out? Open an issue!\n\n## A package I added won't import properly\n\nIf you added the package **after** starting the kernel, you might need to\nrestart the kernel for it to see the new package.\n\n# FAQ\n\n[See FAQ.md.](FAQ.md)\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python Jupyter kernel using Poetry for dependency management",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/pathbird/poetry-kernel"
    },
    "split_keywords": [
        "interactive",
        "interpreter",
        "shell",
        "web"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af273c03d7ae193f089ca0232fd11a2bda119bc2c4f68675fa6ecd8503161360",
                "md5": "c0ce097710f0ba9bb48aef852721d6ff",
                "sha256": "1722d057a716d7bfc4cc763809e5f5cd5c859c8767ecffc67a5e017768fa9caa"
            },
            "downloads": -1,
            "filename": "poetry_kernel-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c0ce097710f0ba9bb48aef852721d6ff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5975,
            "upload_time": "2023-08-04T22:49:50",
            "upload_time_iso_8601": "2023-08-04T22:49:50.172039Z",
            "url": "https://files.pythonhosted.org/packages/af/27/3c03d7ae193f089ca0232fd11a2bda119bc2c4f68675fa6ecd8503161360/poetry_kernel-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "be4d5ad6340a3c1ffaccb1d58067a6af079eed2d4190a80ebab2d1f2b543f14d",
                "md5": "7d938d46277a93b16e08dc456bee8d4b",
                "sha256": "a586631fca31185dbb5f4b8e88a8a30b00bf857b6bc5935b277cfe4f48e90f27"
            },
            "downloads": -1,
            "filename": "poetry-kernel-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7d938d46277a93b16e08dc456bee8d4b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5557,
            "upload_time": "2023-08-04T22:49:51",
            "upload_time_iso_8601": "2023-08-04T22:49:51.655196Z",
            "url": "https://files.pythonhosted.org/packages/be/4d/5ad6340a3c1ffaccb1d58067a6af079eed2d4190a80ebab2d1f2b543f14d/poetry-kernel-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-04 22:49:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pathbird",
    "github_project": "poetry-kernel",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "poetry-kernel"
}
        
Elapsed time: 0.11987s