mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-111374: Add a new PYTHON_FROZEN_MODULES env var, equivalent of -X frozen_modules
. (#111411)
Adds a new PYTHON_FROZEN_MODULES env var to correspond with -X frozen_modules. Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
parent
7e135a48d6
commit
45a36d5f56
5 changed files with 56 additions and 6 deletions
|
@ -285,11 +285,14 @@ static const char usage_envvars[] =
|
|||
"PYTHONDEVMODE: enable the development mode.\n"
|
||||
"PYTHONPYCACHEPREFIX: root directory for bytecode cache (pyc) files.\n"
|
||||
"PYTHONWARNDEFAULTENCODING: enable opt-in EncodingWarning for 'encoding=None'.\n"
|
||||
"PYTHONNODEBUGRANGES: If this variable is set, it disables the inclusion of the \n"
|
||||
"PYTHONNODEBUGRANGES: if this variable is set, it disables the inclusion of the \n"
|
||||
" tables mapping extra location information (end line, start column offset \n"
|
||||
" and end column offset) to every instruction in code objects. This is useful \n"
|
||||
" when smaller code objects and pyc files are desired as well as suppressing the \n"
|
||||
" extra visual location indicators when the interpreter displays tracebacks.\n"
|
||||
"PYTHON_FROZEN_MODULES : if this variable is set, it determines whether or not \n"
|
||||
" frozen modules should be used. The default is \"on\" (or \"off\" if you are \n"
|
||||
" running a local build).\n"
|
||||
"These variables have equivalent command-line parameters (see --help for details):\n"
|
||||
"PYTHONDEBUG : enable parser debug mode (-d)\n"
|
||||
"PYTHONDONTWRITEBYTECODE : don't write .pyc files (-B)\n"
|
||||
|
@ -2132,6 +2135,19 @@ config_init_import(PyConfig *config, int compute_path_config)
|
|||
return status;
|
||||
}
|
||||
|
||||
const char *env = config_get_env(config, "PYTHON_FROZEN_MODULES");
|
||||
if (env == NULL) {
|
||||
}
|
||||
else if (strcmp(env, "on") == 0) {
|
||||
config->use_frozen_modules = 1;
|
||||
}
|
||||
else if (strcmp(env, "off") == 0) {
|
||||
config->use_frozen_modules = 0;
|
||||
} else {
|
||||
return PyStatus_Error("bad value for PYTHON_FROZEN_MODULES "
|
||||
"(expected \"on\" or \"off\")");
|
||||
}
|
||||
|
||||
/* -X frozen_modules=[on|off] */
|
||||
const wchar_t *value = config_get_xoption_value(config, L"frozen_modules");
|
||||
if (value == NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue