Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 09:20:54

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