Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .bumpversion.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion DEVELOPMENT_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ git push upstream && git push upstream --tags
```bash
rm -rf dist/*
rm -rf build/*
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
```
5 changes: 0 additions & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ recursive-include papermill *.yml
recursive-include papermill *.keep
recursive-include papermill *.txt

include setup.py
include requirements.txt
recursive-include requirements *.txt
include tox.ini
include pytest.ini
include README.md
include LICENSE
include MANIFEST.in
include *.md
include *.toml

include .bumpversion.cfg

# Documentation
prune docs

Expand Down
101 changes: 57 additions & 44 deletions docs/extending-entry-points.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,15 @@ Ensuring your handler is found by papermill
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Once you have developed a new handler, you need to declare papermill entry
points in your ``setup.py`` file.
points in your ``pyproject.toml`` file.

This is done by including the ``entry_points`` key-word argument to ``setup``
in your setup.py file:
This is done by including the ``[project.entry-points."papermill.io"]`` section
in your pyproject.toml file:

.. code-block:: python
.. code-block:: toml

from setuptools import setup, find_packages
setup(
# all the normal setup.py arguments...
entry_points={"papermill.io": ["sftp://=papermill_sftp:SFTPHandler"]},
)
[project.entry-points."papermill.io"]
"sftp://" = "papermill_sftp:SFTPHandler"

This indicates to papermill that when a file path begins with ``sftp://``, it
should use the class ``papermill_sftp.SFTPHandler`` to handle reading or writing
Expand All @@ -84,7 +81,7 @@ from an sftp server and writes back to it, so we could do the following::
Our project structure will look like this::

papermill_sftp
|- setup.py
|- pyproject.toml
|- src
|- papermill_sftp
|- __init__.py
Expand Down Expand Up @@ -153,24 +150,32 @@ implement a listdir option for now.
raise NotImplementedError


The ``setup.py`` file contains the following code:
The ``pyproject.toml`` file contains the following code:

.. code-block:: python
.. code-block:: toml

[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "papermill_sftp"
version = "0.1"
description = "An SFTP I/O handler for papermill."
authors = [
{name = "My Name", email = "[email protected]"}
]
dependencies = ["pysftp"]

[project.urls]
Repository = "https://github.com/my_username/papermill_sftp.git"

[project.entry-points."papermill.io"]
"sftp://" = "papermill_sftp:SFTPHandler"

from setuptools import setup, find_packages

setup(
name="papermill_sftp",
version="0.1",
url="https://github.com/my_username/papermill_sftp.git",
author="My Name",
author_email="[email protected]",
description="An SFTP I/O handler for papermill.",
packages=find_packages("./src"),
package_dir={"": "src"},
install_requires=["pysftp"],
entry_points={"papermill.io": ["sftp://=papermill_sftp:SFTPHandler"]},
)
[tool.setuptools]
packages = ["papermill_sftp"]
package-dir = {"" = "src"}

When executing, papermill will check if the input or output path begin with
``sftp://``, and if so, use the SFTPHandler from the papermill_sftp project.
Expand Down Expand Up @@ -214,7 +219,7 @@ time it took to execute each cell as additional output after every code cell.
The project structure is::

papermill_timing
|- setup.py
|- pyproject.toml
|- src
|- papermill_timing
|- __init__.py
Expand Down Expand Up @@ -249,33 +254,41 @@ library to create a `notebook node object`_.
cell.outputs = [output_node] + cell.outputs

Once this is in place, we need to add our engine as an entry point to our
``setup.py`` script - for this, see the following section.
``pyproject.toml`` file - for this, see the following section.

Ensuring your engine is found by papermill
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Custom engines can be specified as `entry points`_, under the
``papermill.engine`` prefix. The entry point needs to reference the class that
we have just implemented. For example, if you write an engine called
TimingEngine in a package called papermill_timing, then in the ``setup.py``
TimingEngine in a package called papermill_timing, then in the ``pyproject.toml``
file, you should specify:

.. code-block:: python
.. code-block:: toml

[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "papermill_timing"
version = "0.1"
description = "A papermill engine that logs additional timing information about code."
authors = [
{name = "My Name", email = "[email protected]"}
]
dependencies = ["papermill", "nbformat"]

[project.urls]
Repository = "https://github.com/my_username/papermill_timing.git"

[project.entry-points."papermill.engine"]
timer_engine = "papermill_timing:CustomEngine"

from setuptools import setup, find_packages

setup(
name="papermill_timing",
version="0.1",
url="https://github.com/my_username/papermill_timing.git",
author="My Name",
author_email="[email protected]",
description="A papermill engine that logs additional timing information about code.",
packages=find_packages("./src"),
package_dir={"": "src"},
install_requires=["papermill", "nbformat"],
entry_points={"papermill.engine": ["timer_engine=papermill_timing:CustomEngine"]},
)
[tool.setuptools]
packages = ["papermill_timing"]
package-dir = {"" = "src"}

This allows users to specify the engine from ``papermill_timing`` by passing the
command line argument ``--engine timer_engine``.
Expand Down
Loading
Loading