1#ifndef Py_PYCORECONFIG_H
2#define Py_PYCORECONFIG_H
3#ifndef Py_LIMITED_API
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8/* --- PyStatus ----------------------------------------------- */
9
10typedef 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
21PyAPI_FUNC(PyStatus) PyStatus_Ok(void);
22PyAPI_FUNC(PyStatus) PyStatus_Error(const char *err_msg);
23PyAPI_FUNC(PyStatus) PyStatus_NoMemory(void);
24PyAPI_FUNC(PyStatus) PyStatus_Exit(int exitcode);
25PyAPI_FUNC(int) PyStatus_IsError(PyStatus err);
26PyAPI_FUNC(int) PyStatus_IsExit(PyStatus err);
27PyAPI_FUNC(int) PyStatus_Exception(PyStatus err);
28
29/* --- PyWideStringList ------------------------------------------------ */
30
31typedef 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
38PyAPI_FUNC(PyStatus) PyWideStringList_Append(PyWideStringList *list,
39 const wchar_t *item);
40PyAPI_FUNC(PyStatus) PyWideStringList_Insert(PyWideStringList *list,
41 Py_ssize_t index,
42 const wchar_t *item);
43
44
45/* --- PyPreConfig ----------------------------------------------- */
46
47typedef 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
127PyAPI_FUNC(void) PyPreConfig_InitPythonConfig(PyPreConfig *config);
128PyAPI_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. */
134typedef 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 import_time;
146 int show_ref_count;
147 int dump_refs;
148 int malloc_stats;
149 wchar_t *filesystem_encoding;
150 wchar_t *filesystem_errors;
151 wchar_t *pycache_prefix;
152 int parse_argv;
153 PyWideStringList orig_argv;
154 PyWideStringList argv;
155 PyWideStringList xoptions;
156 PyWideStringList warnoptions;
157 int site_import;
158 int bytes_warning;
159 int warn_default_encoding;
160 int inspect;
161 int interactive;
162 int optimization_level;
163 int parser_debug;
164 int write_bytecode;
165 int verbose;
166 int quiet;
167 int user_site_directory;
168 int configure_c_stdio;
169 int buffered_stdio;
170 wchar_t *stdio_encoding;
171 wchar_t *stdio_errors;
172#ifdef MS_WINDOWS
173 int legacy_windows_stdio;
174#endif
175 wchar_t *check_hash_pycs_mode;
176
177 /* --- Path configuration inputs ------------ */
178 int pathconfig_warnings;
179 wchar_t *program_name;
180 wchar_t *pythonpath_env;
181 wchar_t *home;
182 wchar_t *platlibdir;
183
184 /* --- Path configuration outputs ----------- */
185 int module_search_paths_set;
186 PyWideStringList module_search_paths;
187 wchar_t *executable;
188 wchar_t *base_executable;
189 wchar_t *prefix;
190 wchar_t *base_prefix;
191 wchar_t *exec_prefix;
192 wchar_t *base_exec_prefix;
193
194 /* --- Parameter only used by Py_Main() ---------- */
195 int skip_source_first_line;
196 wchar_t *run_command;
197 wchar_t *run_module;
198 wchar_t *run_filename;
199
200 /* --- Private fields ---------------------------- */
201
202 // Install importlib? If equals to 0, importlib is not initialized at all.
203 // Needed by freeze_importlib.
204 int _install_importlib;
205
206 // If equal to 0, stop Python initialization before the "main" phase.
207 int _init_main;
208
209 // If non-zero, disallow threads, subprocesses, and fork.
210 // Default: 0.
211 int _isolated_interpreter;
212} PyConfig;
213
214PyAPI_FUNC(void) PyConfig_InitPythonConfig(PyConfig *config);
215PyAPI_FUNC(void) PyConfig_InitIsolatedConfig(PyConfig *config);
216PyAPI_FUNC(void) PyConfig_Clear(PyConfig *);
217PyAPI_FUNC(PyStatus) PyConfig_SetString(
218 PyConfig *config,
219 wchar_t **config_str,
220 const wchar_t *str);
221PyAPI_FUNC(PyStatus) PyConfig_SetBytesString(
222 PyConfig *config,
223 wchar_t **config_str,
224 const char *str);
225PyAPI_FUNC(PyStatus) PyConfig_Read(PyConfig *config);
226PyAPI_FUNC(PyStatus) PyConfig_SetBytesArgv(
227 PyConfig *config,
228 Py_ssize_t argc,
229 char * const *argv);
230PyAPI_FUNC(PyStatus) PyConfig_SetArgv(PyConfig *config,
231 Py_ssize_t argc,
232 wchar_t * const *argv);
233PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config,
234 PyWideStringList *list,
235 Py_ssize_t length, wchar_t **items);
236
237
238/* --- Helper functions --------------------------------------- */
239
240/* Get the original command line arguments, before Python modified them.
241
242 See also PyConfig.orig_argv. */
243PyAPI_FUNC(void) Py_GetArgcArgv(int *argc, wchar_t ***argv);
244
245#ifdef __cplusplus
246}
247#endif
248#endif /* !Py_LIMITED_API */
249#endif /* !Py_PYCORECONFIG_H */
250

source code of include/python3.10/cpython/initconfig.h