1#ifndef Py_CPYTHON_PYLIFECYCLE_H
2# error "this header file must not be included directly"
3#endif
4
5/* Py_FrozenMain is kept out of the Limited API until documented and present
6 in all builds of Python */
7PyAPI_FUNC(int) Py_FrozenMain(int argc, char **argv);
8
9/* Only used by applications that embed the interpreter and need to
10 * override the standard encoding determination mechanism
11 */
12Py_DEPRECATED(3.11) PyAPI_FUNC(int) Py_SetStandardStreamEncoding(
13 const char *encoding,
14 const char *errors);
15
16/* PEP 432 Multi-phase initialization API (Private while provisional!) */
17
18PyAPI_FUNC(PyStatus) Py_PreInitialize(
19 const PyPreConfig *src_config);
20PyAPI_FUNC(PyStatus) Py_PreInitializeFromBytesArgs(
21 const PyPreConfig *src_config,
22 Py_ssize_t argc,
23 char **argv);
24PyAPI_FUNC(PyStatus) Py_PreInitializeFromArgs(
25 const PyPreConfig *src_config,
26 Py_ssize_t argc,
27 wchar_t **argv);
28
29PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
30
31
32/* Initialization and finalization */
33
34PyAPI_FUNC(PyStatus) Py_InitializeFromConfig(
35 const PyConfig *config);
36PyAPI_FUNC(PyStatus) _Py_InitializeMain(void);
37
38PyAPI_FUNC(int) Py_RunMain(void);
39
40
41PyAPI_FUNC(void) _Py_NO_RETURN Py_ExitStatusException(PyStatus err);
42
43/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
44PyAPI_FUNC(void) _Py_RestoreSignals(void);
45
46PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
47PyAPI_FUNC(int) _Py_FdIsInteractive(FILE *fp, PyObject *filename);
48
49Py_DEPRECATED(3.11) PyAPI_FUNC(void) _Py_SetProgramFullPath(const wchar_t *);
50
51PyAPI_FUNC(const char *) _Py_gitidentifier(void);
52PyAPI_FUNC(const char *) _Py_gitversion(void);
53
54PyAPI_FUNC(int) _Py_IsFinalizing(void);
55PyAPI_FUNC(int) _Py_IsInterpreterFinalizing(PyInterpreterState *interp);
56
57/* Random */
58PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size);
59PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
60
61/* Legacy locale support */
62PyAPI_FUNC(int) _Py_CoerceLegacyLocale(int warn);
63PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn);
64PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
65
66/* --- PyInterpreterConfig ------------------------------------ */
67
68#define PyInterpreterConfig_DEFAULT_GIL (0)
69#define PyInterpreterConfig_SHARED_GIL (1)
70#define PyInterpreterConfig_OWN_GIL (2)
71
72typedef struct {
73 // XXX "allow_object_sharing"? "own_objects"?
74 int use_main_obmalloc;
75 int allow_fork;
76 int allow_exec;
77 int allow_threads;
78 int allow_daemon_threads;
79 int check_multi_interp_extensions;
80 int gil;
81} PyInterpreterConfig;
82
83#define _PyInterpreterConfig_INIT \
84 { \
85 .use_main_obmalloc = 0, \
86 .allow_fork = 0, \
87 .allow_exec = 0, \
88 .allow_threads = 1, \
89 .allow_daemon_threads = 0, \
90 .check_multi_interp_extensions = 1, \
91 .gil = PyInterpreterConfig_OWN_GIL, \
92 }
93
94#define _PyInterpreterConfig_LEGACY_INIT \
95 { \
96 .use_main_obmalloc = 1, \
97 .allow_fork = 1, \
98 .allow_exec = 1, \
99 .allow_threads = 1, \
100 .allow_daemon_threads = 1, \
101 .check_multi_interp_extensions = 0, \
102 .gil = PyInterpreterConfig_SHARED_GIL, \
103 }
104
105PyAPI_FUNC(PyStatus) Py_NewInterpreterFromConfig(
106 PyThreadState **tstate_p,
107 const PyInterpreterConfig *config);
108
109typedef void (*atexit_datacallbackfunc)(void *);
110PyAPI_FUNC(int) _Py_AtExit(
111 PyInterpreterState *, atexit_datacallbackfunc, void *);
112

source code of include/python3.12/cpython/pylifecycle.h