Files
metin2-client/src/platform/ScriptLib/PythonHost.h
T
shenleiandClaude Opus 5.5 a46093104c layout: restructure into src/ tests/ android/ scripts/ tools/
- extension/src/{port,platform,codepage} -> src/; native_render -> src/host
  (+ dxt, shaders/); libgr2 -> src/gr2; extension/third_party -> third_party
- extension/tests -> tests/port, libgr2/tests -> tests/gr2
- android-native -> android (build.sh, push-client.sh moved in)
- script -> scripts; tools/40250 -> tools/server; oracle -> tools/granny-oracle;
  perf tools -> tools/perf
- all build trees under build/ (native, release, android, port-gate)
- xrender:: CMake aliases -> mt::; port-map ledger impl paths rewritten

No code changes. ctest 15/15, port_gate macos+android PASS, port_map check 0 errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 19:08:19 +09:00

29 lines
1.5 KiB
C++

#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 <string>
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);
}