Skip to content

Commit 2275852

Browse files
committed
PEP 751: address feedback
- 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 2275852

1 file changed

Lines changed: 105 additions & 23 deletions

File tree

peps/pep-0751.rst

Lines changed: 105 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,67 @@ 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+
diff --git a/source/specifications/dependency-specifiers.rst b/source/specifications/dependency-specifiers.rst
745+
index 06897da2..c9ab247f 100644
746+
--- a/source/specifications/dependency-specifiers.rst
747+
+++ b/source/specifications/dependency-specifiers.rst
748+
@@ -87,7 +87,7 @@ environments::
749+
'platform_system' | 'platform_version' |
750+
'platform_machine' | 'platform_python_implementation' |
751+
'implementation_name' | 'implementation_version' |
752+
- 'extra' # ONLY when defined by a containing layer
753+
+ 'extra' | 'extras' | 'dependency_groups' # ONLY when defined by a containing layer
754+
)
755+
marker_var = wsp* (env_var | python_str)
756+
marker_expr = marker_var marker_op marker_var
757+
758+
This does NOT preclude using the same syntax parser in other contexts, only
759+
where the new markers happen to be considered valid based on context.
760+
761+
Second, the marker specification will be changed to allow sets for values (on
762+
top of the current support for strings and versions). ONLY the new markers
763+
introduced in this PEP will allow for a set for their value (which defaults to
764+
an empty set). This specifically does NOT update the spec to allow for set
765+
literals.
766+
767+
Third, the marker expression syntax specification will be updated to allow for
768+
operations involving sets:
769+
770+
.. code-block:: diff
771+
diff --git a/source/specifications/dependency-specifiers.rst b/source/specifications/dependency-specifiers.rst
772+
index 06897da2..ac29d796 100644
773+
--- a/source/specifications/dependency-specifiers.rst
774+
+++ b/source/specifications/dependency-specifiers.rst
775+
@@ -196,15 +196,16 @@ safely evaluate it without running arbitrary code that could become a security
776+
vulnerability. Markers were first standardised in :pep:`345`. This document
777+
fixes some issues that were observed in the design described in :pep:`426`.
778+
779+
-Comparisons in marker expressions are typed by the comparison operator. The
780+
-<marker_op> operators that are not in <version_cmp> perform the same as they
781+
-do for strings in Python. The <version_cmp> operators use the version comparison
782+
-rules of the :ref:`Version specifier specification <version-specifiers>`
783+
-when those are defined (that is when both sides have a valid
784+
-version specifier). If there is no defined behaviour of this specification
785+
-and the operator exists in Python, then the operator falls back to
786+
-the Python behaviour. Otherwise an error should be raised. e.g. the following
787+
-will result in errors::
788+
+Comparisons in marker expressions are typed by the comparison operator and the
789+
+type of the marker value. The <marker_op> operators that are not in
790+
+<version_cmp> perform the same as they do for strings or sets in Python based on
791+
+whether the marker value is a string or set itself. The <version_cmp> operators
792+
+use the version comparison rules of the
793+
+:ref:`Version specifier specification <version-specifiers>` when those are
794+
+defined (that is when both sides have a valid version specifier). If there is no
795+
+defined behaviour of this specification and the operator exists in Python, then
796+
+the operator falls back to the Python behaviour for the types involved.
797+
+Otherwise an error should be raised. e.g. the following will result in errors::
798+
799+
"dog" ~= "fred"
800+
python_version ~= "surprise"
725801
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.
734802
735803
These changes, along with ``packages.extras``/ ``packages.dependency-groups``
736804
and marker expressions' Boolean logic support, allow for expressing arbitrary,
@@ -806,10 +874,6 @@ Example
806874
run-on = 2025-03-06T12:28:57.760769
807875
808876
809-
810-
811-
812-
813877
------------
814878
Installation
815879
------------
@@ -923,6 +987,17 @@ file. Recording the sdist file name is for the same reason.
923987

924988
This PEP supports multi-use lock files while requirements files are single-use.
925989

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

9271002
=======================
9281003
Backwards Compatibility
@@ -997,6 +1072,13 @@ lock files at least support single-use lock files. Neither type of lock file
9971072
is better or worse than the other, it just changes how much can be written down
9981073
in a single file (which can influence how manageable).
9991074

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

10011083
========================
10021084
Reference Implementation

0 commit comments

Comments
 (0)