@@ -130,8 +130,8 @@ Error Handling
130
130
Get Options
131
131
-----------
132
132
133
- The configuration option *name* parameter must be a non-NULL
134
- null-terminated UTF-8 encoded string.
133
+ The configuration option *name* parameter must be a non-NULL null-terminated
134
+ UTF-8 encoded string. See :ref:`Configuration Options <pyinitconfig-opts>` .
135
135
136
136
.. c:function:: int PyInitConfig_HasOption(PyInitConfig *config, const char *name)
137
137
@@ -185,7 +185,7 @@ Set Options
185
185
-----------
186
186
187
187
The configuration option *name * parameter must be a non-NULL null-terminated
188
- UTF-8 encoded string.
188
+ UTF-8 encoded string. See :ref: ` Configuration Options < pyinitconfig-opts >`.
189
189
190
190
Some configuration options have side effects on other options. This logic is
191
191
only implemented when ``Py_InitializeFromInitConfig() `` is called, not by the
@@ -253,14 +253,307 @@ Initialize Python
253
253
See ``PyInitConfig_GetExitcode() `` for the exit code case.
254
254
255
255
256
+ .. _pyinitconfig-opts :
257
+
258
+ Configuration Options
259
+ =====================
260
+
261
+ .. list-table ::
262
+ :header-rows: 1
263
+
264
+ * - Option
265
+ - PyConfig/PyPreConfig member
266
+ - Type
267
+ - Visibility
268
+ * - ``"allocator" ``
269
+ - :c:member: `allocator <PyPreConfig.allocator> `
270
+ - ``int ``
271
+ - Read-only
272
+ * - ``"argv" ``
273
+ - :c:member: `argv <PyConfig.argv> `
274
+ - ``list[str] ``
275
+ - Public
276
+ * - ``"base_exec_prefix" ``
277
+ - :c:member: `base_exec_prefix <PyConfig.base_exec_prefix> `
278
+ - ``str ``
279
+ - Public
280
+ * - ``"base_executable" ``
281
+ - :c:member: `base_executable <PyConfig.base_executable> `
282
+ - ``str ``
283
+ - Public
284
+ * - ``"base_prefix" ``
285
+ - :c:member: `base_prefix <PyConfig.base_prefix> `
286
+ - ``str ``
287
+ - Public
288
+ * - ``"buffered_stdio" ``
289
+ - :c:member: `buffered_stdio <PyConfig.buffered_stdio> `
290
+ - ``bool ``
291
+ - Read-only
292
+ * - ``"bytes_warning" ``
293
+ - :c:member: `bytes_warning <PyConfig.bytes_warning> `
294
+ - ``int ``
295
+ - Public
296
+ * - ``"check_hash_pycs_mode" ``
297
+ - :c:member: `check_hash_pycs_mode <PyConfig.check_hash_pycs_mode> `
298
+ - ``str ``
299
+ - Read-only
300
+ * - ``"code_debug_ranges" ``
301
+ - :c:member: `code_debug_ranges <PyConfig.code_debug_ranges> `
302
+ - ``bool ``
303
+ - Read-only
304
+ * - ``"coerce_c_locale" ``
305
+ - :c:member: `coerce_c_locale <PyPreConfig.coerce_c_locale> `
306
+ - ``bool ``
307
+ - Read-only
308
+ * - ``"coerce_c_locale_warn" ``
309
+ - :c:member: `coerce_c_locale_warn <PyPreConfig.coerce_c_locale_warn> `
310
+ - ``bool ``
311
+ - Read-only
312
+ * - ``"configure_c_stdio" ``
313
+ - :c:member: `configure_c_stdio <PyConfig.configure_c_stdio> `
314
+ - ``bool ``
315
+ - Read-only
316
+ * - ``"configure_locale" ``
317
+ - :c:member: `configure_locale <PyPreConfig.configure_locale> `
318
+ - ``bool ``
319
+ - Read-only
320
+ * - ``"cpu_count" ``
321
+ - :c:member: `cpu_count <PyConfig.cpu_count> `
322
+ - ``int ``
323
+ - Read-only
324
+ * - ``"dev_mode" ``
325
+ - :c:member: `dev_mode <PyConfig.dev_mode> `
326
+ - ``bool ``
327
+ - Read-only
328
+ * - ``"dump_refs" ``
329
+ - :c:member: `dump_refs <PyConfig.dump_refs> `
330
+ - ``bool ``
331
+ - Read-only
332
+ * - ``"dump_refs_file" ``
333
+ - :c:member: `dump_refs_file <PyConfig.dump_refs_file> `
334
+ - ``str ``
335
+ - Read-only
336
+ * - ``"exec_prefix" ``
337
+ - :c:member: `exec_prefix <PyConfig.exec_prefix> `
338
+ - ``str ``
339
+ - Public
340
+ * - ``"executable" ``
341
+ - :c:member: `executable <PyConfig.executable> `
342
+ - ``str ``
343
+ - Public
344
+ * - ``"faulthandler" ``
345
+ - :c:member: `faulthandler <PyConfig.faulthandler> `
346
+ - ``bool ``
347
+ - Read-only
348
+ * - ``"filesystem_encoding" ``
349
+ - :c:member: `filesystem_encoding <PyConfig.filesystem_encoding> `
350
+ - ``str ``
351
+ - Read-only
352
+ * - ``"filesystem_errors" ``
353
+ - :c:member: `filesystem_errors <PyConfig.filesystem_errors> `
354
+ - ``str ``
355
+ - Read-only
356
+ * - ``"hash_seed" ``
357
+ - :c:member: `hash_seed <PyConfig.hash_seed> `
358
+ - ``int ``
359
+ - Read-only
360
+ * - ``"home" ``
361
+ - :c:member: `home <PyConfig.home> `
362
+ - ``str ``
363
+ - Read-only
364
+ * - ``"import_time" ``
365
+ - :c:member: `import_time <PyConfig.import_time> `
366
+ - ``bool ``
367
+ - Read-only
368
+ * - ``"inspect" ``
369
+ - :c:member: `inspect <PyConfig.inspect> `
370
+ - ``bool ``
371
+ - Public
372
+ * - ``"install_signal_handlers" ``
373
+ - :c:member: `install_signal_handlers <PyConfig.install_signal_handlers> `
374
+ - ``bool ``
375
+ - Read-only
376
+ * - ``"int_max_str_digits" ``
377
+ - :c:member: `int_max_str_digits <PyConfig.int_max_str_digits> `
378
+ - ``int ``
379
+ - Public
380
+ * - ``"interactive" ``
381
+ - :c:member: `interactive <PyConfig.interactive> `
382
+ - ``bool ``
383
+ - Public
384
+ * - ``"isolated" ``
385
+ - :c:member: `isolated <PyConfig.isolated> `
386
+ - ``bool ``
387
+ - Read-only
388
+ * - ``"legacy_windows_fs_encoding" ``
389
+ - :c:member: `legacy_windows_fs_encoding <PyPreConfig.legacy_windows_fs_encoding> `
390
+ - ``bool ``
391
+ - Read-only
392
+ * - ``"legacy_windows_stdio" ``
393
+ - :c:member: `legacy_windows_stdio <PyConfig.legacy_windows_stdio> `
394
+ - ``bool ``
395
+ - Read-only
396
+ * - ``"malloc_stats" ``
397
+ - :c:member: `malloc_stats <PyConfig.malloc_stats> `
398
+ - ``bool ``
399
+ - Read-only
400
+ * - ``"module_search_paths" ``
401
+ - :c:member: `module_search_paths <PyConfig.module_search_paths> `
402
+ - ``list[str] ``
403
+ - Public
404
+ * - ``"optimization_level" ``
405
+ - :c:member: `optimization_level <PyConfig.optimization_level> `
406
+ - ``int ``
407
+ - Public
408
+ * - ``"orig_argv" ``
409
+ - :c:member: `orig_argv <PyConfig.orig_argv> `
410
+ - ``list[str] ``
411
+ - Read-only
412
+ * - ``"parse_argv" ``
413
+ - :c:member: `parse_argv <PyConfig.parse_argv> `
414
+ - ``bool ``
415
+ - Read-only
416
+ * - ``"parser_debug" ``
417
+ - :c:member: `parser_debug <PyConfig.parser_debug> `
418
+ - ``bool ``
419
+ - Public
420
+ * - ``"pathconfig_warnings" ``
421
+ - :c:member: `pathconfig_warnings <PyConfig.pathconfig_warnings> `
422
+ - ``bool ``
423
+ - Read-only
424
+ * - ``"perf_profiling" ``
425
+ - :c:member: `perf_profiling <PyConfig.perf_profiling> `
426
+ - ``bool ``
427
+ - Read-only
428
+ * - ``"platlibdir" ``
429
+ - :c:member: `platlibdir <PyConfig.platlibdir> `
430
+ - ``str ``
431
+ - Public
432
+ * - ``"prefix" ``
433
+ - :c:member: `prefix <PyConfig.prefix> `
434
+ - ``str ``
435
+ - Public
436
+ * - ``"program_name" ``
437
+ - :c:member: `program_name <PyConfig.program_name> `
438
+ - ``str ``
439
+ - Read-only
440
+ * - ``"pycache_prefix" ``
441
+ - :c:member: `pycache_prefix <PyConfig.pycache_prefix> `
442
+ - ``str ``
443
+ - Public
444
+ * - ``"quiet" ``
445
+ - :c:member: `quiet <PyConfig.quiet> `
446
+ - ``bool ``
447
+ - Public
448
+ * - ``"run_command" ``
449
+ - :c:member: `run_command <PyConfig.run_command> `
450
+ - ``str ``
451
+ - Read-only
452
+ * - ``"run_filename" ``
453
+ - :c:member: `run_filename <PyConfig.run_filename> `
454
+ - ``str ``
455
+ - Read-only
456
+ * - ``"run_module" ``
457
+ - :c:member: `run_module <PyConfig.run_module> `
458
+ - ``str ``
459
+ - Read-only
460
+ * - ``"run_presite" ``
461
+ - :c:member: `run_presite <PyConfig.run_presite> `
462
+ - ``str ``
463
+ - Read-only
464
+ * - ``"safe_path" ``
465
+ - :c:member: `safe_path <PyConfig.safe_path> `
466
+ - ``bool ``
467
+ - Read-only
468
+ * - ``"show_ref_count" ``
469
+ - :c:member: `show_ref_count <PyConfig.show_ref_count> `
470
+ - ``bool ``
471
+ - Read-only
472
+ * - ``"site_import" ``
473
+ - :c:member: `site_import <PyConfig.site_import> `
474
+ - ``bool ``
475
+ - Read-only
476
+ * - ``"skip_source_first_line" ``
477
+ - :c:member: `skip_source_first_line <PyConfig.skip_source_first_line> `
478
+ - ``bool ``
479
+ - Read-only
480
+ * - ``"stdio_encoding" ``
481
+ - :c:member: `stdio_encoding <PyConfig.stdio_encoding> `
482
+ - ``str ``
483
+ - Read-only
484
+ * - ``"stdio_errors" ``
485
+ - :c:member: `stdio_errors <PyConfig.stdio_errors> `
486
+ - ``str ``
487
+ - Read-only
488
+ * - ``"stdlib_dir" ``
489
+ - :c:member: `stdlib_dir <PyConfig.stdlib_dir> `
490
+ - ``str ``
491
+ - Public
492
+ * - ``"tracemalloc" ``
493
+ - :c:member: `tracemalloc <PyConfig.tracemalloc> `
494
+ - ``int ``
495
+ - Read-only
496
+ * - ``"use_environment" ``
497
+ - :c:member: `use_environment <PyConfig.use_environment> `
498
+ - ``bool ``
499
+ - Public
500
+ * - ``"use_frozen_modules" ``
501
+ - :c:member: `use_frozen_modules <PyConfig.use_frozen_modules> `
502
+ - ``bool ``
503
+ - Read-only
504
+ * - ``"use_hash_seed" ``
505
+ - :c:member: `use_hash_seed <PyConfig.use_hash_seed> `
506
+ - ``bool ``
507
+ - Read-only
508
+ * - ``"user_site_directory" ``
509
+ - :c:member: `user_site_directory <PyConfig.user_site_directory> `
510
+ - ``bool ``
511
+ - Read-only
512
+ * - ``"utf8_mode" ``
513
+ - :c:member: `utf8_mode <PyPreConfig.utf8_mode> `
514
+ - ``bool ``
515
+ - Read-only
516
+ * - ``"verbose" ``
517
+ - :c:member: `verbose <PyConfig.verbose> `
518
+ - ``int ``
519
+ - Public
520
+ * - ``"warn_default_encoding" ``
521
+ - :c:member: `warn_default_encoding <PyConfig.warn_default_encoding> `
522
+ - ``bool ``
523
+ - Read-only
524
+ * - ``"warnoptions" ``
525
+ - :c:member: `warnoptions <PyConfig.warnoptions> `
526
+ - ``list[str] ``
527
+ - Public
528
+ * - ``"write_bytecode" ``
529
+ - :c:member: `write_bytecode <PyConfig.write_bytecode> `
530
+ - ``bool ``
531
+ - Public
532
+ * - ``"xoptions" ``
533
+ - :c:member: `xoptions <PyConfig.xoptions> `
534
+ - ``dict[str, str] ``
535
+ - Public
536
+ * - ``"_pystats" ``
537
+ - :c:member: `_pystats <PyConfig._pystats> `
538
+ - ``bool ``
539
+ - Read-only
540
+
541
+ Visibility:
542
+
543
+ * Public: Can by get by :c:func: `PyConfig_Get ` and set by
544
+ :c:func: `PyConfig_Set `.
545
+ * Read-only: Can by get by :c:func: `PyConfig_Get `, but cannot be set by
546
+ :c:func: `PyConfig_Set `.
547
+
548
+
256
549
Runtime Python configuration API
257
550
================================
258
551
259
552
At runtime, it's possible to get and set configuration options using
260
553
:c:func: `PyConfig_Get ` and :c:func: `PyConfig_Set ` functions.
261
554
262
555
The configuration option *name * parameter must be a non-NULL null-terminated
263
- UTF-8 encoded string.
556
+ UTF-8 encoded string. See :ref: ` Configuration Options < pyinitconfig-opts >`.
264
557
265
558
Some options are read from the :mod: `sys ` attributes. For example, the option
266
559
``"argv" `` is read from :data: `sys.argv `.
@@ -1055,6 +1348,16 @@ PyConfig
1055
1348
1056
1349
Default: ``0``.
1057
1350
1351
+ .. c:member:: wchar_t* dump_refs_file
1352
+
1353
+ Filename where to dump Python references.
1354
+
1355
+ Set by the :envvar:`PYTHONDUMPREFSFILE` environment variable.
1356
+
1357
+ Default: ``NULL``.
1358
+
1359
+ .. versionadded:: 3.11
1360
+
1058
1361
.. c:member:: wchar_t* exec_prefix
1059
1362
1060
1363
The site-specific directory prefix where the platform-dependent Python
@@ -1133,6 +1436,15 @@ PyConfig
1133
1436
1134
1437
See also the :c:member:`~PyConfig.filesystem_encoding` member.
1135
1438
1439
+ .. c:member:: int use_frozen_modules
1440
+
1441
+ If non-zero, use frozen modules.
1442
+
1443
+ Set by the :envvar:`PYTHON_FROZEN_MODULES` environment variable.
1444
+
1445
+ Default: ``1`` in a release build, or ``0`` in a :ref:`debug build
1446
+ <debug-build>`.
1447
+
1136
1448
.. c:member:: unsigned long hash_seed
1137
1449
.. c:member:: int use_hash_seed
1138
1450
@@ -1589,6 +1901,14 @@ PyConfig
1589
1901
1590
1902
.. versionadded:: 3.12
1591
1903
1904
+ .. c:member:: wchar_t* stdlib_dir
1905
+
1906
+ Directory of the Python standard library.
1907
+
1908
+ Default: ``NULL``.
1909
+
1910
+ .. versionadded:: 3.11
1911
+
1592
1912
.. c:member:: int use_environment
1593
1913
1594
1914
Use :ref:`environment variables <using-on-envvars>`?
@@ -1675,6 +1995,15 @@ PyConfig
1675
1995
1676
1996
Default: empty list.
1677
1997
1998
+ .. c:member:: int _pystats
1999
+
2000
+ If non-zero, write performance statistics at Python exit.
2001
+
2002
+ Need a special build with the ``Py_STATS`` macro:
2003
+ see :option:`--enable-pystats`.
2004
+
2005
+ Default: ``0``.
2006
+
1678
2007
If :c:member:`~PyConfig.parse_argv` is non-zero, :c:member:`~PyConfig.argv`
1679
2008
arguments are parsed the same way the regular Python parses :ref:`command line
1680
2009
arguments <using-on-cmdline>`, and Python arguments are stripped from
0 commit comments