Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:41

0001 #ifndef Py_PYCORECONFIG_H
0002 #define Py_PYCORECONFIG_H
0003 #ifndef Py_LIMITED_API
0004 #ifdef __cplusplus
0005 extern "C" {
0006 #endif
0007 
0008 /* --- PyStatus ----------------------------------------------- */
0009 
0010 typedef struct {
0011     enum {
0012         _PyStatus_TYPE_OK=0,
0013         _PyStatus_TYPE_ERROR=1,
0014         _PyStatus_TYPE_EXIT=2
0015     } _type;
0016     const char *func;
0017     const char *err_msg;
0018     int exitcode;
0019 } PyStatus;
0020 
0021 PyAPI_FUNC(PyStatus) PyStatus_Ok(void);
0022 PyAPI_FUNC(PyStatus) PyStatus_Error(const char *err_msg);
0023 PyAPI_FUNC(PyStatus) PyStatus_NoMemory(void);
0024 PyAPI_FUNC(PyStatus) PyStatus_Exit(int exitcode);
0025 PyAPI_FUNC(int) PyStatus_IsError(PyStatus err);
0026 PyAPI_FUNC(int) PyStatus_IsExit(PyStatus err);
0027 PyAPI_FUNC(int) PyStatus_Exception(PyStatus err);
0028 
0029 /* --- PyWideStringList ------------------------------------------------ */
0030 
0031 typedef struct {
0032     /* If length is greater than zero, items must be non-NULL
0033        and all items strings must be non-NULL */
0034     Py_ssize_t length;
0035     wchar_t **items;
0036 } PyWideStringList;
0037 
0038 PyAPI_FUNC(PyStatus) PyWideStringList_Append(PyWideStringList *list,
0039     const wchar_t *item);
0040 PyAPI_FUNC(PyStatus) PyWideStringList_Insert(PyWideStringList *list,
0041     Py_ssize_t index,
0042     const wchar_t *item);
0043 
0044 
0045 /* --- PyPreConfig ----------------------------------------------- */
0046 
0047 typedef struct PyPreConfig {
0048     int _config_init;     /* _PyConfigInitEnum value */
0049 
0050     /* Parse Py_PreInitializeFromBytesArgs() arguments?
0051        See PyConfig.parse_argv */
0052     int parse_argv;
0053 
0054     /* If greater than 0, enable isolated mode: sys.path contains
0055        neither the script's directory nor the user's site-packages directory.
0056 
0057        Set to 1 by the -I command line option. If set to -1 (default), inherit
0058        Py_IsolatedFlag value. */
0059     int isolated;
0060 
0061     /* If greater than 0: use environment variables.
0062        Set to 0 by -E command line option. If set to -1 (default), it is
0063        set to !Py_IgnoreEnvironmentFlag. */
0064     int use_environment;
0065 
0066     /* Set the LC_CTYPE locale to the user preferred locale? If equals to 0,
0067        set coerce_c_locale and coerce_c_locale_warn to 0. */
0068     int configure_locale;
0069 
0070     /* Coerce the LC_CTYPE locale if it's equal to "C"? (PEP 538)
0071 
0072        Set to 0 by PYTHONCOERCECLOCALE=0. Set to 1 by PYTHONCOERCECLOCALE=1.
0073        Set to 2 if the user preferred LC_CTYPE locale is "C".
0074 
0075        If it is equal to 1, LC_CTYPE locale is read to decide if it should be
0076        coerced or not (ex: PYTHONCOERCECLOCALE=1). Internally, it is set to 2
0077        if the LC_CTYPE locale must be coerced.
0078 
0079        Disable by default (set to 0). Set it to -1 to let Python decide if it
0080        should be enabled or not. */
0081     int coerce_c_locale;
0082 
0083     /* Emit a warning if the LC_CTYPE locale is coerced?
0084 
0085        Set to 1 by PYTHONCOERCECLOCALE=warn.
0086 
0087        Disable by default (set to 0). Set it to -1 to let Python decide if it
0088        should be enabled or not. */
0089     int coerce_c_locale_warn;
0090 
0091 #ifdef MS_WINDOWS
0092     /* If greater than 1, use the "mbcs" encoding instead of the UTF-8
0093        encoding for the filesystem encoding.
0094 
0095        Set to 1 if the PYTHONLEGACYWINDOWSFSENCODING environment variable is
0096        set to a non-empty string. If set to -1 (default), inherit
0097        Py_LegacyWindowsFSEncodingFlag value.
0098 
0099        See PEP 529 for more details. */
0100     int legacy_windows_fs_encoding;
0101 #endif
0102 
0103     /* Enable UTF-8 mode? (PEP 540)
0104 
0105        Disabled by default (equals to 0).
0106 
0107        Set to 1 by "-X utf8" and "-X utf8=1" command line options.
0108        Set to 1 by PYTHONUTF8=1 environment variable.
0109 
0110        Set to 0 by "-X utf8=0" and PYTHONUTF8=0.
0111 
0112        If equals to -1, it is set to 1 if the LC_CTYPE locale is "C" or
0113        "POSIX", otherwise it is set to 0. Inherit Py_UTF8Mode value value. */
0114     int utf8_mode;
0115 
0116     /* If non-zero, enable the Python Development Mode.
0117 
0118        Set to 1 by the -X dev command line option. Set by the PYTHONDEVMODE
0119        environment variable. */
0120     int dev_mode;
0121 
0122     /* Memory allocator: PYTHONMALLOC env var.
0123        See PyMemAllocatorName for valid values. */
0124     int allocator;
0125 } PyPreConfig;
0126 
0127 PyAPI_FUNC(void) PyPreConfig_InitPythonConfig(PyPreConfig *config);
0128 PyAPI_FUNC(void) PyPreConfig_InitIsolatedConfig(PyPreConfig *config);
0129 
0130 
0131 /* --- PyConfig ---------------------------------------------- */
0132 
0133 /* This structure is best documented in the Doc/c-api/init_config.rst file. */
0134 typedef struct PyConfig {
0135     int _config_init;     /* _PyConfigInitEnum value */
0136 
0137     int isolated;
0138     int use_environment;
0139     int dev_mode;
0140     int install_signal_handlers;
0141     int use_hash_seed;
0142     unsigned long hash_seed;
0143     int faulthandler;
0144     int tracemalloc;
0145     int perf_profiling;
0146     int import_time;
0147     int code_debug_ranges;
0148     int show_ref_count;
0149     int dump_refs;
0150     wchar_t *dump_refs_file;
0151     int malloc_stats;
0152     wchar_t *filesystem_encoding;
0153     wchar_t *filesystem_errors;
0154     wchar_t *pycache_prefix;
0155     int parse_argv;
0156     PyWideStringList orig_argv;
0157     PyWideStringList argv;
0158     PyWideStringList xoptions;
0159     PyWideStringList warnoptions;
0160     int site_import;
0161     int bytes_warning;
0162     int warn_default_encoding;
0163     int inspect;
0164     int interactive;
0165     int optimization_level;
0166     int parser_debug;
0167     int write_bytecode;
0168     int verbose;
0169     int quiet;
0170     int user_site_directory;
0171     int configure_c_stdio;
0172     int buffered_stdio;
0173     wchar_t *stdio_encoding;
0174     wchar_t *stdio_errors;
0175 #ifdef MS_WINDOWS
0176     int legacy_windows_stdio;
0177 #endif
0178     wchar_t *check_hash_pycs_mode;
0179     int use_frozen_modules;
0180     int safe_path;
0181     int int_max_str_digits;
0182 
0183     int cpu_count;
0184 #ifdef Py_GIL_DISABLED
0185     int enable_gil;
0186 #endif
0187 
0188     /* --- Path configuration inputs ------------ */
0189     int pathconfig_warnings;
0190     wchar_t *program_name;
0191     wchar_t *pythonpath_env;
0192     wchar_t *home;
0193     wchar_t *platlibdir;
0194 
0195     /* --- Path configuration outputs ----------- */
0196     int module_search_paths_set;
0197     PyWideStringList module_search_paths;
0198     wchar_t *stdlib_dir;
0199     wchar_t *executable;
0200     wchar_t *base_executable;
0201     wchar_t *prefix;
0202     wchar_t *base_prefix;
0203     wchar_t *exec_prefix;
0204     wchar_t *base_exec_prefix;
0205 
0206     /* --- Parameter only used by Py_Main() ---------- */
0207     int skip_source_first_line;
0208     wchar_t *run_command;
0209     wchar_t *run_module;
0210     wchar_t *run_filename;
0211 
0212     /* --- Set by Py_Main() -------------------------- */
0213     wchar_t *sys_path_0;
0214 
0215     /* --- Private fields ---------------------------- */
0216 
0217     // Install importlib? If equals to 0, importlib is not initialized at all.
0218     // Needed by freeze_importlib.
0219     int _install_importlib;
0220 
0221     // If equal to 0, stop Python initialization before the "main" phase.
0222     int _init_main;
0223 
0224     // If non-zero, we believe we're running from a source tree.
0225     int _is_python_build;
0226 
0227 #ifdef Py_STATS
0228     // If non-zero, turns on statistics gathering.
0229     int _pystats;
0230 #endif
0231 
0232 #ifdef Py_DEBUG
0233     // If not empty, import a non-__main__ module before site.py is executed.
0234     // PYTHON_PRESITE=package.module or -X presite=package.module
0235     wchar_t *run_presite;
0236 #endif
0237 } PyConfig;
0238 
0239 PyAPI_FUNC(void) PyConfig_InitPythonConfig(PyConfig *config);
0240 PyAPI_FUNC(void) PyConfig_InitIsolatedConfig(PyConfig *config);
0241 PyAPI_FUNC(void) PyConfig_Clear(PyConfig *);
0242 PyAPI_FUNC(PyStatus) PyConfig_SetString(
0243     PyConfig *config,
0244     wchar_t **config_str,
0245     const wchar_t *str);
0246 PyAPI_FUNC(PyStatus) PyConfig_SetBytesString(
0247     PyConfig *config,
0248     wchar_t **config_str,
0249     const char *str);
0250 PyAPI_FUNC(PyStatus) PyConfig_Read(PyConfig *config);
0251 PyAPI_FUNC(PyStatus) PyConfig_SetBytesArgv(
0252     PyConfig *config,
0253     Py_ssize_t argc,
0254     char * const *argv);
0255 PyAPI_FUNC(PyStatus) PyConfig_SetArgv(PyConfig *config,
0256     Py_ssize_t argc,
0257     wchar_t * const *argv);
0258 PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config,
0259     PyWideStringList *list,
0260     Py_ssize_t length, wchar_t **items);
0261 
0262 
0263 /* --- Helper functions --------------------------------------- */
0264 
0265 /* Get the original command line arguments, before Python modified them.
0266 
0267    See also PyConfig.orig_argv. */
0268 PyAPI_FUNC(void) Py_GetArgcArgv(int *argc, wchar_t ***argv);
0269 
0270 #ifdef __cplusplus
0271 }
0272 #endif
0273 #endif /* !Py_LIMITED_API */
0274 #endif /* !Py_PYCORECONFIG_H */