Replace entrypoint example with `pyproject.toml` in docs (#10359)

Fixes #10344
This commit is contained in:
Vivaan Verma 2022-10-09 21:42:42 +01:00 committed by GitHub
parent 3bf2bc55b1
commit 196f01965e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 17 deletions

View File

@ -356,6 +356,7 @@ Victor Uriarte
Vidar T. Fauske Vidar T. Fauske
Virgil Dupras Virgil Dupras
Vitaly Lashmanov Vitaly Lashmanov
Vivaan Verma
Vlad Dragos Vlad Dragos
Vlad Radziuk Vlad Radziuk
Vladyslav Rachek Vladyslav Rachek

1
changelog/10344.doc.rst Normal file
View File

@ -0,0 +1 @@
Update information on writing plugins to use ``pyproject.toml`` instead of ``setup.py``.

View File

@ -147,27 +147,33 @@ Making your plugin installable by others
If you want to make your plugin externally available, you If you want to make your plugin externally available, you
may define a so-called entry point for your distribution so may define a so-called entry point for your distribution so
that ``pytest`` finds your plugin module. Entry points are that ``pytest`` finds your plugin module. Entry points are
a feature that is provided by :std:doc:`setuptools:index`. pytest looks up a feature that is provided by :std:doc:`setuptools <setuptools:index>`.
the ``pytest11`` entrypoint to discover its
plugins and you can thus make your plugin available by defining
it in your setuptools-invocation:
.. 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.
# sample ./setup.py file .. sourcecode:: toml
from setuptools import setup
# sample ./pyproject.toml file
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
name_of_plugin = "myproject" # register plugin with this name [project]
setup( name = "myproject"
name="myproject", classifiers = [
packages=["myproject"], "Framework :: Pytest",
# the following makes a plugin available to pytest ]
entry_points={"pytest11": [f"{name_of_plugin} = myproject.pluginmodule"]},
# custom PyPI classifier for pytest plugins [tool.setuptools]
classifiers=["Framework :: Pytest"], packages = ["myproject"]
)
[project.entry_points]
pytest11 = [
"myproject = myproject.pluginmodule",
]
If a package is installed this way, ``pytest`` will load If a package is installed this way, ``pytest`` will load
``myproject.pluginmodule`` as a plugin which can define ``myproject.pluginmodule`` as a plugin which can define