codekingpro/portable-devtools
115k
1#ifndef Py_PYCORECONFIG_H2#define Py_PYCORECONFIG_H3#ifndef Py_LIMITED_API4#ifdef __cplusplus5extern "C" {6#endif7 8/* --- PyStatus ----------------------------------------------- */9 10typedef struct {11 enum {12 _PyStatus_TYPE_OK=0,13 _PyStatus_TYPE_ERROR=1,14 _PyStatus_TYPE_EXIT=215 } _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-NULL33 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 contains55 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), inherit58 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 is63 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 be76 coerced or not (ex: PYTHONCOERCECLOCALE=1). Internally, it is set to 277 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 it80 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 it88 should be enabled or not. */89 int coerce_c_locale_warn;90 91#ifdef MS_WINDOWS92 /* If greater than 1, use the "mbcs" encoding instead of the UTF-893 encoding for the filesystem encoding.94 95 Set to 1 if the PYTHONLEGACYWINDOWSFSENCODING environment variable is96 set to a non-empty string. If set to -1 (default), inherit97 Py_LegacyWindowsFSEncodingFlag value.98 99 See PEP 529 for more details. */100 int legacy_windows_fs_encoding;101#endif102 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" or113 "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 PYTHONDEVMODE119 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 perf_profiling;146 int remote_debug;147 int import_time;148 int code_debug_ranges;149 int show_ref_count;150 int dump_refs;151 wchar_t *dump_refs_file;152 int malloc_stats;153 wchar_t *filesystem_encoding;154 wchar_t *filesystem_errors;155 wchar_t *pycache_prefix;156 int parse_argv;157 PyWideStringList orig_argv;158 PyWideStringList argv;159 PyWideStringList xoptions;160 PyWideStringList warnoptions;161 int site_import;162 int bytes_warning;163 int warn_default_encoding;164 int inspect;165 int interactive;166 int optimization_level;167 int parser_debug;168 int write_bytecode;169 int verbose;170 int quiet;171 int user_site_directory;172 int configure_c_stdio;173 int buffered_stdio;174 wchar_t *stdio_encoding;175 wchar_t *stdio_errors;176#ifdef MS_WINDOWS177 int legacy_windows_stdio;178#endif179 wchar_t *check_hash_pycs_mode;180 int use_frozen_modules;181 int safe_path;182 int int_max_str_digits;183 int thread_inherit_context;184 int context_aware_warnings;185#ifdef __APPLE__186 int use_system_logger;187#endif188 189 int cpu_count;190#ifdef Py_GIL_DISABLED191 int enable_gil;192 int tlbc_enabled;193#endif194 195 /* --- Path configuration inputs ------------ */196 int pathconfig_warnings;197 wchar_t *program_name;198 wchar_t *pythonpath_env;199 wchar_t *home;200 wchar_t *platlibdir;201 202 /* --- Path configuration outputs ----------- */203 int module_search_paths_set;204 PyWideStringList module_search_paths;205 wchar_t *stdlib_dir;206 wchar_t *executable;207 wchar_t *base_executable;208 wchar_t *prefix;209 wchar_t *base_prefix;210 wchar_t *exec_prefix;211 wchar_t *base_exec_prefix;212 213 /* --- Parameter only used by Py_Main() ---------- */214 int skip_source_first_line;215 wchar_t *run_command;216 wchar_t *run_module;217 wchar_t *run_filename;218 219 /* --- Set by Py_Main() -------------------------- */220 wchar_t *sys_path_0;221 222 /* --- Private fields ---------------------------- */223 224 // Install importlib? If equals to 0, importlib is not initialized at all.225 // Needed by freeze_importlib.226 int _install_importlib;227 228 // If equal to 0, stop Python initialization before the "main" phase.229 int _init_main;230 231 // If non-zero, we believe we're running from a source tree.232 int _is_python_build;233 234#ifdef Py_STATS235 // If non-zero, turns on statistics gathering.236 int _pystats;237#endif238 239#ifdef Py_DEBUG240 // If not empty, import a non-__main__ module before site.py is executed.241 // PYTHON_PRESITE=package.module or -X presite=package.module242 wchar_t *run_presite;243#endif244} PyConfig;245 246PyAPI_FUNC(void) PyConfig_InitPythonConfig(PyConfig *config);247PyAPI_FUNC(void) PyConfig_InitIsolatedConfig(PyConfig *config);248PyAPI_FUNC(void) PyConfig_Clear(PyConfig *);249PyAPI_FUNC(PyStatus) PyConfig_SetString(250 PyConfig *config,251 wchar_t **config_str,252 const wchar_t *str);253PyAPI_FUNC(PyStatus) PyConfig_SetBytesString(254 PyConfig *config,255 wchar_t **config_str,256 const char *str);257PyAPI_FUNC(PyStatus) PyConfig_Read(PyConfig *config);258PyAPI_FUNC(PyStatus) PyConfig_SetBytesArgv(259 PyConfig *config,260 Py_ssize_t argc,261 char * const *argv);262PyAPI_FUNC(PyStatus) PyConfig_SetArgv(PyConfig *config,263 Py_ssize_t argc,264 wchar_t * const *argv);265PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config,266 PyWideStringList *list,267 Py_ssize_t length, wchar_t **items);268 269 270/* --- PyConfig_Get() ----------------------------------------- */271 272PyAPI_FUNC(PyObject*) PyConfig_Get(const char *name);273PyAPI_FUNC(int) PyConfig_GetInt(const char *name, int *value);274PyAPI_FUNC(PyObject*) PyConfig_Names(void);275PyAPI_FUNC(int) PyConfig_Set(const char *name, PyObject *value);276 277 278/* --- Helper functions --------------------------------------- */279 280/* Get the original command line arguments, before Python modified them.281 282 See also PyConfig.orig_argv. */283PyAPI_FUNC(void) Py_GetArgcArgv(int *argc, wchar_t ***argv);284 285 286// --- PyInitConfig ---------------------------------------------------------287 288typedef struct PyInitConfig PyInitConfig;289 290PyAPI_FUNC(PyInitConfig*) PyInitConfig_Create(void);291PyAPI_FUNC(void) PyInitConfig_Free(PyInitConfig *config);292 293PyAPI_FUNC(int) PyInitConfig_GetError(PyInitConfig* config,294 const char **err_msg);295PyAPI_FUNC(int) PyInitConfig_GetExitCode(PyInitConfig* config,296 int *exitcode);297 298PyAPI_FUNC(int) PyInitConfig_HasOption(PyInitConfig *config,299 const char *name);300PyAPI_FUNC(int) PyInitConfig_GetInt(PyInitConfig *config,301 const char *name,302 int64_t *value);303PyAPI_FUNC(int) PyInitConfig_GetStr(PyInitConfig *config,304 const char *name,305 char **value);306PyAPI_FUNC(int) PyInitConfig_GetStrList(PyInitConfig *config,307 const char *name,308 size_t *length,309 char ***items);310PyAPI_FUNC(void) PyInitConfig_FreeStrList(size_t length, char **items);311 312PyAPI_FUNC(int) PyInitConfig_SetInt(PyInitConfig *config,313 const char *name,314 int64_t value);315PyAPI_FUNC(int) PyInitConfig_SetStr(PyInitConfig *config,316 const char *name,317 const char *value);318PyAPI_FUNC(int) PyInitConfig_SetStrList(PyInitConfig *config,319 const char *name,320 size_t length,321 char * const *items);322 323PyAPI_FUNC(int) PyInitConfig_AddModule(PyInitConfig *config,324 const char *name,325 PyObject* (*initfunc)(void));326 327PyAPI_FUNC(int) Py_InitializeFromInitConfig(PyInitConfig *config);328 329 330#ifdef __cplusplus331}332#endif333#endif /* !Py_LIMITED_API */334#endif /* !Py_PYCORECONFIG_H */335 