deploy-stub: Add flag for enabling verbose mode in Python

This commit is contained in:
rdb 2025-11-09 23:21:49 +01:00
parent e809c9eb92
commit 325727ef2f
2 changed files with 17 additions and 0 deletions

View File

@ -32,6 +32,14 @@
// Leave room for future expansion.
#define MAX_NUM_POINTERS 24
/* Stored in the flags field of the blobinfo structure below. */
enum Flags {
F_log_append = 1,
F_log_filename_strftime = 2,
F_keep_docstrings = 4,
F_python_verbose = 8,
};
// Define an exposed symbol where we store the offset to the module data.
extern "C" {
__attribute__((__visibility__("default"), used))
@ -283,6 +291,10 @@ void android_main(struct android_app *app) {
PyConfig_SetBytesString(&config, &config.platlibdir, libdir);
env->ReleaseStringUTFChars(libdir_jstr, libdir);
if (blobinfo.flags & F_python_verbose) {
config.verbose = 1;
}
status = Py_InitializeFromConfig(&config);
PyConfig_Clear(&config);
if (PyStatus_Exception(status)) {

View File

@ -35,6 +35,7 @@ enum Flags {
F_log_append = 1,
F_log_filename_strftime = 2,
F_keep_docstrings = 4,
F_python_verbose = 8,
};
/* Define an exposed symbol where we store the offset to the module data. */
@ -416,6 +417,10 @@ int Py_FrozenMain(int argc, char **argv)
}
#endif
if (blobinfo.flags & F_python_verbose) {
Py_VerboseFlag = 1;
}
#ifndef NDEBUG
if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
inspect = 1;