From bd6836a893fdd5e193121eec6efa47c7a945d145 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Tue, 17 Nov 2026 19:35:07 +0100 Subject: [PATCH] Clarify script entrypoint format in writing-pyproject.toml guide Closes #1993 Supersedes and closes #2060 --- source/guides/writing-pyproject-toml.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/guides/writing-pyproject-toml.rst b/source/guides/writing-pyproject-toml.rst index 06d792332..652ab50a8 100644 --- a/source/guides/writing-pyproject-toml.rst +++ b/source/guides/writing-pyproject-toml.rst @@ -239,6 +239,12 @@ In this example, after installing your project, a ``spam-cli`` command will be available. Executing this command will do the equivalent of ``import sys; from spam import main_cli; sys.exit(main_cli())``. +If your callable is in a submodule, use an +:ref:`object reference ` such as ``spam.cli:main``. The part +before the colon names the module to import; the part after it identifies +a callable object through attribute lookup in that module. The callable +is invoked with no arguments. + On Windows, scripts packaged this way need a terminal, so if you launch them from within a graphical application, they will make a terminal pop up. To prevent this from happening, use the ``[project.gui-scripts]``