blob: 04e672e96e17cb5a8c961bf375d134d8a08c3a22 [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);
Victor Stinner124b9eb2018-08-29 01:29:06 +020022#endif
23#ifdef Py_BUILD_CORE
24PyAPI_FUNC(void) _Py_ClearStandardStreamEncoding(void);
25#endif
Victor Stinner0327bde2017-11-23 17:03:20 +010026
Victor Stinner124b9eb2018-08-29 01:29:06 +020027
28#ifndef Py_LIMITED_API
Eric Snow1abcf672017-05-23 21:46:51 -070029/* PEP 432 Multi-phase initialization API (Private while provisional!) */
Victor Stinner1dc6e392018-07-25 02:49:17 +020030PyAPI_FUNC(_PyInitError) _Py_InitializeCore(
31 PyInterpreterState **interp,
32 const _PyCoreConfig *);
Eric Snow1abcf672017-05-23 21:46:51 -070033PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
Victor Stinner46972b72017-11-24 22:55:40 +010034
Victor Stinnerb5fd9ad2017-12-14 02:20:52 +010035
Victor Stinnerc4bca952017-12-19 23:48:17 +010036PyAPI_FUNC(_PyInitError) _PyMainInterpreterConfig_Read(
37 _PyMainInterpreterConfig *config,
38 const _PyCoreConfig *core_config);
Victor Stinner46972b72017-11-24 22:55:40 +010039PyAPI_FUNC(void) _PyMainInterpreterConfig_Clear(_PyMainInterpreterConfig *);
Victor Stinnerda273412017-12-15 01:46:02 +010040PyAPI_FUNC(int) _PyMainInterpreterConfig_Copy(
41 _PyMainInterpreterConfig *config,
42 const _PyMainInterpreterConfig *config2);
Victor Stinner46972b72017-11-24 22:55:40 +010043
Victor Stinner1dc6e392018-07-25 02:49:17 +020044PyAPI_FUNC(_PyInitError) _Py_InitializeMainInterpreter(
45 PyInterpreterState *interp,
46 const _PyMainInterpreterConfig *);
Nick Coghland6009512014-11-20 21:39:37 +100047#endif
48
Eric Snow1abcf672017-05-23 21:46:51 -070049/* Initialization and finalization */
Nick Coghland6009512014-11-20 21:39:37 +100050PyAPI_FUNC(void) Py_Initialize(void);
51PyAPI_FUNC(void) Py_InitializeEx(int);
52#ifndef Py_LIMITED_API
Victor Stinner1dc6e392018-07-25 02:49:17 +020053PyAPI_FUNC(_PyInitError) _Py_InitializeFromConfig(
54 const _PyCoreConfig *config);
Victor Stinnercfc88312018-08-01 16:41:25 +020055PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalInitError(_PyInitError err);
Nick Coghland6009512014-11-20 21:39:37 +100056#endif
57PyAPI_FUNC(void) Py_Finalize(void);
Martin Panterb4ce1fc2015-11-30 03:18:29 +000058PyAPI_FUNC(int) Py_FinalizeEx(void);
Nick Coghland6009512014-11-20 21:39:37 +100059PyAPI_FUNC(int) Py_IsInitialized(void);
Eric Snow1abcf672017-05-23 21:46:51 -070060
61/* Subinterpreter support */
Nick Coghland6009512014-11-20 21:39:37 +100062PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
63PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
64
65
66/* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level
67 * exit functions.
68 */
69#ifndef Py_LIMITED_API
Marcel Plch776407f2017-12-20 11:17:58 +010070PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(PyObject *), PyObject *);
Nick Coghland6009512014-11-20 21:39:37 +100071#endif
72PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
73
Victor Stinnercfc88312018-08-01 16:41:25 +020074PyAPI_FUNC(void) _Py_NO_RETURN Py_Exit(int);
Nick Coghland6009512014-11-20 21:39:37 +100075
76/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
77#ifndef Py_LIMITED_API
78PyAPI_FUNC(void) _Py_RestoreSignals(void);
79
80PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
81#endif
82
83/* Bootstrap __main__ (defined in Modules/main.c) */
84PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv);
Victor Stinner94540602017-12-16 04:54:22 +010085#ifdef Py_BUILD_CORE
86PyAPI_FUNC(int) _Py_UnixMain(int argc, char **argv);
87#endif
Nick Coghland6009512014-11-20 21:39:37 +100088
89/* In getpath.c */
90PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void);
91PyAPI_FUNC(wchar_t *) Py_GetPrefix(void);
92PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void);
93PyAPI_FUNC(wchar_t *) Py_GetPath(void);
Victor Stinnerd4341102017-11-23 00:12:09 +010094#ifdef Py_BUILD_CORE
Victor Stinnerb1147e42018-07-21 02:06:16 +020095struct _PyPathConfig;
Victor Stinnerb1147e42018-07-21 02:06:16 +020096
97PyAPI_FUNC(_PyInitError) _PyPathConfig_SetGlobal(
Victor Stinnerecf411c2018-07-26 02:37:22 +020098 const struct _PyPathConfig *config);
Victor Stinner11a247d2017-12-13 21:05:57 +010099PyAPI_FUNC(PyObject*) _PyPathConfig_ComputeArgv0(int argc, wchar_t **argv);
Victor Stinner9bee3292017-12-21 16:49:13 +0100100PyAPI_FUNC(int) _Py_FindEnvConfigValue(
101 FILE *env_file,
102 const wchar_t *key,
103 wchar_t *value,
104 size_t value_size);
Victor Stinnerd4341102017-11-23 00:12:09 +0100105#endif
Nick Coghland6009512014-11-20 21:39:37 +1000106PyAPI_FUNC(void) Py_SetPath(const wchar_t *);
107#ifdef MS_WINDOWS
Victor Stinner31a83932017-12-04 13:39:15 +0100108int _Py_CheckPython3(void);
Nick Coghland6009512014-11-20 21:39:37 +1000109#endif
110
111/* In their own files */
112PyAPI_FUNC(const char *) Py_GetVersion(void);
113PyAPI_FUNC(const char *) Py_GetPlatform(void);
114PyAPI_FUNC(const char *) Py_GetCopyright(void);
115PyAPI_FUNC(const char *) Py_GetCompiler(void);
116PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
117#ifndef Py_LIMITED_API
Ned Deily5c4b0d02017-03-04 00:19:55 -0500118PyAPI_FUNC(const char *) _Py_gitidentifier(void);
119PyAPI_FUNC(const char *) _Py_gitversion(void);
Nick Coghland6009512014-11-20 21:39:37 +1000120#endif
121
122/* Internal -- various one-time initializations */
123#ifndef Py_LIMITED_API
124PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
Victor Stinnerf7e5b562017-11-15 15:48:08 -0800125PyAPI_FUNC(_PyInitError) _PySys_BeginInit(PyObject **sysmod);
Victor Stinnerfbca9082018-08-30 00:50:45 +0200126PyAPI_FUNC(int) _PySys_EndInit(PyObject *sysdict, PyInterpreterState *interp);
Victor Stinner672b6ba2017-12-06 17:25:50 +0100127PyAPI_FUNC(_PyInitError) _PyImport_Init(PyInterpreterState *interp);
Nick Coghland6009512014-11-20 21:39:37 +1000128PyAPI_FUNC(void) _PyExc_Init(PyObject * bltinmod);
Victor Stinnerf7e5b562017-11-15 15:48:08 -0800129PyAPI_FUNC(_PyInitError) _PyImportHooks_Init(void);
Nick Coghland6009512014-11-20 21:39:37 +1000130PyAPI_FUNC(int) _PyFloat_Init(void);
131PyAPI_FUNC(int) PyByteArray_Init(void);
Victor Stinner358e5e12017-12-15 00:51:22 +0100132PyAPI_FUNC(_PyInitError) _Py_HashRandomization_Init(const _PyCoreConfig *);
133#endif
Nick Coghland6009512014-11-20 21:39:37 +1000134
135/* Various internal finalizers */
Victor Stinner92a3c6f2017-12-06 18:12:59 +0100136
137#ifdef Py_BUILD_CORE
Nick Coghland6009512014-11-20 21:39:37 +1000138PyAPI_FUNC(void) _PyExc_Fini(void);
139PyAPI_FUNC(void) _PyImport_Fini(void);
Victor Stinner92a3c6f2017-12-06 18:12:59 +0100140PyAPI_FUNC(void) _PyImport_Fini2(void);
141PyAPI_FUNC(void) _PyGC_DumpShutdownStats(void);
142PyAPI_FUNC(void) _PyGC_Fini(void);
143PyAPI_FUNC(void) _PyType_Fini(void);
144PyAPI_FUNC(void) _Py_HashRandomization_Fini(void);
145#endif /* Py_BUILD_CORE */
146
147#ifndef Py_LIMITED_API
Nick Coghland6009512014-11-20 21:39:37 +1000148PyAPI_FUNC(void) PyMethod_Fini(void);
149PyAPI_FUNC(void) PyFrame_Fini(void);
150PyAPI_FUNC(void) PyCFunction_Fini(void);
151PyAPI_FUNC(void) PyDict_Fini(void);
152PyAPI_FUNC(void) PyTuple_Fini(void);
153PyAPI_FUNC(void) PyList_Fini(void);
154PyAPI_FUNC(void) PySet_Fini(void);
155PyAPI_FUNC(void) PyBytes_Fini(void);
156PyAPI_FUNC(void) PyByteArray_Fini(void);
157PyAPI_FUNC(void) PyFloat_Fini(void);
158PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
Nick Coghland6009512014-11-20 21:39:37 +1000159PyAPI_FUNC(void) PySlice_Fini(void);
Yury Selivanoveb636452016-09-08 22:01:51 -0700160PyAPI_FUNC(void) PyAsyncGen_Fini(void);
Nick Coghland6009512014-11-20 21:39:37 +1000161
Eric Snow2ebc5ce2017-09-07 23:51:28 -0600162PyAPI_FUNC(int) _Py_IsFinalizing(void);
Victor Stinner92a3c6f2017-12-06 18:12:59 +0100163#endif /* !Py_LIMITED_API */
Nick Coghland6009512014-11-20 21:39:37 +1000164
165/* Signals */
166typedef void (*PyOS_sighandler_t)(int);
167PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
168PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
169
Serhiy Storchaka9fab79b2016-09-11 11:03:14 +0300170#ifndef Py_LIMITED_API
Nick Coghland6009512014-11-20 21:39:37 +1000171/* Random */
Victor Stinnere66987e2016-09-06 16:33:52 -0700172PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size);
173PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
Serhiy Storchaka9fab79b2016-09-11 11:03:14 +0300174#endif /* !Py_LIMITED_API */
Nick Coghland6009512014-11-20 21:39:37 +1000175
Erik Bray031c4bf2017-10-27 11:46:03 +0200176/* Legacy locale support */
177#ifndef Py_LIMITED_API
Victor Stinnerb2457ef2018-08-29 13:25:36 +0200178PyAPI_FUNC(void) _Py_CoerceLegacyLocale(int warn);
Erik Bray031c4bf2017-10-27 11:46:03 +0200179PyAPI_FUNC(int) _Py_LegacyLocaleDetected(void);
xdegaye1588be62017-11-12 12:45:59 +0100180PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
Erik Bray031c4bf2017-10-27 11:46:03 +0200181#endif
Victor Stinnerdfe0dc72018-08-29 11:47:29 +0200182#ifdef Py_BUILD_CORE
183PyAPI_FUNC(int) _Py_IsLocaleCoercionTarget(const char *ctype_loc);
184#endif
Erik Bray031c4bf2017-10-27 11:46:03 +0200185
Nick Coghland6009512014-11-20 21:39:37 +1000186#ifdef __cplusplus
187}
188#endif
189#endif /* !Py_PYLIFECYCLE_H */