blob: 4965d7cbf06ceae85402f1d0955cd2e6db106086 [file] [log] [blame]
Nick Coghland6009512014-11-20 21:39:37 +10001
2/* Interfaces to configure, query, create & destroy the Python runtime */
3
4#ifndef Py_PYLIFECYCLE_H
5#define Py_PYLIFECYCLE_H
6#ifdef __cplusplus
7extern "C" {
8#endif
9
Serhiy Storchaka4ae06c52017-12-12 13:55:04 +020010PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *);
Victor Stinner0327bde2017-11-23 17:03:20 +010011PyAPI_FUNC(wchar_t *) Py_GetProgramName(void);
12
Serhiy Storchaka4ae06c52017-12-12 13:55:04 +020013PyAPI_FUNC(void) Py_SetPythonHome(const wchar_t *);
Victor Stinner0327bde2017-11-23 17:03:20 +010014PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void);
Victor Stinner0327bde2017-11-23 17:03:20 +010015
16#ifndef Py_LIMITED_API
17/* Only used by applications that embed the interpreter and need to
18 * override the standard encoding determination mechanism
19 */
20PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding,
21 const char *errors);
22
Eric Snow1abcf672017-05-23 21:46:51 -070023/* PEP 432 Multi-phase initialization API (Private while provisional!) */
Victor Stinner1dc6e392018-07-25 02:49:17 +020024PyAPI_FUNC(_PyInitError) _Py_InitializeCore(
25 PyInterpreterState **interp,
26 const _PyCoreConfig *);
Eric Snow1abcf672017-05-23 21:46:51 -070027PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
Victor Stinner46972b72017-11-24 22:55:40 +010028
Victor Stinnerb5fd9ad2017-12-14 02:20:52 +010029
Victor Stinnerc4bca952017-12-19 23:48:17 +010030PyAPI_FUNC(_PyInitError) _PyMainInterpreterConfig_Read(
31 _PyMainInterpreterConfig *config,
32 const _PyCoreConfig *core_config);
Victor Stinner46972b72017-11-24 22:55:40 +010033PyAPI_FUNC(void) _PyMainInterpreterConfig_Clear(_PyMainInterpreterConfig *);
Victor Stinnerda273412017-12-15 01:46:02 +010034PyAPI_FUNC(int) _PyMainInterpreterConfig_Copy(
35 _PyMainInterpreterConfig *config,
36 const _PyMainInterpreterConfig *config2);
Victor Stinner46972b72017-11-24 22:55:40 +010037
Victor Stinner1dc6e392018-07-25 02:49:17 +020038PyAPI_FUNC(_PyInitError) _Py_InitializeMainInterpreter(
39 PyInterpreterState *interp,
40 const _PyMainInterpreterConfig *);
Nick Coghland6009512014-11-20 21:39:37 +100041#endif
42
Eric Snow1abcf672017-05-23 21:46:51 -070043/* Initialization and finalization */
Nick Coghland6009512014-11-20 21:39:37 +100044PyAPI_FUNC(void) Py_Initialize(void);
45PyAPI_FUNC(void) Py_InitializeEx(int);
46#ifndef Py_LIMITED_API
Victor Stinner1dc6e392018-07-25 02:49:17 +020047PyAPI_FUNC(_PyInitError) _Py_InitializeFromConfig(
48 const _PyCoreConfig *config);
Victor Stinnercfc88312018-08-01 16:41:25 +020049PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalInitError(_PyInitError err);
Nick Coghland6009512014-11-20 21:39:37 +100050#endif
51PyAPI_FUNC(void) Py_Finalize(void);
Martin Panterb4ce1fc2015-11-30 03:18:29 +000052PyAPI_FUNC(int) Py_FinalizeEx(void);
Nick Coghland6009512014-11-20 21:39:37 +100053PyAPI_FUNC(int) Py_IsInitialized(void);
Eric Snow1abcf672017-05-23 21:46:51 -070054
55/* Subinterpreter support */
Nick Coghland6009512014-11-20 21:39:37 +100056PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
57PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
58
59
60/* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level
61 * exit functions.
62 */
63#ifndef Py_LIMITED_API
Marcel Plch776407f2017-12-20 11:17:58 +010064PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(PyObject *), PyObject *);
Nick Coghland6009512014-11-20 21:39:37 +100065#endif
66PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
67
Victor Stinnercfc88312018-08-01 16:41:25 +020068PyAPI_FUNC(void) _Py_NO_RETURN Py_Exit(int);
Nick Coghland6009512014-11-20 21:39:37 +100069
70/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
71#ifndef Py_LIMITED_API
72PyAPI_FUNC(void) _Py_RestoreSignals(void);
73
74PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
75#endif
76
77/* Bootstrap __main__ (defined in Modules/main.c) */
78PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv);
Victor Stinner94540602017-12-16 04:54:22 +010079#ifdef Py_BUILD_CORE
80PyAPI_FUNC(int) _Py_UnixMain(int argc, char **argv);
81#endif
Nick Coghland6009512014-11-20 21:39:37 +100082
83/* In getpath.c */
84PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void);
85PyAPI_FUNC(wchar_t *) Py_GetPrefix(void);
86PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void);
87PyAPI_FUNC(wchar_t *) Py_GetPath(void);
Victor Stinnerd4341102017-11-23 00:12:09 +010088#ifdef Py_BUILD_CORE
Victor Stinnerb1147e42018-07-21 02:06:16 +020089struct _PyPathConfig;
Victor Stinnerb1147e42018-07-21 02:06:16 +020090
91PyAPI_FUNC(_PyInitError) _PyPathConfig_SetGlobal(
Victor Stinnerecf411c2018-07-26 02:37:22 +020092 const struct _PyPathConfig *config);
Victor Stinner11a247d2017-12-13 21:05:57 +010093PyAPI_FUNC(PyObject*) _PyPathConfig_ComputeArgv0(int argc, wchar_t **argv);
Victor Stinner9bee3292017-12-21 16:49:13 +010094PyAPI_FUNC(int) _Py_FindEnvConfigValue(
95 FILE *env_file,
96 const wchar_t *key,
97 wchar_t *value,
98 size_t value_size);
Victor Stinnerd4341102017-11-23 00:12:09 +010099#endif
Nick Coghland6009512014-11-20 21:39:37 +1000100PyAPI_FUNC(void) Py_SetPath(const wchar_t *);
101#ifdef MS_WINDOWS
Victor Stinner31a83932017-12-04 13:39:15 +0100102int _Py_CheckPython3(void);
Nick Coghland6009512014-11-20 21:39:37 +1000103#endif
104
105/* In their own files */
106PyAPI_FUNC(const char *) Py_GetVersion(void);
107PyAPI_FUNC(const char *) Py_GetPlatform(void);
108PyAPI_FUNC(const char *) Py_GetCopyright(void);
109PyAPI_FUNC(const char *) Py_GetCompiler(void);
110PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
111#ifndef Py_LIMITED_API
Ned Deily5c4b0d02017-03-04 00:19:55 -0500112PyAPI_FUNC(const char *) _Py_gitidentifier(void);
113PyAPI_FUNC(const char *) _Py_gitversion(void);
Nick Coghland6009512014-11-20 21:39:37 +1000114#endif
115
116/* Internal -- various one-time initializations */
117#ifndef Py_LIMITED_API
118PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
Victor Stinnerf7e5b562017-11-15 15:48:08 -0800119PyAPI_FUNC(_PyInitError) _PySys_BeginInit(PyObject **sysmod);
Victor Stinner41264f12017-12-15 02:05:29 +0100120PyAPI_FUNC(int) _PySys_EndInit(PyObject *sysdict, _PyMainInterpreterConfig *config);
Victor Stinner672b6ba2017-12-06 17:25:50 +0100121PyAPI_FUNC(_PyInitError) _PyImport_Init(PyInterpreterState *interp);
Nick Coghland6009512014-11-20 21:39:37 +1000122PyAPI_FUNC(void) _PyExc_Init(PyObject * bltinmod);
Victor Stinnerf7e5b562017-11-15 15:48:08 -0800123PyAPI_FUNC(_PyInitError) _PyImportHooks_Init(void);
Nick Coghland6009512014-11-20 21:39:37 +1000124PyAPI_FUNC(int) _PyFloat_Init(void);
125PyAPI_FUNC(int) PyByteArray_Init(void);
Victor Stinner358e5e12017-12-15 00:51:22 +0100126PyAPI_FUNC(_PyInitError) _Py_HashRandomization_Init(const _PyCoreConfig *);
127#endif
Nick Coghland6009512014-11-20 21:39:37 +1000128
129/* Various internal finalizers */
Victor Stinner92a3c6f2017-12-06 18:12:59 +0100130
131#ifdef Py_BUILD_CORE
Nick Coghland6009512014-11-20 21:39:37 +1000132PyAPI_FUNC(void) _PyExc_Fini(void);
133PyAPI_FUNC(void) _PyImport_Fini(void);
Victor Stinner92a3c6f2017-12-06 18:12:59 +0100134PyAPI_FUNC(void) _PyImport_Fini2(void);
135PyAPI_FUNC(void) _PyGC_DumpShutdownStats(void);
136PyAPI_FUNC(void) _PyGC_Fini(void);
137PyAPI_FUNC(void) _PyType_Fini(void);
138PyAPI_FUNC(void) _Py_HashRandomization_Fini(void);
139#endif /* Py_BUILD_CORE */
140
141#ifndef Py_LIMITED_API
Nick Coghland6009512014-11-20 21:39:37 +1000142PyAPI_FUNC(void) PyMethod_Fini(void);
143PyAPI_FUNC(void) PyFrame_Fini(void);
144PyAPI_FUNC(void) PyCFunction_Fini(void);
145PyAPI_FUNC(void) PyDict_Fini(void);
146PyAPI_FUNC(void) PyTuple_Fini(void);
147PyAPI_FUNC(void) PyList_Fini(void);
148PyAPI_FUNC(void) PySet_Fini(void);
149PyAPI_FUNC(void) PyBytes_Fini(void);
150PyAPI_FUNC(void) PyByteArray_Fini(void);
151PyAPI_FUNC(void) PyFloat_Fini(void);
152PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
Nick Coghland6009512014-11-20 21:39:37 +1000153PyAPI_FUNC(void) PySlice_Fini(void);
Yury Selivanoveb636452016-09-08 22:01:51 -0700154PyAPI_FUNC(void) PyAsyncGen_Fini(void);
Nick Coghland6009512014-11-20 21:39:37 +1000155
Eric Snow2ebc5ce2017-09-07 23:51:28 -0600156PyAPI_FUNC(int) _Py_IsFinalizing(void);
Victor Stinner92a3c6f2017-12-06 18:12:59 +0100157#endif /* !Py_LIMITED_API */
Nick Coghland6009512014-11-20 21:39:37 +1000158
159/* Signals */
160typedef void (*PyOS_sighandler_t)(int);
161PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
162PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
163
Serhiy Storchaka9fab79b2016-09-11 11:03:14 +0300164#ifndef Py_LIMITED_API
Nick Coghland6009512014-11-20 21:39:37 +1000165/* Random */
Victor Stinnere66987e2016-09-06 16:33:52 -0700166PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size);
167PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
Serhiy Storchaka9fab79b2016-09-11 11:03:14 +0300168#endif /* !Py_LIMITED_API */
Nick Coghland6009512014-11-20 21:39:37 +1000169
Erik Bray031c4bf2017-10-27 11:46:03 +0200170/* Legacy locale support */
171#ifndef Py_LIMITED_API
Victor Stinner94540602017-12-16 04:54:22 +0100172PyAPI_FUNC(void) _Py_CoerceLegacyLocale(const _PyCoreConfig *config);
Erik Bray031c4bf2017-10-27 11:46:03 +0200173PyAPI_FUNC(int) _Py_LegacyLocaleDetected(void);
xdegaye1588be62017-11-12 12:45:59 +0100174PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
Erik Bray031c4bf2017-10-27 11:46:03 +0200175#endif
176
Nick Coghland6009512014-11-20 21:39:37 +1000177#ifdef __cplusplus
178}
179#endif
180#endif /* !Py_PYLIFECYCLE_H */