WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 8f26414

Browse files
CopilotBordawillingc
authored
Modernize packaging to use pyproject.toml (#837)
* Initial plan * Migrate packaging configuration to pyproject.toml Co-authored-by: Borda <[email protected]> * Update tox dist command to use python -m build instead of setup.py Co-authored-by: Borda <[email protected]> * Update documentation to use pyproject.toml instead of setup.py Co-authored-by: Borda <[email protected]> * Remove legacy configuration files (setup.py, pytest.ini, tox.ini, .bumpversion.cfg) Co-authored-by: Borda <[email protected]> * Remove ansicolors dependency and add hdfs to dev/test extras Co-authored-by: willingc <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Borda <[email protected]> Co-authored-by: willingc <[email protected]>
1 parent 6ad6038 commit 8f26414

File tree

8 files changed

+305
-232
lines changed

8 files changed

+305
-232
lines changed

.bumpversion.cfg

Lines changed: 0 additions & 7 deletions
This file was deleted.

DEVELOPMENT_GUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ git push upstream && git push upstream --tags
7373
```bash
7474
rm -rf dist/*
7575
rm -rf build/*
76-
python setup.py sdist bdist_wheel
76+
python -m build
7777
twine upload dist/*
7878
```

MANIFEST.in

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@ recursive-include papermill *.yml
66
recursive-include papermill *.keep
77
recursive-include papermill *.txt
88

9-
include setup.py
109
include requirements.txt
1110
recursive-include requirements *.txt
12-
include tox.ini
13-
include pytest.ini
1411
include README.md
1512
include LICENSE
1613
include MANIFEST.in
1714
include *.md
1815
include *.toml
1916

20-
include .bumpversion.cfg
21-
2217
# Documentation
2318
prune docs
2419

docs/extending-entry-points.rst

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,15 @@ Ensuring your handler is found by papermill
5151
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5252

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

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

59-
.. code-block:: python
59+
.. code-block:: toml
6060
61-
from setuptools import setup, find_packages
62-
setup(
63-
# all the normal setup.py arguments...
64-
entry_points={"papermill.io": ["sftp://=papermill_sftp:SFTPHandler"]},
65-
)
61+
[project.entry-points."papermill.io"]
62+
"sftp://" = "papermill_sftp:SFTPHandler"
6663
6764
This indicates to papermill that when a file path begins with ``sftp://``, it
6865
should use the class ``papermill_sftp.SFTPHandler`` to handle reading or writing
@@ -84,7 +81,7 @@ from an sftp server and writes back to it, so we could do the following::
8481
Our project structure will look like this::
8582

8683
papermill_sftp
87-
|- setup.py
84+
|- pyproject.toml
8885
|- src
8986
|- papermill_sftp
9087
|- __init__.py
@@ -153,24 +150,32 @@ implement a listdir option for now.
153150
raise NotImplementedError
154151
155152
156-
The ``setup.py`` file contains the following code:
153+
The ``pyproject.toml`` file contains the following code:
157154

158-
.. code-block:: python
155+
.. code-block:: toml
156+
157+
[build-system]
158+
requires = ["setuptools>=61.0", "wheel"]
159+
build-backend = "setuptools.build_meta"
160+
161+
[project]
162+
name = "papermill_sftp"
163+
version = "0.1"
164+
description = "An SFTP I/O handler for papermill."
165+
authors = [
166+
{name = "My Name", email = "[email protected]"}
167+
]
168+
dependencies = ["pysftp"]
169+
170+
[project.urls]
171+
Repository = "https://github.com/my_username/papermill_sftp.git"
172+
173+
[project.entry-points."papermill.io"]
174+
"sftp://" = "papermill_sftp:SFTPHandler"
159175
160-
from setuptools import setup, find_packages
161-
162-
setup(
163-
name="papermill_sftp",
164-
version="0.1",
165-
url="https://github.com/my_username/papermill_sftp.git",
166-
author="My Name",
167-
author_email="[email protected]",
168-
description="An SFTP I/O handler for papermill.",
169-
packages=find_packages("./src"),
170-
package_dir={"": "src"},
171-
install_requires=["pysftp"],
172-
entry_points={"papermill.io": ["sftp://=papermill_sftp:SFTPHandler"]},
173-
)
176+
[tool.setuptools]
177+
packages = ["papermill_sftp"]
178+
package-dir = {"" = "src"}
174179
175180
When executing, papermill will check if the input or output path begin with
176181
``sftp://``, and if so, use the SFTPHandler from the papermill_sftp project.
@@ -214,7 +219,7 @@ time it took to execute each cell as additional output after every code cell.
214219
The project structure is::
215220

216221
papermill_timing
217-
|- setup.py
222+
|- pyproject.toml
218223
|- src
219224
|- papermill_timing
220225
|- __init__.py
@@ -249,33 +254,41 @@ library to create a `notebook node object`_.
249254
cell.outputs = [output_node] + cell.outputs
250255
251256
Once this is in place, we need to add our engine as an entry point to our
252-
``setup.py`` script - for this, see the following section.
257+
``pyproject.toml`` file - for this, see the following section.
253258

254259
Ensuring your engine is found by papermill
255260
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
256261

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

263-
.. code-block:: python
268+
.. code-block:: toml
269+
270+
[build-system]
271+
requires = ["setuptools>=61.0", "wheel"]
272+
build-backend = "setuptools.build_meta"
273+
274+
[project]
275+
name = "papermill_timing"
276+
version = "0.1"
277+
description = "A papermill engine that logs additional timing information about code."
278+
authors = [
279+
{name = "My Name", email = "[email protected]"}
280+
]
281+
dependencies = ["papermill", "nbformat"]
282+
283+
[project.urls]
284+
Repository = "https://github.com/my_username/papermill_timing.git"
285+
286+
[project.entry-points."papermill.engine"]
287+
timer_engine = "papermill_timing:CustomEngine"
264288
265-
from setuptools import setup, find_packages
266-
267-
setup(
268-
name="papermill_timing",
269-
version="0.1",
270-
url="https://github.com/my_username/papermill_timing.git",
271-
author="My Name",
272-
author_email="[email protected]",
273-
description="A papermill engine that logs additional timing information about code.",
274-
packages=find_packages("./src"),
275-
package_dir={"": "src"},
276-
install_requires=["papermill", "nbformat"],
277-
entry_points={"papermill.engine": ["timer_engine=papermill_timing:CustomEngine"]},
278-
)
289+
[tool.setuptools]
290+
packages = ["papermill_timing"]
291+
package-dir = {"" = "src"}
279292
280293
This allows users to specify the engine from ``papermill_timing`` by passing the
281294
command line argument ``--engine timer_engine``.

0 commit comments

Comments
 (0)