Skip to content

Commit a604ff0

Browse files
committed
📝 Make "setuptools entrypoint" term generic
This feature grew out of `setuptools` but the modern interface for extracting this information from the distribution package metadata is `importlib.metadata`. So the patch attempts to reflect this in the documentation messaging. Refs: * https://docs.python.org/3/library/importlib.metadata.html#entry-points * https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/#using-package-metadata * https://packaging.python.org/en/latest/specifications/entry-points/#entry-points
1 parent fe4961a commit a604ff0

File tree

10 files changed

+28
-21
lines changed

10 files changed

+28
-21
lines changed

doc/en/example/simple.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ the command line arguments before they get processed:
212212

213213
.. code-block:: python
214214
215-
# setuptools plugin
215+
# installable external plugin
216216
import sys
217217
218218
@@ -1073,8 +1073,8 @@ Instead of freezing the pytest runner as a separate executable, you can make
10731073
your frozen program work as the pytest runner by some clever
10741074
argument handling during program startup. This allows you to
10751075
have a single executable, which is usually more convenient.
1076-
Please note that the mechanism for plugin discovery used by pytest
1077-
(setuptools entry points) doesn't work with frozen executables so pytest
1076+
Please note that the mechanism for plugin discovery used by pytest (`entry points
1077+
<pip-installable plugins>`_) doesn't work with frozen executables so pytest
10781078
can't find any third party plugins automatically. To include third party plugins
10791079
like ``pytest-timeout`` they must be imported explicitly and passed on to pytest.main.
10801080

doc/en/how-to/fixtures.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,7 @@ The same applies for the test folder level obviously.
19311931
Using fixtures from other projects
19321932
----------------------------------
19331933

1934-
Usually projects that provide pytest support will use :ref:`entry points <setuptools entry points>`,
1934+
Usually projects that provide pytest support will use :ref:`entry points <pip-installable plugins>`,
19351935
so just installing those projects into an environment will make those fixtures available for use.
19361936

19371937
In case you want to use fixtures from a project that does not use entry points, you can

doc/en/how-to/usage.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ You can early-load plugins (internal and external) explicitly in the command-lin
154154
The option receives a ``name`` parameter, which can be:
155155

156156
* A full module dotted name, for example ``myproject.plugins``. This dotted name must be importable.
157-
* The entry-point name of a plugin. This is the name passed to ``setuptools`` when the plugin is
157+
* The entry-point name of a plugin. This is the name passed to ``importlib`` when the plugin is
158158
registered. For example to early-load the :pypi:`pytest-cov` plugin you can use::
159159

160160
pytest -p pytest_cov

doc/en/how-to/writing_plugins.rst

+9-6
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ reporting by calling :ref:`well specified hooks <hook-reference>` of the followi
1616

1717
* builtin plugins: loaded from pytest's internal ``_pytest`` directory.
1818

19-
* :ref:`external plugins <extplugins>`: modules discovered through
20-
`setuptools entry points`_
19+
* :ref:`external plugins <extplugins>`: installed third-party modules discovered through
20+
`entry points <pip-installable plugins>`_ in their packaging metadata
2121

2222
* `conftest.py plugins`_: modules auto-discovered in test directories
2323

@@ -42,7 +42,8 @@ Plugin discovery order at tool startup
4242
3. by scanning the command line for the ``-p name`` option
4343
and loading the specified plugin. This happens before normal command-line parsing.
4444

45-
4. by loading all plugins registered through `setuptools entry points`_.
45+
4. by loading all plugins registered through installed third-party package
46+
`entry points <pip-installable plugins>`_.
4647

4748
5. by loading all plugins specified through the :envvar:`PYTEST_PLUGINS` environment variable.
4849

@@ -142,7 +143,8 @@ Making your plugin installable by others
142143
If you want to make your plugin externally available, you
143144
may define a so-called entry point for your distribution so
144145
that ``pytest`` finds your plugin module. Entry points are
145-
a feature that is provided by :std:doc:`setuptools <setuptools:index>`.
146+
a feature that is provided by :std:doc:`packaging tools
147+
<packaging:specifications/entry-points>`.
146148

147149
pytest looks up the ``pytest11`` entrypoint to discover its
148150
plugins, thus you can make your plugin available by defining
@@ -265,8 +267,9 @@ of the variable will also be loaded as plugins, and so on.
265267
tests root directory is deprecated, and will raise a warning.
266268

267269
This mechanism makes it easy to share fixtures within applications or even
268-
external applications without the need to create external plugins using
269-
the ``setuptools``'s entry point technique.
270+
external applications without the need to create external plugins using the
271+
:std:doc:`entry point packaging metadata <guides/creating-and-discovering-plugins>`
272+
technique.
270273

271274
Plugins imported by :globalvar:`pytest_plugins` will also automatically be marked
272275
for assertion rewriting (see :func:`pytest.register_assert_rewrite`).

doc/en/reference/customize.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ and can also be used to hold pytest configuration if they have a ``[pytest]`` se
9090
setup.cfg
9191
~~~~~~~~~
9292

93-
``setup.cfg`` files are general purpose configuration files, used originally by ``distutils`` (now deprecated) and `setuptools <https://setuptools.pypa.io/en/latest/userguide/declarative_config.html>`__, and can also be used to hold pytest configuration
93+
``setup.cfg`` files are general purpose configuration files, used originally by ``distutils`` (now deprecated) and :std:doc:`setuptools <setuptools:userguide/declarative_config>`, and can also be used to hold pytest configuration
9494
if they have a ``[tool:pytest]`` section.
9595

9696
.. code-block:: ini

doc/en/reference/reference.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ Reference to all hooks which can be implemented by :ref:`conftest.py files <loca
650650
Bootstrapping hooks
651651
~~~~~~~~~~~~~~~~~~~
652652

653-
Bootstrapping hooks called for plugins registered early enough (internal and setuptools plugins).
653+
Bootstrapping hooks called for plugins registered early enough (internal and third-party plugins).
654654

655655
.. hook:: pytest_load_initial_conftests
656656
.. autofunction:: pytest_load_initial_conftests
@@ -1147,8 +1147,9 @@ When set, pytest will print tracing and debug information.
11471147

11481148
.. envvar:: PYTEST_DISABLE_PLUGIN_AUTOLOAD
11491149

1150-
When set, disables plugin auto-loading through setuptools entrypoints. Only explicitly specified plugins will be
1151-
loaded.
1150+
When set, disables plugin auto-loading through :std:doc:`entry point packaging
1151+
metadata <guides/creating-and-discovering-plugins>`. Only explicitly specified
1152+
plugins will be loaded.
11521153

11531154
.. envvar:: PYTEST_PLUGINS
11541155

src/_pytest/config/__init__.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,8 @@ def _mark_plugins_for_rewrite(self, hook) -> None:
12901290
self.pluginmanager.rewrite_hook = hook
12911291

12921292
if os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD"):
1293-
# We don't autoload from setuptools entry points, no need to continue.
1293+
# We don't autoload from distribution package entry points,
1294+
# no need to continue.
12941295
return
12951296

12961297
package_files = (
@@ -1381,8 +1382,8 @@ def _preparse(self, args: List[str], addopts: bool = True) -> None:
13811382
self._consider_importhook(args)
13821383
self.pluginmanager.consider_preparse(args, exclude_only=False)
13831384
if not os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD"):
1384-
# Don't autoload from setuptools entry point. Only explicitly specified
1385-
# plugins are going to be loaded.
1385+
# Don't autoload from distribution package entry point. Only
1386+
# explicitly specified plugins are going to be loaded.
13861387
self.pluginmanager.load_setuptools_entrypoints("pytest11")
13871388
self.pluginmanager.consider_env()
13881389

src/_pytest/helpconfig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def getpluginversioninfo(config: Config) -> List[str]:
243243
lines = []
244244
plugininfo = config.pluginmanager.list_plugin_distinfo()
245245
if plugininfo:
246-
lines.append("setuptools registered plugins:")
246+
lines.append("registered third-party plugins:")
247247
for plugin, dist in plugininfo:
248248
loc = getattr(plugin, "__file__", repr(plugin))
249249
content = f"{dist.project_name}-{dist.version} at {loc}"

testing/test_assertion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def test_installed_plugin_rewrite(
223223
) -> None:
224224
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
225225
# Make sure the hook is installed early enough so that plugins
226-
# installed via setuptools are rewritten.
226+
# installed via distribution package are rewritten.
227227
pytester.mkdir("hampkg")
228228
contents = {
229229
"hampkg/__init__.py": """\

testing/test_helpconfig.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ def test_version_verbose(pytester: Pytester, pytestconfig, monkeypatch) -> None:
1010
assert result.ret == 0
1111
result.stdout.fnmatch_lines([f"*pytest*{pytest.__version__}*imported from*"])
1212
if pytestconfig.pluginmanager.list_plugin_distinfo():
13-
result.stdout.fnmatch_lines(["*setuptools registered plugins:", "*at*"])
13+
result.stdout.fnmatch_lines(
14+
["*registered third-party plugins:", "*at*"]
15+
)
1416

1517

1618
def test_version_less_verbose(pytester: Pytester, pytestconfig, monkeypatch) -> None:

0 commit comments

Comments
 (0)