From 31a037ce07d194bec82f89f1baf5517f442f9da8 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Tue, 24 Nov 2026 10:34:46 +0100 Subject: [PATCH 1/2] Add a note in writing-pyproject-toml on how to handle missing extras Closes gh-1605 --- source/guides/writing-pyproject-toml.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/guides/writing-pyproject-toml.rst b/source/guides/writing-pyproject-toml.rst index a983f6a35..b59011251 100644 --- a/source/guides/writing-pyproject-toml.rst +++ b/source/guides/writing-pyproject-toml.rst @@ -179,6 +179,11 @@ Each of the keys defines a "packaging extra". In the example above, one could use, e.g., ``pip install your-project-name[gui]`` to install your project with GUI support, adding the PyQt5 dependency. +To keep your package usable without optional dependencies, import them only where +needed, and handle their absence explicitly. If a user requests a feature whose +dependencies are missing, provide an error message explaining which extra to +install, for example, ``your-project-name[gui]``. + .. _self-referential-extras: You can also define an extra that refers back to the current project with From f5f3dc5e953982fba8c269bdfe4d81849167b41a Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Thu, 26 Nov 2026 12:24:10 +0100 Subject: [PATCH 2/2] Shorten the guidance on missing extras, avoid library design aspects --- source/guides/writing-pyproject-toml.rst | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/source/guides/writing-pyproject-toml.rst b/source/guides/writing-pyproject-toml.rst index b59011251..25fc4eef8 100644 --- a/source/guides/writing-pyproject-toml.rst +++ b/source/guides/writing-pyproject-toml.rst @@ -164,7 +164,8 @@ syntax you can use to constrain versions. You may want to make some of your dependencies optional, if they are only needed for a specific feature of your package. In that case, put -them in ``optional-dependencies``. +them in ``optional-dependencies``. Your package should remain usable without +these optional dependencies installed. .. code-block:: toml @@ -179,11 +180,6 @@ Each of the keys defines a "packaging extra". In the example above, one could use, e.g., ``pip install your-project-name[gui]`` to install your project with GUI support, adding the PyQt5 dependency. -To keep your package usable without optional dependencies, import them only where -needed, and handle their absence explicitly. If a user requests a feature whose -dependencies are missing, provide an error message explaining which extra to -install, for example, ``your-project-name[gui]``. - .. _self-referential-extras: You can also define an extra that refers back to the current project with