@@ -87,7 +87,7 @@ environments::
8787 'platform_system' | 'platform_version' |
8888 'platform_machine' | 'platform_python_implementation' |
8989 'implementation_name' | 'implementation_version' |
90- 'extra' # ONLY when defined by a containing layer
90+ 'extra' | 'extras' | 'dependency_groups' # ONLY when defined by a containing layer
9191 )
9292 marker_var = wsp* (env_var | python_str)
9393 marker_expr = marker_var marker_op marker_var
@@ -196,15 +196,16 @@ safely evaluate it without running arbitrary code that could become a security
196196vulnerability. Markers were first standardised in :pep: `345 `. This document
197197fixes some issues that were observed in the design described in :pep: `426 `.
198198
199- Comparisons in marker expressions are typed by the comparison operator. The
200- <marker_op> operators that are not in <version_cmp> perform the same as they
201- do for strings in Python. The <version_cmp> operators use the version comparison
202- rules of the :ref: `Version specifier specification <version-specifiers >`
203- when those are defined (that is when both sides have a valid
204- version specifier). If there is no defined behaviour of this specification
205- and the operator exists in Python, then the operator falls back to
206- the Python behaviour. Otherwise an error should be raised. e.g. the following
207- will result in errors::
199+ Comparisons in marker expressions are typed by the comparison operator and the
200+ type of the marker value. The <marker_op> operators that are not in
201+ <version_cmp> perform the same as they do for strings or sets in Python based on
202+ whether the marker value is a string or set itself. The <version_cmp> operators
203+ use the version comparison rules of the
204+ :ref: `Version specifier specification <version-specifiers >` when those are
205+ defined (that is when both sides have a valid version specifier). If there is no
206+ defined behaviour of this specification and the operator exists in Python, then
207+ the operator falls back to the Python behaviour for the types involved.
208+ Otherwise an error should be raised. e.g. the following will result in errors::
208209
209210 "dog" ~= "fred"
210211 python_version ~= "surprise"
@@ -235,52 +236,80 @@ no current specification for this. Regardless, outside of a context where this
235236special handling is taking place, the "extra" variable should result in an
236237error like all other unknown variables.
237238
239+ The "extras" and "dependency_groups" variables are also special. They are used
240+ to specify any requested extras or dependency groups when installing from a lock
241+ file. Outside of the context of lock files, these two variables should result in
242+ an error like all other unknown variables.
243+
238244.. list-table ::
239245 :header-rows: 1
240246
241247 * - Marker
242248 - Python equivalent
249+ - Type
243250 - Sample values
244251 * - ``os_name ``
245252 - :py:data: `os.name `
253+ - String
246254 - ``posix ``, ``java ``
247255 * - ``sys_platform ``
248256 - :py:data: `sys.platform `
257+ - String
249258 - ``linux ``, ``linux2 ``, ``darwin ``, ``java1.8.0_51 `` (note that "linux"
250259 is from Python3 and "linux2" from Python2)
251260 * - ``platform_machine ``
252261 - :py:func: `platform.machine() `
262+ - String
253263 - ``x86_64 ``
254264 * - ``platform_python_implementation ``
255265 - :py:func: `platform.python_implementation() `
266+ - String
256267 - ``CPython ``, ``Jython ``
257268 * - ``platform_release ``
258269 - :py:func: `platform.release() `
270+ - String
259271 - ``3.14.1-x86_64-linode39 ``, ``14.5.0 ``, ``1.8.0_51 ``
260272 * - ``platform_system ``
261273 - :py:func: `platform.system() `
274+ - String
262275 - ``Linux ``, ``Windows ``, ``Java ``
263276 * - ``platform_version ``
264277 - :py:func: `platform.version() `
278+ - String
265279 - ``#1 SMP Fri Apr 25 13:07:35 EDT 2014 ``
266280 ``Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Oracle Corporation ``
267281 ``Darwin Kernel Version 14.5.0: Wed Jul 29 02:18:53 PDT 2015; root:xnu-2782.40.9~2/RELEASE_X86_64 ``
268282 * - ``python_version ``
269283 - ``'.'.join(platform.python_version_tuple()[:2]) ``
284+ - Version
270285 - ``3.4 ``, ``2.7 ``
271286 * - ``python_full_version ``
272287 - :py:func: `platform.python_version() `
288+ - Version
273289 - ``3.4.0 ``, ``3.5.0b1 ``
274290 * - ``implementation_name ``
275291 - :py:data: `sys.implementation.name <sys.implementation> `
292+ - String
276293 - ``cpython ``
277294 * - ``implementation_version ``
278295 - see definition below
296+ - Version
279297 - ``3.4.0 ``, ``3.5.0b1 ``
280298 * - ``extra ``
281299 - An error except when defined by the context interpreting the
282300 specification.
301+ - String
283302 - ``test ``
303+ * - ``extras ``
304+ - An error except when defined by the context interpreting the
305+ specification.
306+ - Set of strings
307+ - ``{"test"} ``
308+ * - ``dependency_groups ``
309+ - An error except when defined by the context interpreting the
310+ specification.
311+ - Set of strings
312+ - ``{"test"} ``
284313
285314The ``implementation_version `` marker variable is derived from
286315:py:data: `sys.implementation.version <sys.implementation> `:
@@ -330,7 +359,7 @@ The complete parsley grammar::
330359 'platform_system' | 'platform_version' |
331360 'platform_machine' | 'platform_python_implementation' |
332361 'implementation_name' | 'implementation_version' |
333- 'extra' # ONLY when defined by a containing layer
362+ 'extra' | 'extras' | 'dependency_groups' # ONLY when defined by a containing layer
334363 ):varname -> lookup(varname)
335364 marker_var = wsp* (env_var | python_str)
336365 marker_expr = marker_var:l marker_op:o marker_var:r -> (o, l, r)
@@ -495,6 +524,8 @@ History
495524- June 2024: The definition of ``version_many `` was changed to allow trailing
496525 commas, matching with the behavior of the Python implementation that has been
497526 in use since late 2022.
527+ - April 2025: Added ``extras `` and ``dependency_groups `` for lock-file-spec _ as
528+ approved through :pep: `751 `.
498529
499530
500531References
0 commit comments