Skip to content

Commit 196f019

Browse files
authored
Replace entrypoint example with pyproject.toml in docs (#10359)
Fixes #10344
1 parent 3bf2bc5 commit 196f019

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ Victor Uriarte
356356
Vidar T. Fauske
357357
Virgil Dupras
358358
Vitaly Lashmanov
359+
Vivaan Verma
359360
Vlad Dragos
360361
Vlad Radziuk
361362
Vladyslav Rachek

changelog/10344.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update information on writing plugins to use ``pyproject.toml`` instead of ``setup.py``.

doc/en/how-to/writing_plugins.rst

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -147,27 +147,33 @@ Making your plugin installable by others
147147

148148
If you want to make your plugin externally available, you
149149
may define a so-called entry point for your distribution so
150-
that ``pytest`` finds your plugin module. Entry points are
151-
a feature that is provided by :std:doc:`setuptools:index`. pytest looks up
152-
the ``pytest11`` entrypoint to discover its
153-
plugins and you can thus make your plugin available by defining
154-
it in your setuptools-invocation:
150+
that ``pytest`` finds your plugin module. Entry points are
151+
a feature that is provided by :std:doc:`setuptools <setuptools:index>`.
155152

156-
.. sourcecode:: python
153+
pytest looks up the ``pytest11`` entrypoint to discover its
154+
plugins, thus you can make your plugin available by defining
155+
it in your ``pyproject.toml`` file.
156+
157+
.. sourcecode:: toml
158+
159+
# sample ./pyproject.toml file
160+
[build-system]
161+
requires = ["hatchling"]
162+
build-backend = "hatchling.build"
157163

158-
# sample ./setup.py file
159-
from setuptools import setup
164+
[project]
165+
name = "myproject"
166+
classifiers = [
167+
"Framework :: Pytest",
168+
]
160169

170+
[tool.setuptools]
171+
packages = ["myproject"]
161172

162-
name_of_plugin = "myproject" # register plugin with this name
163-
setup(
164-
name="myproject",
165-
packages=["myproject"],
166-
# the following makes a plugin available to pytest
167-
entry_points={"pytest11": [f"{name_of_plugin} = myproject.pluginmodule"]},
168-
# custom PyPI classifier for pytest plugins
169-
classifiers=["Framework :: Pytest"],
170-
)
173+
[project.entry_points]
174+
pytest11 = [
175+
"myproject = myproject.pluginmodule",
176+
]
171177

172178
If a package is installed this way, ``pytest`` will load
173179
``myproject.pluginmodule`` as a plugin which can define

0 commit comments

Comments
 (0)