From 196f01965ed264e1fd917db236c872f85403753d Mon Sep 17 00:00:00 2001 From: Vivaan Verma Date: Sun, 9 Oct 2022 21:42:42 +0100 Subject: [PATCH] Replace entrypoint example with `pyproject.toml` in docs (#10359) Fixes #10344 --- AUTHORS | 1 + changelog/10344.doc.rst | 1 + doc/en/how-to/writing_plugins.rst | 40 ++++++++++++++++++------------- 3 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 changelog/10344.doc.rst diff --git a/AUTHORS b/AUTHORS index ca2872f32a4..4e15caf8e90 100644 --- a/AUTHORS +++ b/AUTHORS @@ -356,6 +356,7 @@ Victor Uriarte Vidar T. Fauske Virgil Dupras Vitaly Lashmanov +Vivaan Verma Vlad Dragos Vlad Radziuk Vladyslav Rachek diff --git a/changelog/10344.doc.rst b/changelog/10344.doc.rst new file mode 100644 index 00000000000..1c7885edc20 --- /dev/null +++ b/changelog/10344.doc.rst @@ -0,0 +1 @@ +Update information on writing plugins to use ``pyproject.toml`` instead of ``setup.py``. diff --git a/doc/en/how-to/writing_plugins.rst b/doc/en/how-to/writing_plugins.rst index 2fbf49718ce..f15b69c2317 100644 --- a/doc/en/how-to/writing_plugins.rst +++ b/doc/en/how-to/writing_plugins.rst @@ -147,27 +147,33 @@ Making your plugin installable by others If you want to make your plugin externally available, you may define a so-called entry point for your distribution so -that ``pytest`` finds your plugin module. Entry points are -a feature that is provided by :std:doc:`setuptools:index`. pytest looks up -the ``pytest11`` entrypoint to discover its -plugins and you can thus make your plugin available by defining -it in your setuptools-invocation: +that ``pytest`` finds your plugin module. Entry points are +a feature that is provided by :std:doc:`setuptools `. -.. sourcecode:: python +pytest looks up the ``pytest11`` entrypoint to discover its +plugins, thus you can make your plugin available by defining +it in your ``pyproject.toml`` file. + +.. sourcecode:: toml + + # sample ./pyproject.toml file + [build-system] + requires = ["hatchling"] + build-backend = "hatchling.build" - # sample ./setup.py file - from setuptools import setup + [project] + name = "myproject" + classifiers = [ + "Framework :: Pytest", + ] + [tool.setuptools] + packages = ["myproject"] - name_of_plugin = "myproject" # register plugin with this name - setup( - name="myproject", - packages=["myproject"], - # the following makes a plugin available to pytest - entry_points={"pytest11": [f"{name_of_plugin} = myproject.pluginmodule"]}, - # custom PyPI classifier for pytest plugins - classifiers=["Framework :: Pytest"], - ) + [project.entry_points] + pytest11 = [ + "myproject = myproject.pluginmodule", + ] If a package is installed this way, ``pytest`` will load ``myproject.pluginmodule`` as a plugin which can define