#pragma once // The interpreter setup 40250 got for free from a real python27 installation. // // 40250's Main() only constructs CPythonLauncher: python27.dll found its own prefix, so `import site`, // the codec registry and every stdlib import worked before a single script ran. The embedded // interpreter has no prefix and no filesystem to probe, so the host does that part itself — // the flags before Py_Initialize, and the stdlib (python27.zip) on sys.path afterwards. // See docs/PORT-PLAN.md 批次 2P step 3. #include namespace PythonHost { // Before the interpreter starts, i.e. before CPythonLauncher's constructor. // `program_name` is what CPythonLauncher::Create defaults to; it only names the interpreter. void Configure(const char* program_name = "eter.python"); // After Py_Initialize: replaces sys.path with `stdlib_path` (a python27.zip or a stdlib directory // on a real filesystem — zipimport and the .py importer both need a path the C library can open) // and re-registers the codec search function. False leaves *error set. bool InstallStdLib(const char* stdlib_path, std::string* error); // Where the host put the stdlib: $MT_PYTHON_STDLIB when set, else whatever SetDefaultStdLibPath was // given, else "". Inside Godot that is the staged python27.zip (extension/src/python_stdlib.h), which // on Android/iOS is the sandbox copy of the one in the read-only bundle. std::string DefaultStdLibPath(); void SetDefaultStdLibPath(const char* stdlib_path); }