@@ -175,6 +175,33 @@ Each of the keys defines a "packaging extra". In the example above, one
175175could use, e.g., ``pip install your-project-name[gui] `` to install your
176176project with GUI support, adding the PyQt5 dependency.
177177
178+ .. _self-referential-extras :
179+
180+ You can also define an extra that refers back to the current project with
181+ other extras. This is useful for convenience extras that combine several
182+ optional features (such as an ``all `` extra hosting dependencies from both
183+ ``gui `` and ``cli ``):
184+
185+ .. code-block :: toml
186+
187+ all = ["your-project-name[gui, cli]"]
188+
189+ The combined extra does not need its own manually maintained copy of each
190+ referenced extra's dependencies, which can otherwise fall out of sync after
191+ a few years of maintenance and bug fixes:
192+
193+ .. code-block :: toml
194+
195+ gui = ["PyQt5"]
196+ cli = [
197+ "rich>=14.2", # version range is added after last "all" extra update
198+ "textual", # dependency newly added since last "all" extra update
199+ "click",
200+ ]
201+ all = ["PyQt5", "rich", "click"]
202+
203+ Most package managers now support this kind of extra, including
204+ :ref: `pip `, :ref: `uv `, :ref: `poetry `, :ref: `hatch `, :ref: `pdm ` and :ref: `pipenv `.
178205
179206.. _requires-python :
180207.. _python_requires :
@@ -555,6 +582,7 @@ A full example
555582 "rich",
556583 "click",
557584 ]
585+ all = ["spam-eggs[gui, cli]"]
558586
559587 [project.urls]
560588 Homepage = "https://example.com"
0 commit comments