Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 1 | |
| 2 | /* Interfaces to configure, query, create & destroy the Python runtime */ |
| 3 | |
| 4 | #ifndef Py_PYLIFECYCLE_H |
| 5 | #define Py_PYLIFECYCLE_H |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
| 9 | |
Serhiy Storchaka | 4ae06c5 | 2017-12-12 13:55:04 +0200 | [diff] [blame] | 10 | PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *); |
Victor Stinner | 0327bde | 2017-11-23 17:03:20 +0100 | [diff] [blame] | 11 | PyAPI_FUNC(wchar_t *) Py_GetProgramName(void); |
| 12 | |
Serhiy Storchaka | 4ae06c5 | 2017-12-12 13:55:04 +0200 | [diff] [blame] | 13 | PyAPI_FUNC(void) Py_SetPythonHome(const wchar_t *); |
Victor Stinner | 0327bde | 2017-11-23 17:03:20 +0100 | [diff] [blame] | 14 | PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void); |
Victor Stinner | 0327bde | 2017-11-23 17:03:20 +0100 | [diff] [blame] | 15 | |
| 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 | */ |
| 20 | PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding, |
| 21 | const char *errors); |
Victor Stinner | 124b9eb | 2018-08-29 01:29:06 +0200 | [diff] [blame] | 22 | #endif |
| 23 | #ifdef Py_BUILD_CORE |
| 24 | PyAPI_FUNC(void) _Py_ClearStandardStreamEncoding(void); |
| 25 | #endif |
Victor Stinner | 0327bde | 2017-11-23 17:03:20 +0100 | [diff] [blame] | 26 | |
Victor Stinner | 124b9eb | 2018-08-29 01:29:06 +0200 | [diff] [blame] | 27 | |
| 28 | #ifndef Py_LIMITED_API |
Eric Snow | 1abcf67 | 2017-05-23 21:46:51 -0700 | [diff] [blame] | 29 | /* PEP 432 Multi-phase initialization API (Private while provisional!) */ |
Victor Stinner | 1dc6e39 | 2018-07-25 02:49:17 +0200 | [diff] [blame] | 30 | PyAPI_FUNC(_PyInitError) _Py_InitializeCore( |
| 31 | PyInterpreterState **interp, |
| 32 | const _PyCoreConfig *); |
Eric Snow | 1abcf67 | 2017-05-23 21:46:51 -0700 | [diff] [blame] | 33 | PyAPI_FUNC(int) _Py_IsCoreInitialized(void); |
Victor Stinner | 46972b7 | 2017-11-24 22:55:40 +0100 | [diff] [blame] | 34 | |
Victor Stinner | b5fd9ad | 2017-12-14 02:20:52 +0100 | [diff] [blame] | 35 | |
Victor Stinner | c4bca95 | 2017-12-19 23:48:17 +0100 | [diff] [blame] | 36 | PyAPI_FUNC(_PyInitError) _PyMainInterpreterConfig_Read( |
| 37 | _PyMainInterpreterConfig *config, |
| 38 | const _PyCoreConfig *core_config); |
Victor Stinner | 46972b7 | 2017-11-24 22:55:40 +0100 | [diff] [blame] | 39 | PyAPI_FUNC(void) _PyMainInterpreterConfig_Clear(_PyMainInterpreterConfig *); |
Victor Stinner | da27341 | 2017-12-15 01:46:02 +0100 | [diff] [blame] | 40 | PyAPI_FUNC(int) _PyMainInterpreterConfig_Copy( |
| 41 | _PyMainInterpreterConfig *config, |
| 42 | const _PyMainInterpreterConfig *config2); |
Victor Stinner | 46972b7 | 2017-11-24 22:55:40 +0100 | [diff] [blame] | 43 | |
Victor Stinner | 1dc6e39 | 2018-07-25 02:49:17 +0200 | [diff] [blame] | 44 | PyAPI_FUNC(_PyInitError) _Py_InitializeMainInterpreter( |
| 45 | PyInterpreterState *interp, |
| 46 | const _PyMainInterpreterConfig *); |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 47 | #endif |
| 48 | |
Eric Snow | 1abcf67 | 2017-05-23 21:46:51 -0700 | [diff] [blame] | 49 | /* Initialization and finalization */ |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 50 | PyAPI_FUNC(void) Py_Initialize(void); |
| 51 | PyAPI_FUNC(void) Py_InitializeEx(int); |
| 52 | #ifndef Py_LIMITED_API |
Victor Stinner | 1dc6e39 | 2018-07-25 02:49:17 +0200 | [diff] [blame] | 53 | PyAPI_FUNC(_PyInitError) _Py_InitializeFromConfig( |
| 54 | const _PyCoreConfig *config); |
Victor Stinner | cfc8831 | 2018-08-01 16:41:25 +0200 | [diff] [blame] | 55 | PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalInitError(_PyInitError err); |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 56 | #endif |
| 57 | PyAPI_FUNC(void) Py_Finalize(void); |
Martin Panter | b4ce1fc | 2015-11-30 03:18:29 +0000 | [diff] [blame] | 58 | PyAPI_FUNC(int) Py_FinalizeEx(void); |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 59 | PyAPI_FUNC(int) Py_IsInitialized(void); |
Eric Snow | 1abcf67 | 2017-05-23 21:46:51 -0700 | [diff] [blame] | 60 | |
| 61 | /* Subinterpreter support */ |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 62 | PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void); |
| 63 | PyAPI_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 Plch | 776407f | 2017-12-20 11:17:58 +0100 | [diff] [blame] | 70 | PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(PyObject *), PyObject *); |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 71 | #endif |
| 72 | PyAPI_FUNC(int) Py_AtExit(void (*func)(void)); |
| 73 | |
Victor Stinner | cfc8831 | 2018-08-01 16:41:25 +0200 | [diff] [blame] | 74 | PyAPI_FUNC(void) _Py_NO_RETURN Py_Exit(int); |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 75 | |
| 76 | /* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */ |
| 77 | #ifndef Py_LIMITED_API |
| 78 | PyAPI_FUNC(void) _Py_RestoreSignals(void); |
| 79 | |
| 80 | PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *); |
| 81 | #endif |
| 82 | |
| 83 | /* Bootstrap __main__ (defined in Modules/main.c) */ |
| 84 | PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv); |
Victor Stinner | 9454060 | 2017-12-16 04:54:22 +0100 | [diff] [blame] | 85 | #ifdef Py_BUILD_CORE |
| 86 | PyAPI_FUNC(int) _Py_UnixMain(int argc, char **argv); |
| 87 | #endif |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 88 | |
| 89 | /* In getpath.c */ |
| 90 | PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void); |
| 91 | PyAPI_FUNC(wchar_t *) Py_GetPrefix(void); |
| 92 | PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void); |
| 93 | PyAPI_FUNC(wchar_t *) Py_GetPath(void); |
Victor Stinner | d434110 | 2017-11-23 00:12:09 +0100 | [diff] [blame] | 94 | #ifdef Py_BUILD_CORE |
Victor Stinner | b1147e4 | 2018-07-21 02:06:16 +0200 | [diff] [blame] | 95 | struct _PyPathConfig; |
Victor Stinner | b1147e4 | 2018-07-21 02:06:16 +0200 | [diff] [blame] | 96 | |
| 97 | PyAPI_FUNC(_PyInitError) _PyPathConfig_SetGlobal( |
Victor Stinner | ecf411c | 2018-07-26 02:37:22 +0200 | [diff] [blame] | 98 | const struct _PyPathConfig *config); |
Victor Stinner | 11a247d | 2017-12-13 21:05:57 +0100 | [diff] [blame] | 99 | PyAPI_FUNC(PyObject*) _PyPathConfig_ComputeArgv0(int argc, wchar_t **argv); |
Victor Stinner | 9bee329 | 2017-12-21 16:49:13 +0100 | [diff] [blame] | 100 | PyAPI_FUNC(int) _Py_FindEnvConfigValue( |
| 101 | FILE *env_file, |
| 102 | const wchar_t *key, |
| 103 | wchar_t *value, |
| 104 | size_t value_size); |
Victor Stinner | d434110 | 2017-11-23 00:12:09 +0100 | [diff] [blame] | 105 | #endif |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 106 | PyAPI_FUNC(void) Py_SetPath(const wchar_t *); |
| 107 | #ifdef MS_WINDOWS |
Victor Stinner | 31a8393 | 2017-12-04 13:39:15 +0100 | [diff] [blame] | 108 | int _Py_CheckPython3(void); |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 109 | #endif |
| 110 | |
| 111 | /* In their own files */ |
| 112 | PyAPI_FUNC(const char *) Py_GetVersion(void); |
| 113 | PyAPI_FUNC(const char *) Py_GetPlatform(void); |
| 114 | PyAPI_FUNC(const char *) Py_GetCopyright(void); |
| 115 | PyAPI_FUNC(const char *) Py_GetCompiler(void); |
| 116 | PyAPI_FUNC(const char *) Py_GetBuildInfo(void); |
| 117 | #ifndef Py_LIMITED_API |
Ned Deily | 5c4b0d0 | 2017-03-04 00:19:55 -0500 | [diff] [blame] | 118 | PyAPI_FUNC(const char *) _Py_gitidentifier(void); |
| 119 | PyAPI_FUNC(const char *) _Py_gitversion(void); |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 120 | #endif |
| 121 | |
| 122 | /* Internal -- various one-time initializations */ |
| 123 | #ifndef Py_LIMITED_API |
| 124 | PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void); |
Victor Stinner | f7e5b56 | 2017-11-15 15:48:08 -0800 | [diff] [blame] | 125 | PyAPI_FUNC(_PyInitError) _PySys_BeginInit(PyObject **sysmod); |
Victor Stinner | fbca908 | 2018-08-30 00:50:45 +0200 | [diff] [blame] | 126 | PyAPI_FUNC(int) _PySys_EndInit(PyObject *sysdict, PyInterpreterState *interp); |
Victor Stinner | 672b6ba | 2017-12-06 17:25:50 +0100 | [diff] [blame] | 127 | PyAPI_FUNC(_PyInitError) _PyImport_Init(PyInterpreterState *interp); |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 128 | PyAPI_FUNC(void) _PyExc_Init(PyObject * bltinmod); |
Victor Stinner | f7e5b56 | 2017-11-15 15:48:08 -0800 | [diff] [blame] | 129 | PyAPI_FUNC(_PyInitError) _PyImportHooks_Init(void); |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 130 | PyAPI_FUNC(int) _PyFloat_Init(void); |
| 131 | PyAPI_FUNC(int) PyByteArray_Init(void); |
Victor Stinner | 358e5e1 | 2017-12-15 00:51:22 +0100 | [diff] [blame] | 132 | PyAPI_FUNC(_PyInitError) _Py_HashRandomization_Init(const _PyCoreConfig *); |
| 133 | #endif |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 134 | |
| 135 | /* Various internal finalizers */ |
Victor Stinner | 92a3c6f | 2017-12-06 18:12:59 +0100 | [diff] [blame] | 136 | |
| 137 | #ifdef Py_BUILD_CORE |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 138 | PyAPI_FUNC(void) _PyExc_Fini(void); |
| 139 | PyAPI_FUNC(void) _PyImport_Fini(void); |
Victor Stinner | 92a3c6f | 2017-12-06 18:12:59 +0100 | [diff] [blame] | 140 | PyAPI_FUNC(void) _PyImport_Fini2(void); |
| 141 | PyAPI_FUNC(void) _PyGC_DumpShutdownStats(void); |
| 142 | PyAPI_FUNC(void) _PyGC_Fini(void); |
| 143 | PyAPI_FUNC(void) _PyType_Fini(void); |
| 144 | PyAPI_FUNC(void) _Py_HashRandomization_Fini(void); |
| 145 | #endif /* Py_BUILD_CORE */ |
| 146 | |
| 147 | #ifndef Py_LIMITED_API |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 148 | PyAPI_FUNC(void) PyMethod_Fini(void); |
| 149 | PyAPI_FUNC(void) PyFrame_Fini(void); |
| 150 | PyAPI_FUNC(void) PyCFunction_Fini(void); |
| 151 | PyAPI_FUNC(void) PyDict_Fini(void); |
| 152 | PyAPI_FUNC(void) PyTuple_Fini(void); |
| 153 | PyAPI_FUNC(void) PyList_Fini(void); |
| 154 | PyAPI_FUNC(void) PySet_Fini(void); |
| 155 | PyAPI_FUNC(void) PyBytes_Fini(void); |
| 156 | PyAPI_FUNC(void) PyByteArray_Fini(void); |
| 157 | PyAPI_FUNC(void) PyFloat_Fini(void); |
| 158 | PyAPI_FUNC(void) PyOS_FiniInterrupts(void); |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 159 | PyAPI_FUNC(void) PySlice_Fini(void); |
Yury Selivanov | eb63645 | 2016-09-08 22:01:51 -0700 | [diff] [blame] | 160 | PyAPI_FUNC(void) PyAsyncGen_Fini(void); |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 161 | |
Eric Snow | 2ebc5ce | 2017-09-07 23:51:28 -0600 | [diff] [blame] | 162 | PyAPI_FUNC(int) _Py_IsFinalizing(void); |
Victor Stinner | 92a3c6f | 2017-12-06 18:12:59 +0100 | [diff] [blame] | 163 | #endif /* !Py_LIMITED_API */ |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 164 | |
| 165 | /* Signals */ |
| 166 | typedef void (*PyOS_sighandler_t)(int); |
| 167 | PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int); |
| 168 | PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t); |
| 169 | |
Serhiy Storchaka | 9fab79b | 2016-09-11 11:03:14 +0300 | [diff] [blame] | 170 | #ifndef Py_LIMITED_API |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 171 | /* Random */ |
Victor Stinner | e66987e | 2016-09-06 16:33:52 -0700 | [diff] [blame] | 172 | PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size); |
| 173 | PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size); |
Serhiy Storchaka | 9fab79b | 2016-09-11 11:03:14 +0300 | [diff] [blame] | 174 | #endif /* !Py_LIMITED_API */ |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 175 | |
Erik Bray | 031c4bf | 2017-10-27 11:46:03 +0200 | [diff] [blame] | 176 | /* Legacy locale support */ |
| 177 | #ifndef Py_LIMITED_API |
Victor Stinner | b2457ef | 2018-08-29 13:25:36 +0200 | [diff] [blame] | 178 | PyAPI_FUNC(void) _Py_CoerceLegacyLocale(int warn); |
Erik Bray | 031c4bf | 2017-10-27 11:46:03 +0200 | [diff] [blame] | 179 | PyAPI_FUNC(int) _Py_LegacyLocaleDetected(void); |
xdegaye | 1588be6 | 2017-11-12 12:45:59 +0100 | [diff] [blame] | 180 | PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category); |
Erik Bray | 031c4bf | 2017-10-27 11:46:03 +0200 | [diff] [blame] | 181 | #endif |
Victor Stinner | dfe0dc7 | 2018-08-29 11:47:29 +0200 | [diff] [blame] | 182 | #ifdef Py_BUILD_CORE |
| 183 | PyAPI_FUNC(int) _Py_IsLocaleCoercionTarget(const char *ctype_loc); |
| 184 | #endif |
Erik Bray | 031c4bf | 2017-10-27 11:46:03 +0200 | [diff] [blame] | 185 | |
Nick Coghlan | d600951 | 2014-11-20 21:39:37 +1000 | [diff] [blame] | 186 | #ifdef __cplusplus |
| 187 | } |
| 188 | #endif |
| 189 | #endif /* !Py_PYLIFECYCLE_H */ |