Skip to content

Commit f663eaa

Browse files
authored
PEP 751: address feedback (#4306)
- Make `packages.*.name` optional - `packages.directory.editable` can be ignored at install-time - Clarify the marker syntax changes - Introduce `default-group` - Clarify how this PEP does not fully replace requirements files - Clarify how different installers can be used to install from a lock file, but different lockers could lead to different outcomes
1 parent 4a65966 commit f663eaa

File tree

1 file changed

+107
-23
lines changed

1 file changed

+107
-23
lines changed

peps/pep-0751.rst

Lines changed: 107 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ consistent order. Usage of inline tables SHOULD also be kept consistent.
210210

211211
- **Type**: Array of strings
212212
- **Required?**: no; defaults to ``[]``
213-
- **Inspiration**: :ref:`packaging:pyproject-tool-table`
213+
- **Inspiration**: :ref:`packaging:core-metadata-provides-extra`
214214
- The list of :ref:`extras <packaging:core-metadata-provides-extra>` supported
215215
by this lock file.
216216
- Lockers MAY choose to not support writing lock files that support extras and
@@ -240,6 +240,22 @@ consistent order. Usage of inline tables SHOULD also be kept consistent.
240240
is, in effect, multi-use even if it only looks to be single-use.
241241

242242

243+
``default-group``
244+
=================
245+
246+
- **Type**: String
247+
- **Required?**: no
248+
- **Inspiration**: Poetry_, PDM_
249+
- The name of a synthetic dependency group to represent what should be installed
250+
by default (e.g. what ``project.dependencies`` implicitly represents).
251+
- Meant to be used in situations where ``packages.marker`` necessitates such a
252+
group to exist.
253+
- The group listed by this key SHOULD NOT be listed in ``dependency-groups`` as
254+
the group is not meant to be directly exposed to users by name but instead via
255+
an installer's UI.
256+
- This group can only be specified when ``dependency-groups`` has values.
257+
258+
243259
``created-by``
244260
==============
245261

@@ -455,7 +471,12 @@ consistent order. Usage of inline tables SHOULD also be kept consistent.
455471
- **Type**: boolean
456472
- **Required?**: no; defaults to ``false``
457473
- **Inspiration**: :ref:`packaging:direct-url-data-structure-local-directory`
458-
- A flag representing whether the source tree should be installed as editable.
474+
- A flag representing whether the source tree was an editable install at lock
475+
time.
476+
- Installer MAY choose to ignore this flag if user actions or context would make
477+
an editable install unnecessary or undesirable (e.g. a container image that
478+
will not be mounted for development purposes but instead deployed to
479+
production where it would be treated at read-only).
459480

460481

461482
``packages.directory.subdirectory``
@@ -567,7 +588,8 @@ See ``packages.vcs.subdirectory``.
567588
'''''''''''''''''''''''
568589

569590
- **Type**: string
570-
- **Required?**: yes
591+
- **Required?**: no, not when the last component of ``path``/ ``url`` would be
592+
the same value
571593
- **Inspiration**: PDM_, Poetry_, uv_
572594
- The file name of the :ref:`packaging:source-distribution-format-sdist` file.
573595

@@ -620,7 +642,8 @@ See ``packages.archive.hashes``.
620642
''''''''''''''''''''''''
621643

622644
- **Type**: string
623-
- **Required?**: yes
645+
- **Required?**: no, not when the last component of ``path``/ ``url`` would be
646+
the same value
624647
- **Inspiration**: PDM_, Poetry_, uv_
625648
- The file name of the :ref:`packaging:binary-distribution-format` file.
626649

@@ -715,22 +738,69 @@ contexts where marker syntax is used (e.g. ``METADATA``, ``pyproject.toml``).
715738

716739
First, two new markers will be introduced: ``extras`` and
717740
``dependency_groups``. They represent the extras and dependency groups that have
718-
been requested to be installed, respectively.
719-
720-
Second, the marker specification will be changed to allow for containers and not
721-
just strings for values. ONLY the new markers introduced in this PEP MAY and
722-
MUST be used with a :py:class:`collections.abc.Container` type for their
723-
value (which default to empty containers). An assumption of the type of
724-
container used MUST NOT be made (e.g. could be a set, list, or tuple).
741+
been requested to be installed, respectively:
742+
743+
.. code-block:: diff
744+
745+
diff --git a/source/specifications/dependency-specifiers.rst b/source/specifications/dependency-specifiers.rst
746+
index 06897da2..c9ab247f 100644
747+
--- a/source/specifications/dependency-specifiers.rst
748+
+++ b/source/specifications/dependency-specifiers.rst
749+
@@ -87,7 +87,7 @@ environments::
750+
'platform_system' | 'platform_version' |
751+
'platform_machine' | 'platform_python_implementation' |
752+
'implementation_name' | 'implementation_version' |
753+
- 'extra' # ONLY when defined by a containing layer
754+
+ 'extra' | 'extras' | 'dependency_groups' # ONLY when defined by a containing layer
755+
)
756+
marker_var = wsp* (env_var | python_str)
757+
marker_expr = marker_var marker_op marker_var
758+
759+
This does NOT preclude using the same syntax parser in other contexts, only
760+
where the new markers happen to be considered valid based on context.
761+
762+
Second, the marker specification will be changed to allow sets for values (on
763+
top of the current support for strings and versions). ONLY the new markers
764+
introduced in this PEP will allow for a set for their value (which defaults to
765+
an empty set). This specifically does NOT update the spec to allow for set
766+
literals.
767+
768+
Third, the marker expression syntax specification will be updated to allow for
769+
operations involving sets:
770+
771+
.. code-block:: diff
772+
773+
diff --git a/source/specifications/dependency-specifiers.rst b/source/specifications/dependency-specifiers.rst
774+
index 06897da2..ac29d796 100644
775+
--- a/source/specifications/dependency-specifiers.rst
776+
+++ b/source/specifications/dependency-specifiers.rst
777+
@@ -196,15 +196,16 @@ safely evaluate it without running arbitrary code that could become a security
778+
vulnerability. Markers were first standardised in :pep:`345`. This document
779+
fixes some issues that were observed in the design described in :pep:`426`.
780+
781+
-Comparisons in marker expressions are typed by the comparison operator. The
782+
-<marker_op> operators that are not in <version_cmp> perform the same as they
783+
-do for strings in Python. The <version_cmp> operators use the version comparison
784+
-rules of the :ref:`Version specifier specification <version-specifiers>`
785+
-when those are defined (that is when both sides have a valid
786+
-version specifier). If there is no defined behaviour of this specification
787+
-and the operator exists in Python, then the operator falls back to
788+
-the Python behaviour. Otherwise an error should be raised. e.g. the following
789+
-will result in errors::
790+
+Comparisons in marker expressions are typed by the comparison operator and the
791+
+type of the marker value. The <marker_op> operators that are not in
792+
+<version_cmp> perform the same as they do for strings or sets in Python based on
793+
+whether the marker value is a string or set itself. The <version_cmp> operators
794+
+use the version comparison rules of the
795+
+:ref:`Version specifier specification <version-specifiers>` when those are
796+
+defined (that is when both sides have a valid version specifier). If there is no
797+
+defined behaviour of this specification and the operator exists in Python, then
798+
+the operator falls back to the Python behaviour for the types involved.
799+
+Otherwise an error should be raised. e.g. the following will result in errors::
800+
801+
"dog" ~= "fred"
802+
python_version ~= "surprise"
725803
726-
Third, the "<marker_op> operators that are not in <version_cmp>" will be changed
727-
from operating "the same as they do for *strings*" to "the same as they
728-
do for *containers*". There are no backwards-compatibility concerns as strings
729-
are containers themselves.
730-
731-
Fourth, a tool MUST raise an error if an extra or dependency group is specified
732-
in a marker expression that does not exist in ``extras`` or
733-
``dependency-groups``, respectively.
734804
735805
These changes, along with ``packages.extras``/ ``packages.dependency-groups``
736806
and marker expressions' Boolean logic support, allow for expressing arbitrary,
@@ -806,10 +876,6 @@ Example
806876
run-on = 2025-03-06T12:28:57.760769
807877
808878
809-
810-
811-
812-
813879
------------
814880
Installation
815881
------------
@@ -923,6 +989,17 @@ file. Recording the sdist file name is for the same reason.
923989

924990
This PEP supports multi-use lock files while requirements files are single-use.
925991

992+
This PEP does NOT fully replace requirements files because:
993+
994+
- They support specifying installation
995+
`options <https://pip.pypa.io/en/stable/reference/requirements-file-format/#supported-options>`__
996+
at install-time (e.g. ``--index-url``, ``--constrants``).
997+
- They can
998+
`reference other requirements files <https://pip.pypa.io/en/stable/reference/requirements-file-format/#referring-to-other-requirements-files>`__
999+
via ``-r``.
1000+
- They can
1001+
`use environment variables <https://pip.pypa.io/en/stable/reference/requirements-file-format/#using-environment-variables>`__ .
1002+
9261003

9271004
=======================
9281005
Backwards Compatibility
@@ -997,6 +1074,13 @@ lock files at least support single-use lock files. Neither type of lock file
9971074
is better or worse than the other, it just changes how much can be written down
9981075
in a single file (which can influence how manageable).
9991076

1077+
Lock files that follow this PEP can be installed by any installer that
1078+
implements the specification. This allows users of a lock file to not not be
1079+
tied to the locker used by the person who produced the lock file. But it is not
1080+
the case that using a different locker will lead to the same result. This could
1081+
be for various reasons, including using different algorithms to determine what
1082+
to lock.
1083+
10001084

10011085
========================
10021086
Reference Implementation

0 commit comments

Comments
 (0)