Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace entrypoint example with pyproject.toml in docs #10359

Merged
merged 5 commits into from Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
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
@@ -0,0 +1 @@
Update information on writing plugins to use ``pyproject.toml`` instead of ``setup.py``.
31 changes: 18 additions & 13 deletions doc/en/how-to/writing_plugins.rst
Expand Up @@ -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
the ``pytest11`` entrypoint to discover its
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 ./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