jpayne@69: #ifndef Py_PYCORECONFIG_H jpayne@69: #define Py_PYCORECONFIG_H jpayne@69: #ifndef Py_LIMITED_API jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /* --- PyStatus ----------------------------------------------- */ jpayne@69: jpayne@69: typedef struct { jpayne@69: enum { jpayne@69: _PyStatus_TYPE_OK=0, jpayne@69: _PyStatus_TYPE_ERROR=1, jpayne@69: _PyStatus_TYPE_EXIT=2 jpayne@69: } _type; jpayne@69: const char *func; jpayne@69: const char *err_msg; jpayne@69: int exitcode; jpayne@69: } PyStatus; jpayne@69: jpayne@69: PyAPI_FUNC(PyStatus) PyStatus_Ok(void); jpayne@69: PyAPI_FUNC(PyStatus) PyStatus_Error(const char *err_msg); jpayne@69: PyAPI_FUNC(PyStatus) PyStatus_NoMemory(void); jpayne@69: PyAPI_FUNC(PyStatus) PyStatus_Exit(int exitcode); jpayne@69: PyAPI_FUNC(int) PyStatus_IsError(PyStatus err); jpayne@69: PyAPI_FUNC(int) PyStatus_IsExit(PyStatus err); jpayne@69: PyAPI_FUNC(int) PyStatus_Exception(PyStatus err); jpayne@69: jpayne@69: /* --- PyWideStringList ------------------------------------------------ */ jpayne@69: jpayne@69: typedef struct { jpayne@69: /* If length is greater than zero, items must be non-NULL jpayne@69: and all items strings must be non-NULL */ jpayne@69: Py_ssize_t length; jpayne@69: wchar_t **items; jpayne@69: } PyWideStringList; jpayne@69: jpayne@69: PyAPI_FUNC(PyStatus) PyWideStringList_Append(PyWideStringList *list, jpayne@69: const wchar_t *item); jpayne@69: PyAPI_FUNC(PyStatus) PyWideStringList_Insert(PyWideStringList *list, jpayne@69: Py_ssize_t index, jpayne@69: const wchar_t *item); jpayne@69: jpayne@69: jpayne@69: /* --- PyPreConfig ----------------------------------------------- */ jpayne@69: jpayne@69: typedef struct { jpayne@69: int _config_init; /* _PyConfigInitEnum value */ jpayne@69: jpayne@69: /* Parse Py_PreInitializeFromBytesArgs() arguments? jpayne@69: See PyConfig.parse_argv */ jpayne@69: int parse_argv; jpayne@69: jpayne@69: /* If greater than 0, enable isolated mode: sys.path contains jpayne@69: neither the script's directory nor the user's site-packages directory. jpayne@69: jpayne@69: Set to 1 by the -I command line option. If set to -1 (default), inherit jpayne@69: Py_IsolatedFlag value. */ jpayne@69: int isolated; jpayne@69: jpayne@69: /* If greater than 0: use environment variables. jpayne@69: Set to 0 by -E command line option. If set to -1 (default), it is jpayne@69: set to !Py_IgnoreEnvironmentFlag. */ jpayne@69: int use_environment; jpayne@69: jpayne@69: /* Set the LC_CTYPE locale to the user preferred locale? If equals to 0, jpayne@69: set coerce_c_locale and coerce_c_locale_warn to 0. */ jpayne@69: int configure_locale; jpayne@69: jpayne@69: /* Coerce the LC_CTYPE locale if it's equal to "C"? (PEP 538) jpayne@69: jpayne@69: Set to 0 by PYTHONCOERCECLOCALE=0. Set to 1 by PYTHONCOERCECLOCALE=1. jpayne@69: Set to 2 if the user preferred LC_CTYPE locale is "C". jpayne@69: jpayne@69: If it is equal to 1, LC_CTYPE locale is read to decide if it should be jpayne@69: coerced or not (ex: PYTHONCOERCECLOCALE=1). Internally, it is set to 2 jpayne@69: if the LC_CTYPE locale must be coerced. jpayne@69: jpayne@69: Disable by default (set to 0). Set it to -1 to let Python decide if it jpayne@69: should be enabled or not. */ jpayne@69: int coerce_c_locale; jpayne@69: jpayne@69: /* Emit a warning if the LC_CTYPE locale is coerced? jpayne@69: jpayne@69: Set to 1 by PYTHONCOERCECLOCALE=warn. jpayne@69: jpayne@69: Disable by default (set to 0). Set it to -1 to let Python decide if it jpayne@69: should be enabled or not. */ jpayne@69: int coerce_c_locale_warn; jpayne@69: jpayne@69: #ifdef MS_WINDOWS jpayne@69: /* If greater than 1, use the "mbcs" encoding instead of the UTF-8 jpayne@69: encoding for the filesystem encoding. jpayne@69: jpayne@69: Set to 1 if the PYTHONLEGACYWINDOWSFSENCODING environment variable is jpayne@69: set to a non-empty string. If set to -1 (default), inherit jpayne@69: Py_LegacyWindowsFSEncodingFlag value. jpayne@69: jpayne@69: See PEP 529 for more details. */ jpayne@69: int legacy_windows_fs_encoding; jpayne@69: #endif jpayne@69: jpayne@69: /* Enable UTF-8 mode? (PEP 540) jpayne@69: jpayne@69: Disabled by default (equals to 0). jpayne@69: jpayne@69: Set to 1 by "-X utf8" and "-X utf8=1" command line options. jpayne@69: Set to 1 by PYTHONUTF8=1 environment variable. jpayne@69: jpayne@69: Set to 0 by "-X utf8=0" and PYTHONUTF8=0. jpayne@69: jpayne@69: If equals to -1, it is set to 1 if the LC_CTYPE locale is "C" or jpayne@69: "POSIX", otherwise it is set to 0. Inherit Py_UTF8Mode value value. */ jpayne@69: int utf8_mode; jpayne@69: jpayne@69: int dev_mode; /* Development mode. PYTHONDEVMODE, -X dev */ jpayne@69: jpayne@69: /* Memory allocator: PYTHONMALLOC env var. jpayne@69: See PyMemAllocatorName for valid values. */ jpayne@69: int allocator; jpayne@69: } PyPreConfig; jpayne@69: jpayne@69: PyAPI_FUNC(void) PyPreConfig_InitPythonConfig(PyPreConfig *config); jpayne@69: PyAPI_FUNC(void) PyPreConfig_InitIsolatedConfig(PyPreConfig *config); jpayne@69: jpayne@69: jpayne@69: /* --- PyConfig ---------------------------------------------- */ jpayne@69: jpayne@69: typedef struct { jpayne@69: int _config_init; /* _PyConfigInitEnum value */ jpayne@69: jpayne@69: int isolated; /* Isolated mode? see PyPreConfig.isolated */ jpayne@69: int use_environment; /* Use environment variables? see PyPreConfig.use_environment */ jpayne@69: int dev_mode; /* Development mode? See PyPreConfig.dev_mode */ jpayne@69: jpayne@69: /* Install signal handlers? Yes by default. */ jpayne@69: int install_signal_handlers; jpayne@69: jpayne@69: int use_hash_seed; /* PYTHONHASHSEED=x */ jpayne@69: unsigned long hash_seed; jpayne@69: jpayne@69: /* Enable faulthandler? jpayne@69: Set to 1 by -X faulthandler and PYTHONFAULTHANDLER. -1 means unset. */ jpayne@69: int faulthandler; jpayne@69: jpayne@69: /* Enable tracemalloc? jpayne@69: Set by -X tracemalloc=N and PYTHONTRACEMALLOC. -1 means unset */ jpayne@69: int tracemalloc; jpayne@69: jpayne@69: int import_time; /* PYTHONPROFILEIMPORTTIME, -X importtime */ jpayne@69: int show_ref_count; /* -X showrefcount */ jpayne@69: int show_alloc_count; /* -X showalloccount */ jpayne@69: int dump_refs; /* PYTHONDUMPREFS */ jpayne@69: int malloc_stats; /* PYTHONMALLOCSTATS */ jpayne@69: jpayne@69: /* Python filesystem encoding and error handler: jpayne@69: sys.getfilesystemencoding() and sys.getfilesystemencodeerrors(). jpayne@69: jpayne@69: Default encoding and error handler: jpayne@69: jpayne@69: * if Py_SetStandardStreamEncoding() has been called: they have the jpayne@69: highest priority; jpayne@69: * PYTHONIOENCODING environment variable; jpayne@69: * The UTF-8 Mode uses UTF-8/surrogateescape; jpayne@69: * If Python forces the usage of the ASCII encoding (ex: C locale jpayne@69: or POSIX locale on FreeBSD or HP-UX), use ASCII/surrogateescape; jpayne@69: * locale encoding: ANSI code page on Windows, UTF-8 on Android and jpayne@69: VxWorks, LC_CTYPE locale encoding on other platforms; jpayne@69: * On Windows, "surrogateescape" error handler; jpayne@69: * "surrogateescape" error handler if the LC_CTYPE locale is "C" or "POSIX"; jpayne@69: * "surrogateescape" error handler if the LC_CTYPE locale has been coerced jpayne@69: (PEP 538); jpayne@69: * "strict" error handler. jpayne@69: jpayne@69: Supported error handlers: "strict", "surrogateescape" and jpayne@69: "surrogatepass". The surrogatepass error handler is only supported jpayne@69: if Py_DecodeLocale() and Py_EncodeLocale() use directly the UTF-8 codec; jpayne@69: it's only used on Windows. jpayne@69: jpayne@69: initfsencoding() updates the encoding to the Python codec name. jpayne@69: For example, "ANSI_X3.4-1968" is replaced with "ascii". jpayne@69: jpayne@69: On Windows, sys._enablelegacywindowsfsencoding() sets the jpayne@69: encoding/errors to mbcs/replace at runtime. jpayne@69: jpayne@69: jpayne@69: See Py_FileSystemDefaultEncoding and Py_FileSystemDefaultEncodeErrors. jpayne@69: */ jpayne@69: wchar_t *filesystem_encoding; jpayne@69: wchar_t *filesystem_errors; jpayne@69: jpayne@69: wchar_t *pycache_prefix; /* PYTHONPYCACHEPREFIX, -X pycache_prefix=PATH */ jpayne@69: int parse_argv; /* Parse argv command line arguments? */ jpayne@69: jpayne@69: /* Command line arguments (sys.argv). jpayne@69: jpayne@69: Set parse_argv to 1 to parse argv as Python command line arguments jpayne@69: and then strip Python arguments from argv. jpayne@69: jpayne@69: If argv is empty, an empty string is added to ensure that sys.argv jpayne@69: always exists and is never empty. */ jpayne@69: PyWideStringList argv; jpayne@69: jpayne@69: /* Program name: jpayne@69: jpayne@69: - If Py_SetProgramName() was called, use its value. jpayne@69: - On macOS, use PYTHONEXECUTABLE environment variable if set. jpayne@69: - If WITH_NEXT_FRAMEWORK macro is defined, use __PYVENV_LAUNCHER__ jpayne@69: environment variable is set. jpayne@69: - Use argv[0] if available and non-empty. jpayne@69: - Use "python" on Windows, or "python3 on other platforms. */ jpayne@69: wchar_t *program_name; jpayne@69: jpayne@69: PyWideStringList xoptions; /* Command line -X options */ jpayne@69: jpayne@69: /* Warnings options: lowest to highest priority. warnings.filters jpayne@69: is built in the reverse order (highest to lowest priority). */ jpayne@69: PyWideStringList warnoptions; jpayne@69: jpayne@69: /* If equal to zero, disable the import of the module site and the jpayne@69: site-dependent manipulations of sys.path that it entails. Also disable jpayne@69: these manipulations if site is explicitly imported later (call jpayne@69: site.main() if you want them to be triggered). jpayne@69: jpayne@69: Set to 0 by the -S command line option. If set to -1 (default), it is jpayne@69: set to !Py_NoSiteFlag. */ jpayne@69: int site_import; jpayne@69: jpayne@69: /* Bytes warnings: jpayne@69: jpayne@69: * If equal to 1, issue a warning when comparing bytes or bytearray with jpayne@69: str or bytes with int. jpayne@69: * If equal or greater to 2, issue an error. jpayne@69: jpayne@69: Incremented by the -b command line option. If set to -1 (default), inherit jpayne@69: Py_BytesWarningFlag value. */ jpayne@69: int bytes_warning; jpayne@69: jpayne@69: /* If greater than 0, enable inspect: when a script is passed as first jpayne@69: argument or the -c option is used, enter interactive mode after jpayne@69: executing the script or the command, even when sys.stdin does not appear jpayne@69: to be a terminal. jpayne@69: jpayne@69: Incremented by the -i command line option. Set to 1 if the PYTHONINSPECT jpayne@69: environment variable is non-empty. If set to -1 (default), inherit jpayne@69: Py_InspectFlag value. */ jpayne@69: int inspect; jpayne@69: jpayne@69: /* If greater than 0: enable the interactive mode (REPL). jpayne@69: jpayne@69: Incremented by the -i command line option. If set to -1 (default), jpayne@69: inherit Py_InteractiveFlag value. */ jpayne@69: int interactive; jpayne@69: jpayne@69: /* Optimization level. jpayne@69: jpayne@69: Incremented by the -O command line option. Set by the PYTHONOPTIMIZE jpayne@69: environment variable. If set to -1 (default), inherit Py_OptimizeFlag jpayne@69: value. */ jpayne@69: int optimization_level; jpayne@69: jpayne@69: /* If greater than 0, enable the debug mode: turn on parser debugging jpayne@69: output (for expert only, depending on compilation options). jpayne@69: jpayne@69: Incremented by the -d command line option. Set by the PYTHONDEBUG jpayne@69: environment variable. If set to -1 (default), inherit Py_DebugFlag jpayne@69: value. */ jpayne@69: int parser_debug; jpayne@69: jpayne@69: /* If equal to 0, Python won't try to write ``.pyc`` files on the jpayne@69: import of source modules. jpayne@69: jpayne@69: Set to 0 by the -B command line option and the PYTHONDONTWRITEBYTECODE jpayne@69: environment variable. If set to -1 (default), it is set to jpayne@69: !Py_DontWriteBytecodeFlag. */ jpayne@69: int write_bytecode; jpayne@69: jpayne@69: /* If greater than 0, enable the verbose mode: print a message each time a jpayne@69: module is initialized, showing the place (filename or built-in module) jpayne@69: from which it is loaded. jpayne@69: jpayne@69: If greater or equal to 2, print a message for each file that is checked jpayne@69: for when searching for a module. Also provides information on module jpayne@69: cleanup at exit. jpayne@69: jpayne@69: Incremented by the -v option. Set by the PYTHONVERBOSE environment jpayne@69: variable. If set to -1 (default), inherit Py_VerboseFlag value. */ jpayne@69: int verbose; jpayne@69: jpayne@69: /* If greater than 0, enable the quiet mode: Don't display the copyright jpayne@69: and version messages even in interactive mode. jpayne@69: jpayne@69: Incremented by the -q option. If set to -1 (default), inherit jpayne@69: Py_QuietFlag value. */ jpayne@69: int quiet; jpayne@69: jpayne@69: /* If greater than 0, don't add the user site-packages directory to jpayne@69: sys.path. jpayne@69: jpayne@69: Set to 0 by the -s and -I command line options , and the PYTHONNOUSERSITE jpayne@69: environment variable. If set to -1 (default), it is set to jpayne@69: !Py_NoUserSiteDirectory. */ jpayne@69: int user_site_directory; jpayne@69: jpayne@69: /* If non-zero, configure C standard steams (stdio, stdout, jpayne@69: stderr): jpayne@69: jpayne@69: - Set O_BINARY mode on Windows. jpayne@69: - If buffered_stdio is equal to zero, make streams unbuffered. jpayne@69: Otherwise, enable streams buffering if interactive is non-zero. */ jpayne@69: int configure_c_stdio; jpayne@69: jpayne@69: /* If equal to 0, enable unbuffered mode: force the stdout and stderr jpayne@69: streams to be unbuffered. jpayne@69: jpayne@69: Set to 0 by the -u option. Set by the PYTHONUNBUFFERED environment jpayne@69: variable. jpayne@69: If set to -1 (default), it is set to !Py_UnbufferedStdioFlag. */ jpayne@69: int buffered_stdio; jpayne@69: jpayne@69: /* Encoding of sys.stdin, sys.stdout and sys.stderr. jpayne@69: Value set from PYTHONIOENCODING environment variable and jpayne@69: Py_SetStandardStreamEncoding() function. jpayne@69: See also 'stdio_errors' attribute. */ jpayne@69: wchar_t *stdio_encoding; jpayne@69: jpayne@69: /* Error handler of sys.stdin and sys.stdout. jpayne@69: Value set from PYTHONIOENCODING environment variable and jpayne@69: Py_SetStandardStreamEncoding() function. jpayne@69: See also 'stdio_encoding' attribute. */ jpayne@69: wchar_t *stdio_errors; jpayne@69: jpayne@69: #ifdef MS_WINDOWS jpayne@69: /* If greater than zero, use io.FileIO instead of WindowsConsoleIO for sys jpayne@69: standard streams. jpayne@69: jpayne@69: Set to 1 if the PYTHONLEGACYWINDOWSSTDIO environment variable is set to jpayne@69: a non-empty string. If set to -1 (default), inherit jpayne@69: Py_LegacyWindowsStdioFlag value. jpayne@69: jpayne@69: See PEP 528 for more details. */ jpayne@69: int legacy_windows_stdio; jpayne@69: #endif jpayne@69: jpayne@69: /* Value of the --check-hash-based-pycs command line option: jpayne@69: jpayne@69: - "default" means the 'check_source' flag in hash-based pycs jpayne@69: determines invalidation jpayne@69: - "always" causes the interpreter to hash the source file for jpayne@69: invalidation regardless of value of 'check_source' bit jpayne@69: - "never" causes the interpreter to always assume hash-based pycs are jpayne@69: valid jpayne@69: jpayne@69: The default value is "default". jpayne@69: jpayne@69: See PEP 552 "Deterministic pycs" for more details. */ jpayne@69: wchar_t *check_hash_pycs_mode; jpayne@69: jpayne@69: /* --- Path configuration inputs ------------ */ jpayne@69: jpayne@69: /* If greater than 0, suppress _PyPathConfig_Calculate() warnings on Unix. jpayne@69: The parameter has no effect on Windows. jpayne@69: jpayne@69: If set to -1 (default), inherit !Py_FrozenFlag value. */ jpayne@69: int pathconfig_warnings; jpayne@69: jpayne@69: wchar_t *pythonpath_env; /* PYTHONPATH environment variable */ jpayne@69: wchar_t *home; /* PYTHONHOME environment variable, jpayne@69: see also Py_SetPythonHome(). */ jpayne@69: jpayne@69: /* --- Path configuration outputs ----------- */ jpayne@69: jpayne@69: int module_search_paths_set; /* If non-zero, use module_search_paths */ jpayne@69: PyWideStringList module_search_paths; /* sys.path paths. Computed if jpayne@69: module_search_paths_set is equal jpayne@69: to zero. */ jpayne@69: jpayne@69: wchar_t *executable; /* sys.executable */ jpayne@69: wchar_t *base_executable; /* sys._base_executable */ jpayne@69: wchar_t *prefix; /* sys.prefix */ jpayne@69: wchar_t *base_prefix; /* sys.base_prefix */ jpayne@69: wchar_t *exec_prefix; /* sys.exec_prefix */ jpayne@69: wchar_t *base_exec_prefix; /* sys.base_exec_prefix */ jpayne@69: jpayne@69: /* --- Parameter only used by Py_Main() ---------- */ jpayne@69: jpayne@69: /* Skip the first line of the source ('run_filename' parameter), allowing use of non-Unix forms of jpayne@69: "#!cmd". This is intended for a DOS specific hack only. jpayne@69: jpayne@69: Set by the -x command line option. */ jpayne@69: int skip_source_first_line; jpayne@69: jpayne@69: wchar_t *run_command; /* -c command line argument */ jpayne@69: wchar_t *run_module; /* -m command line argument */ jpayne@69: wchar_t *run_filename; /* Trailing command line argument without -c or -m */ jpayne@69: jpayne@69: /* --- Private fields ---------------------------- */ jpayne@69: jpayne@69: /* Install importlib? If set to 0, importlib is not initialized at all. jpayne@69: Needed by freeze_importlib. */ jpayne@69: int _install_importlib; jpayne@69: jpayne@69: /* If equal to 0, stop Python initialization before the "main" phase */ jpayne@69: int _init_main; jpayne@69: } PyConfig; jpayne@69: jpayne@69: PyAPI_FUNC(void) PyConfig_InitPythonConfig(PyConfig *config); jpayne@69: PyAPI_FUNC(void) PyConfig_InitIsolatedConfig(PyConfig *config); jpayne@69: PyAPI_FUNC(void) PyConfig_Clear(PyConfig *); jpayne@69: PyAPI_FUNC(PyStatus) PyConfig_SetString( jpayne@69: PyConfig *config, jpayne@69: wchar_t **config_str, jpayne@69: const wchar_t *str); jpayne@69: PyAPI_FUNC(PyStatus) PyConfig_SetBytesString( jpayne@69: PyConfig *config, jpayne@69: wchar_t **config_str, jpayne@69: const char *str); jpayne@69: PyAPI_FUNC(PyStatus) PyConfig_Read(PyConfig *config); jpayne@69: PyAPI_FUNC(PyStatus) PyConfig_SetBytesArgv( jpayne@69: PyConfig *config, jpayne@69: Py_ssize_t argc, jpayne@69: char * const *argv); jpayne@69: PyAPI_FUNC(PyStatus) PyConfig_SetArgv(PyConfig *config, jpayne@69: Py_ssize_t argc, jpayne@69: wchar_t * const *argv); jpayne@69: PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config, jpayne@69: PyWideStringList *list, jpayne@69: Py_ssize_t length, wchar_t **items); jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: #endif /* !Py_LIMITED_API */ jpayne@69: #endif /* !Py_PYCORECONFIG_H */