@@ -87,7 +87,7 @@ environments::
87
87
'platform_system' | 'platform_version' |
88
88
'platform_machine' | 'platform_python_implementation' |
89
89
'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
91
91
)
92
92
marker_var = wsp* (env_var | python_str)
93
93
marker_expr = marker_var marker_op marker_var
@@ -196,15 +196,16 @@ safely evaluate it without running arbitrary code that could become a security
196
196
vulnerability. Markers were first standardised in :pep: `345 `. This document
197
197
fixes some issues that were observed in the design described in :pep: `426 `.
198
198
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::
208
209
209
210
"dog" ~= "fred"
210
211
python_version ~= "surprise"
@@ -235,52 +236,80 @@ no current specification for this. Regardless, outside of a context where this
235
236
special handling is taking place, the "extra" variable should result in an
236
237
error like all other unknown variables.
237
238
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
+
238
244
.. list-table ::
239
245
:header-rows: 1
240
246
241
247
* - Marker
242
248
- Python equivalent
249
+ - Type
243
250
- Sample values
244
251
* - ``os_name ``
245
252
- :py:data: `os.name `
253
+ - String
246
254
- ``posix ``, ``java ``
247
255
* - ``sys_platform ``
248
256
- :py:data: `sys.platform `
257
+ - String
249
258
- ``linux ``, ``linux2 ``, ``darwin ``, ``java1.8.0_51 `` (note that "linux"
250
259
is from Python3 and "linux2" from Python2)
251
260
* - ``platform_machine ``
252
261
- :py:func: `platform.machine() `
262
+ - String
253
263
- ``x86_64 ``
254
264
* - ``platform_python_implementation ``
255
265
- :py:func: `platform.python_implementation() `
266
+ - String
256
267
- ``CPython ``, ``Jython ``
257
268
* - ``platform_release ``
258
269
- :py:func: `platform.release() `
270
+ - String
259
271
- ``3.14.1-x86_64-linode39 ``, ``14.5.0 ``, ``1.8.0_51 ``
260
272
* - ``platform_system ``
261
273
- :py:func: `platform.system() `
274
+ - String
262
275
- ``Linux ``, ``Windows ``, ``Java ``
263
276
* - ``platform_version ``
264
277
- :py:func: `platform.version() `
278
+ - String
265
279
- ``#1 SMP Fri Apr 25 13:07:35 EDT 2014 ``
266
280
``Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Oracle Corporation ``
267
281
``Darwin Kernel Version 14.5.0: Wed Jul 29 02:18:53 PDT 2015; root:xnu-2782.40.9~2/RELEASE_X86_64 ``
268
282
* - ``python_version ``
269
283
- ``'.'.join(platform.python_version_tuple()[:2]) ``
284
+ - :ref: `Version <version-specifiers >`
270
285
- ``3.4 ``, ``2.7 ``
271
286
* - ``python_full_version ``
272
287
- :py:func: `platform.python_version() `
288
+ - :ref: `Version <version-specifiers >`
273
289
- ``3.4.0 ``, ``3.5.0b1 ``
274
290
* - ``implementation_name ``
275
291
- :py:data: `sys.implementation.name <sys.implementation> `
292
+ - String
276
293
- ``cpython ``
277
294
* - ``implementation_version ``
278
295
- see definition below
296
+ - :ref: `Version <version-specifiers >`
279
297
- ``3.4.0 ``, ``3.5.0b1 ``
280
298
* - ``extra ``
281
299
- An error except when defined by the context interpreting the
282
300
specification.
283
- - ``test ``
301
+ - String
302
+ - ``toml ``
303
+ * - ``extras ``
304
+ - An error except when defined by the context interpreting the
305
+ specification.
306
+ - Set of strings
307
+ - ``{"toml"} ``
308
+ * - ``dependency_groups ``
309
+ - An error except when defined by the context interpreting the
310
+ specification.
311
+ - Set of strings
312
+ - ``{"test"} ``
284
313
285
314
The ``implementation_version `` marker variable is derived from
286
315
:py:data: `sys.implementation.version <sys.implementation> `:
@@ -330,7 +359,7 @@ The complete parsley grammar::
330
359
'platform_system' | 'platform_version' |
331
360
'platform_machine' | 'platform_python_implementation' |
332
361
'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
334
363
):varname -> lookup(varname)
335
364
marker_var = wsp* (env_var | python_str)
336
365
marker_expr = marker_var:l marker_op:o marker_var:r -> (o, l, r)
@@ -495,6 +524,8 @@ History
495
524
- June 2024: The definition of ``version_many `` was changed to allow trailing
496
525
commas, matching with the behavior of the Python implementation that has been
497
526
in use since late 2022.
527
+ - April 2025: Added ``extras `` and ``dependency_groups `` for
528
+ :ref: `lock-file-spec ` as approved through :pep: `751 `.
498
529
499
530
500
531
References
0 commit comments