Debian Codegraph @

Include/cpython/initconfig.h

raw
1 #ifndef Py_PYCORECONFIG_H
2 #define Py_PYCORECONFIG_H
3 #ifndef Py_LIMITED_API
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 /* --- PyStatus ----------------------------------------------- */
9
10 typedef struct {
11 enum {
12 _PyStatus_TYPE_OK=0,
13 _PyStatus_TYPE_ERROR=1,
14 _PyStatus_TYPE_EXIT=2
15 } _type;
16 const char *func;
17 const char *err_msg;
18 int exitcode;
19 } PyStatus;
20
21 PyAPI_FUNC(PyStatus) PyStatus_Ok(void);
22 PyAPI_FUNC(PyStatus) PyStatus_Error(const char *err_msg);
23 PyAPI_FUNC(PyStatus) PyStatus_NoMemory(void);
24 PyAPI_FUNC(PyStatus) PyStatus_Exit(int exitcode);
25 PyAPI_FUNC(int) PyStatus_IsError(PyStatus err);
26 PyAPI_FUNC(int) PyStatus_IsExit(PyStatus err);
27 PyAPI_FUNC(int) PyStatus_Exception(PyStatus err);
28
29 /* --- PyWideStringList ------------------------------------------------ */
30
31 typedef struct {
32 /* If length is greater than zero, items must be non-NULL
33 and all items strings must be non-NULL */
34 Py_ssize_t length;
35 wchar_t **items;
36 } PyWideStringList;
37
38 PyAPI_FUNC(PyStatus) PyWideStringList_Append(PyWideStringList *list,
39 const wchar_t *item);
40 PyAPI_FUNC(PyStatus) PyWideStringList_Insert(PyWideStringList *list,
41 Py_ssize_t index,
42 const wchar_t *item);
43
44
45 /* --- PyPreConfig ----------------------------------------------- */
46
47 typedef struct PyPreConfig {
48 int _config_init; /* _PyConfigInitEnum value */
49
50 /* Parse Py_PreInitializeFromBytesArgs() arguments?
51 See PyConfig.parse_argv */
52 int parse_argv;
53
54 /* If greater than 0, enable isolated mode: sys.path contains
55 neither the script's directory nor the user's site-packages directory.
56
57 Set to 1 by the -I command line option. If set to -1 (default), inherit
58 Py_IsolatedFlag value. */
59 int isolated;
60
61 /* If greater than 0: use environment variables.
62 Set to 0 by -E command line option. If set to -1 (default), it is
63 set to !Py_IgnoreEnvironmentFlag. */
64 int use_environment;
65
66 /* Set the LC_CTYPE locale to the user preferred locale? If equals to 0,
67 set coerce_c_locale and coerce_c_locale_warn to 0. */
68 int configure_locale;
69
70 /* Coerce the LC_CTYPE locale if it's equal to "C"? (PEP 538)
71
72 Set to 0 by PYTHONCOERCECLOCALE=0. Set to 1 by PYTHONCOERCECLOCALE=1.
73 Set to 2 if the user preferred LC_CTYPE locale is "C".
74
75 If it is equal to 1, LC_CTYPE locale is read to decide if it should be
76 coerced or not (ex: PYTHONCOERCECLOCALE=1). Internally, it is set to 2
77 if the LC_CTYPE locale must be coerced.
78
79 Disable by default (set to 0). Set it to -1 to let Python decide if it
80 should be enabled or not. */
81 int coerce_c_locale;
82
83 /* Emit a warning if the LC_CTYPE locale is coerced?
84
85 Set to 1 by PYTHONCOERCECLOCALE=warn.
86
87 Disable by default (set to 0). Set it to -1 to let Python decide if it
88 should be enabled or not. */
89 int coerce_c_locale_warn;
90
91 #ifdef MS_WINDOWS
92 /* If greater than 1, use the "mbcs" encoding instead of the UTF-8
93 encoding for the filesystem encoding.
94
95 Set to 1 if the PYTHONLEGACYWINDOWSFSENCODING environment variable is
96 set to a non-empty string. If set to -1 (default), inherit
97 Py_LegacyWindowsFSEncodingFlag value.
98
99 See PEP 529 for more details. */
100 int legacy_windows_fs_encoding;
101 #endif
102
103 /* Enable UTF-8 mode? (PEP 540)
104
105 Disabled by default (equals to 0).
106
107 Set to 1 by "-X utf8" and "-X utf8=1" command line options.
108 Set to 1 by PYTHONUTF8=1 environment variable.
109
110 Set to 0 by "-X utf8=0" and PYTHONUTF8=0.
111
112 If equals to -1, it is set to 1 if the LC_CTYPE locale is "C" or
113 "POSIX", otherwise it is set to 0. Inherit Py_UTF8Mode value value. */
114 int utf8_mode;
115
116 /* If non-zero, enable the Python Development Mode.
117
118 Set to 1 by the -X dev command line option. Set by the PYTHONDEVMODE
119 environment variable. */
120 int dev_mode;
121
122 /* Memory allocator: PYTHONMALLOC env var.
123 See PyMemAllocatorName for valid values. */
124 int allocator;
125 } PyPreConfig;
126
127 PyAPI_FUNC(void) PyPreConfig_InitPythonConfig(PyPreConfig *config);
128 PyAPI_FUNC(void) PyPreConfig_InitIsolatedConfig(PyPreConfig *config);
129
130
131 /* --- PyConfig ---------------------------------------------- */
132
133 /* This structure is best documented in the Doc/c-api/init_config.rst file. */
134 typedef struct PyConfig {
135 int _config_init; /* _PyConfigInitEnum value */
136
137 int isolated;
138 int use_environment;
139 int dev_mode;
140 int install_signal_handlers;
141 int use_hash_seed;
142 unsigned long hash_seed;
143 int faulthandler;
144 int tracemalloc;
145 int perf_profiling;
146 int import_time;
147 int code_debug_ranges;
148 int show_ref_count;
149 int dump_refs;
150 wchar_t *dump_refs_file;
151 int malloc_stats;
152 wchar_t *filesystem_encoding;
153 wchar_t *filesystem_errors;
154 wchar_t *pycache_prefix;
155 int parse_argv;
156 PyWideStringList orig_argv;
157 PyWideStringList argv;
158 PyWideStringList xoptions;
159 PyWideStringList warnoptions;
160 int site_import;
161 int bytes_warning;
162 int warn_default_encoding;
163 int inspect;
164 int interactive;
165 int optimization_level;
166 int parser_debug;
167 int write_bytecode;
168 int verbose;
169 int quiet;
170 int user_site_directory;
171 int configure_c_stdio;
172 int buffered_stdio;
173 wchar_t *stdio_encoding;
174 wchar_t *stdio_errors;
175 #ifdef MS_WINDOWS
176 int legacy_windows_stdio;
177 #endif
178 wchar_t *check_hash_pycs_mode;
179 int use_frozen_modules;
180 int safe_path;
181 int int_max_str_digits;
182
183 int cpu_count;
184 #ifdef Py_GIL_DISABLED
185 int enable_gil;
186 #endif
187
188 /* --- Path configuration inputs ------------ */
189 int pathconfig_warnings;
190 wchar_t *program_name;
191 wchar_t *pythonpath_env;
192 wchar_t *home;
193 wchar_t *platlibdir;
194
195 /* --- Path configuration outputs ----------- */
196 int module_search_paths_set;
197 PyWideStringList module_search_paths;
198 wchar_t *stdlib_dir;
199 wchar_t *executable;
200 wchar_t *base_executable;
201 wchar_t *prefix;
202 wchar_t *base_prefix;
203 wchar_t *exec_prefix;
204 wchar_t *base_exec_prefix;
205
206 /* --- Parameter only used by Py_Main() ---------- */
207 int skip_source_first_line;
208 wchar_t *run_command;
209 wchar_t *run_module;
210 wchar_t *run_filename;
211
212 /* --- Set by Py_Main() -------------------------- */
213 wchar_t *sys_path_0;
214
215 /* --- Private fields ---------------------------- */
216
217 // Install importlib? If equals to 0, importlib is not initialized at all.
218 // Needed by freeze_importlib.
219 int _install_importlib;
220
221 // If equal to 0, stop Python initialization before the "main" phase.
222 int _init_main;
223
224 // If non-zero, we believe we're running from a source tree.
225 int _is_python_build;
226
227 #ifdef Py_STATS
228 // If non-zero, turns on statistics gathering.
229 int _pystats;
230 #endif
231
232 #ifdef Py_DEBUG
233 // If not empty, import a non-__main__ module before site.py is executed.
234 // PYTHON_PRESITE=package.module or -X presite=package.module
235 wchar_t *run_presite;
236 #endif
237 } PyConfig;
238
239 PyAPI_FUNC(void) PyConfig_InitPythonConfig(PyConfig *config);
240 PyAPI_FUNC(void) PyConfig_InitIsolatedConfig(PyConfig *config);
241 PyAPI_FUNC(void) PyConfig_Clear(PyConfig *);
242 PyAPI_FUNC(PyStatus) PyConfig_SetString(
243 PyConfig *config,
244 wchar_t **config_str,
245 const wchar_t *str);
246 PyAPI_FUNC(PyStatus) PyConfig_SetBytesString(
247 PyConfig *config,
248 wchar_t **config_str,
249 const char *str);
250 PyAPI_FUNC(PyStatus) PyConfig_Read(PyConfig *config);
251 PyAPI_FUNC(PyStatus) PyConfig_SetBytesArgv(
252 PyConfig *config,
253 Py_ssize_t argc,
254 char * const *argv);
255 PyAPI_FUNC(PyStatus) PyConfig_SetArgv(PyConfig *config,
256 Py_ssize_t argc,
257 wchar_t * const *argv);
258 PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config,
259 PyWideStringList *list,
260 Py_ssize_t length, wchar_t **items);
261
262
263 /* --- Helper functions --------------------------------------- */
264
265 /* Get the original command line arguments, before Python modified them.
266
267 See also PyConfig.orig_argv. */
268 PyAPI_FUNC(void) Py_GetArgcArgv(int *argc, wchar_t ***argv);
269
270 #ifdef __cplusplus
271 }
272 #endif
273 #endif /* !Py_LIMITED_API */
274 #endif /* !Py_PYCORECONFIG_H */