docs: update plugin docs to use pyproject.toml

This commit is contained in:
Vivaan Verma 2022-10-09 16:01:03 +00:00
parent 571dc6b220
commit ee6183348a
1 changed files with 18 additions and 13 deletions

View File

@ -151,23 +151,28 @@ 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:index`. pytest looks up
the ``pytest11`` entrypoint to discover its the ``pytest11`` entrypoint to discover its
plugins and you can thus make your plugin available by defining plugins and you can thus make your plugin available by defining
it in your setuptools-invocation: it in your ``pyproject.toml`` file.
.. sourcecode:: python .. sourcecode:: toml
# sample ./setup.py file # sample ./pyproject.toml file
from setuptools import setup [build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "myproject"
classifiers = [
"Framework :: Pytest",
]
name_of_plugin = "myproject" # register plugin with this name [tool.setuptools]
setup( packages = ["myproject"]
name="myproject",
packages=["myproject"], [project.entry_points]
# the following makes a plugin available to pytest pytest11 = [
entry_points={"pytest11": [f"{name_of_plugin} = myproject.pluginmodule"]}, "myproject = myproject.pluginmodule",
# custom PyPI classifier for pytest plugins ]
classifiers=["Framework :: Pytest"],
)
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