Skip to content

Commit de46370

Browse files
committed
Improve Examples section of the Dependency specifiers spec
Closes gh-1226
1 parent 2a5e415 commit de46370

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

‎source/specifications/dependency-specifiers.rst‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,40 @@ Specification
3232
Examples
3333
--------
3434

35-
All features of the language shown with a name based lookup::
35+
A dependency specifier showing all grammar features for a name based lookup::
3636

3737
requests [security,tests] >= 2.8.1, == 2.8.* ; python_version < "3.7"
3838

39-
A minimal URL based lookup::
39+
A dependency specifier with a direct URL reference::
4040

4141
pip @ https://github.com/pypa/pip/archive/1.3.1.zip#sha1=da9234ee9982d4bbb3c72346a6de940a148ea686
4242

43+
Optional whitespace can improve readability, as in ``pip ~= 23.1`` or
44+
``resolvelib > 0.5, != 0.6.0``. The surrounding syntax depends on where the
45+
dependency specifier is used.
46+
47+
In Core Metadata, dependency specifiers are values of
48+
:ref:`Requires-Dist <core-metadata-requires-dist>` fields::
49+
50+
Requires-Dist: pip ~= 23.1
51+
Requires-Dist: resolvelib > 0.5, != 0.6.0
52+
53+
In :file:`pyproject.toml`, they can be listed as strings, for example in
54+
:ref:`project.dependencies <pyproject-toml-dependencies>`:
55+
56+
.. code-block:: toml
57+
58+
[project]
59+
dependencies = [
60+
"pip ~= 23.1",
61+
"resolvelib > 0.5, != 0.6.0",
62+
]
63+
64+
When passing a dependency specifier containing spaces on the command line,
65+
quote the entire argument to preserve those spaces::
66+
67+
python -m pip install "pip ~= 23.1"
68+
4369
Concepts
4470
--------
4571

@@ -710,6 +736,8 @@ History
710736
inadvertently retained from :pep:`508`
711737
- July 2026: Explain that ``extra != "name"`` is not (properly) supported
712738
(https://discuss.python.org/t/ban-negative-extras-for-extras-marker/108022/24)
739+
- December 2026: Added examples showing dependency specifiers in metadata,
740+
TOML configuration, and shell commands.
713741

714742

715743
References

0 commit comments

Comments
 (0)