Skip to content

Commit

Permalink
Replace entrypoint example with pyproject.toml in docs (#10359)
Browse files Browse the repository at this point in the history
Fixes #10344
  • Loading branch information
doublevcodes authored Oct 9, 2022
1 parent 3bf2bc5 commit 196f019
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ Victor Uriarte
Vidar T. Fauske
Virgil Dupras
Vitaly Lashmanov
Vivaan Verma
Vlad Dragos
Vlad Radziuk
Vladyslav Rachek
Expand Down
1 change: 1 addition & 0 deletions changelog/10344.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update information on writing plugins to use ``pyproject.toml`` instead of ``setup.py``.
40 changes: 23 additions & 17 deletions doc/en/how-to/writing_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <setuptools:index>`.

.. 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
Expand Down

0 comments on commit 196f019

Please sign in to comment.