port(2P step 2): ScriptLib/PythonLauncher on the embedded interpreter
Link mtpython into port_logic and copy 40250's ScriptLib launcher across: PythonLauncher, PythonUtils and PythonMarshal, plus the 12 forwarding headers that make its `#include <Python-2.7/*>` lines compile unchanged. symtable.h forward-declares mod_ty rather than including Python-ast.h, whose one-word macros (Delete, Module, Set, Print) collide with EterLib/Pool.h — the same clash 40250 sidestepped by commenting out PySymtable_Build. Two `// PORT:` edits: `unsigned char(val)` is an MSVC extension (PythonUtils.cpp, twice), and PyObject_AsCharBuffer wants a Py_ssize_t* (TraceFunc). port_python_launcher_test drives the launcher in the order UserInterface.cpp does (:241-434): Create(), __DEBUG__/__COMMAND_LINE__, TRUE/FALSE, a CRLF script through RunMemoryTextFile, a .pyc through RunCompiledFile, then RunFile reading system.py out of the real pack. It stops at `ImportError: No module named app`, i.e. the first C++ module RunMainScript registers — that is the 2V0 slice, and the stdlib behind it is step 3. The host flags (Py_NoSiteFlag and friends) sit in the test for now; step 3 moves them into the platform layer. port-map statuses are set only for what the test actually executes: 10 of 12 launcher functions and 4 of 11 marshal ones (the small-.pyc path delegates to CPython's own reader, so the ported r_object stays unreached). PythonUtils compiles but nothing calls it until the binding modules arrive, so it stays TODO. Windows has no mtpython yet, so port_logic drops ScriptLib and the shims there. Tests: macOS ctest 27/27 incl. port.python_launcher; port_logic (with ScriptLib) also compiles for android arm64 (NDK API 24) and ios arm64. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -493,3 +493,4 @@
|
||||
{"time":"2026-09-23T12:30:00Z","event":"port_round","unit":"proto reader -> 40250 item_proto/mob_proto via CLZO + pack://locale/<lang>/ (PORT-PLAN §5 step 2 + step 5 runtime switch)","ported":["EterPack/EterPack.cpp (16 fns)","EterPack/EterPackManager.cpp (14)","EterPack/EterPackPolicy_CSHybridCrypt.cpp (1)","EterBase/lzo.cpp (11)","EterBase/tea.cpp (2)","EterBase/Stl.cpp (2)"],"adapted":["UserInterface/UserInterface.cpp PackInitialize","EterBase/FileLoader.cpp (5)","EterBase/MappedFile.cpp (9)","EterBase/FileBase.cpp (5)","EterBase/CRC32.cpp GetCRC32"],"deleted":["extension/src/proto/proto.cpp m2dev reader: XChaCha20 + MCOZ, 236-byte item / 335-byte mob strides"],"divergent":[],"needs_live":[],"status_note":"statuses set only for the functions a clang coverage run of proto_test + port_eterpack_test hit; the rest stay TODO. SMobTable is a local #pragma pack(1) mirror in proto.cpp (static_assert 255) until batch 2P ports GameLib/PythonNonPlayer. name = cp1252(szLocaleName) as CItemData::GetName / CPythonNonPlayer::GetMonsterName","tests":["extension/tests/proto_test.cpp: 5743 items / 1334 mobs from pack://locale/en PASS","extension/tests/proto_item_layout_test.cpp 156/255 strides, 236/335 rejected PASS","godot netbridge/equip_model/remote_player/mob_view PASS"],"commit":"2D-proto"}
|
||||
{"time":"2026-09-23T13:30:00Z","event":"asset_gate","unit":"PORT-PLAN §5 steps 3-4: MT_ASSETS_STRICT + provenance manifest + script/run_40250_asset_gate.sh","manifest":"audit/assets/40250-client.json (pack/Index + 214 .eix/.epk + 8 Eternexus/root/*.msm = 223 files, 1407474045 bytes, sha256)","env":{"MT_40250_CLIENT":"40250 Client dir (native tests, AssetRoot.client_path, gate)","MT_ASSETS":"m2dev loose dev override only","M2_ASSETS":"no longer used by tests"},"fixes":["remote_player_test accepted only twohand_sword/wait.msa; WAIT picks wait/wait_1 by weight, so it failed ~1/3 of runs"],"tests":["script/run_40250_asset_gate.sh macOS PASS (manifest, ctest port.eterpack|proto.*, godot netbridge/equip_model/remote_player/mob_view)","gate with MT_40250_CLIENT=/nonexistent exits 1"],"commit":"2D-gate"}
|
||||
{"time": "2026-09-23T15:30:00Z", "event": "third_party", "unit": "PORT-PLAN 批次 2P step 1: vendored CPython 2.7.18 as the mtpython static library", "source": "official Python-2.7.18.tgz sha256 b62c0e7937551d0cc02b8fd5cb0f544f9405bafc9a54d3808ed4594812edef43, trimmed to 25MB (Doc/Demo/Tools/Mac/PCbuild, Modules/{_ctypes,expat,zlib,_sqlite}, stdlib test trees, pre-VS2010 PC projects); Lib/ kept for step 3's python27.zip", "shared": "source list = the 133 objects of the reference libpython2.7.a; built-in table config/config.c = 39 entries (config/Setup.static)", "per_platform": "config/<plat>/pyconfig.h from tools/py_embed/gen_pyconfig.sh; android undefs HAVE_LANGINFO_H (nl_langinfo needs API 26); ios is derived from macos (2.7 configure refuses a darwin cross build) and drops process control + sys/random.h, keeping HAVE_GETGROUPS because posixmodule.c defines MAX_GROUPS only inside it", "patches": ["configure + configure.ac: arm64 MACOSX_DEFAULT_ARCH", "Modules/posixmodule.c: undef HAVE_SYSTEM/POPEN/FORK/EXECV/WAIT under TARGET_OS_IPHONE, which its own 'all other compilers' block hard-defines past pyconfig.h"], "not_done": ["Linux x86_64: gen_pyconfig.sh linux needs a Linux host", "Windows x64: upstream supports MSVC + PC/pyconfig.h while the Windows gate is MinGW, where PC/pyconfig.h leaves HAVE_UNISTD_H unset and posixmodule.c/dynload_win.c collide with the MinGW headers; decided in step 4"], "ported": [], "deleted": [], "divergent": [], "needs_live": [], "status_note": "no port-map entry: this is third-party source, not a ported 40250 unit. Linking into libmtgodot is step 2 (ScriptLib/PythonLauncher.cpp)", "tests": ["ctest python.embed (macOS arm64): 39 builtin modules, all import, sys.version 2.7.18, utf-8/cp1252 codecs + pickle round-trip via the vendored Lib/ PASS", "android arm64 NDK API 24: libmtpython.a builds clean", "ios arm64 iphoneos: libmtpython.a = 133 objects, no undefined _system/_fork/_popen"], "commit": "2P-step1"}
|
||||
{"time": "2026-09-23T17:30:00Z", "event": "port_round", "unit": "PORT-PLAN 批次 2P step 2: ScriptLib/PythonLauncher.cpp into port_logic on the embedded interpreter", "ported": ["ScriptLib/PythonLauncher.cpp (10 of 12 fns)", "ScriptLib/PythonMarshal.cpp (4 of 11)"], "adapted": [], "deleted": [], "divergent": [], "needs_live": [], "status_note": "statuses set only for what port.python_launcher actually runs. PythonUtils.cpp is copied and compiled but nothing calls it yet (the binding modules are 2V0), so all 19 stay TODO; TraceFunc/SetTraceFunc are _DEBUG-only; in PythonMarshal only the small-.pyc path runs (r_long, _PyMarshal_ReadLongFromFile, getfilesize, _PyMarshal_ReadLastObjectFromFile) because that one delegates to CPython's own PyMarshal_ReadObjectFromString under 16KB, leaving the ported r_object reader unreached. Two // PORT: edits: `unsigned char(val)` -> a cast (MSVC extension) in PythonUtils.cpp x2, and PyObject_AsCharBuffer's Py_ssize_t* in TraceFunc. CPythonLauncher::GetError dereferences the NULL PyErr_Fetch yields when nothing is pending — kept verbatim, the test only calls it with an error set.", "shims": "extension/src/port/common/shim/sdk/Python-2.7/: 12 forwarding headers for 40250's #include <Python-2.7/*>; symtable.h forward-declares mod_ty instead of including Python-ast.h, whose one-word macros (Delete, Module, Set, Print) collide with EterLib/Pool.h — 40250 sidestepped the same clash by commenting out PySymtable_Build", "tests": ["ctest port.python_launcher (macOS arm64): Create/RunLine/RunMemoryTextFile(CRLF)/RunCompiledFile(.pyc)/RunFile PASS; RunFile(\"system.py\") reads the real pack and stops at ImportError: No module named app (the 2V0 C++ modules)", "ctest macOS: 27/27 PASS", "android arm64 NDK API 24 + ios arm64 iphoneos: port_logic (incl. ScriptLib) compiles"], "commit": "2P-step2"}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"reference": "ScriptLib/PythonLauncher.cpp",
|
||||
"reference_sha256": "3dbaccfb21153cbbf201c2fe7252063455f6b9a9c79c1c55f9d03e8573bf65c8",
|
||||
"priority": "P4",
|
||||
"contracts": [],
|
||||
"functions": {
|
||||
"CPythonLauncher::CPythonLauncher": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonLauncher.cpp:CPythonLauncher::CPythonLauncher"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"CPythonLauncher::~CPythonLauncher": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonLauncher.cpp:CPythonLauncher::~CPythonLauncher"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"CPythonLauncher::Clear": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonLauncher.cpp:CPythonLauncher::Clear"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"Traceback": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonLauncher.cpp:Traceback"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"TraceFunc": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"CPythonLauncher::SetTraceFunc": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"CPythonLauncher::Create": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonLauncher.cpp:CPythonLauncher::Create"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"CPythonLauncher::RunCompiledFile": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonLauncher.cpp:CPythonLauncher::RunCompiledFile"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"CPythonLauncher::RunMemoryTextFile": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonLauncher.cpp:CPythonLauncher::RunMemoryTextFile"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"CPythonLauncher::RunFile": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonLauncher.cpp:CPythonLauncher::RunFile"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"CPythonLauncher::RunLine": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonLauncher.cpp:CPythonLauncher::RunLine"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"CPythonLauncher::GetError": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonLauncher.cpp:CPythonLauncher::GetError"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"reference": "ScriptLib/PythonMarshal.cpp",
|
||||
"reference_sha256": "c12ee08f78c9070097b851a5d0a22be9999e12fc03e04c6da639c5f1bbd81f05",
|
||||
"priority": "P4",
|
||||
"contracts": [],
|
||||
"functions": {
|
||||
"r_string": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"r_short": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"r_long": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonMarshal.cpp:r_long"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"r_long64": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"r_object": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"_PyMarshal_ReadShortFromFile": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"_PyMarshal_ReadLongFromFile": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonMarshal.cpp:_PyMarshal_ReadLongFromFile"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"getfilesize": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonMarshal.cpp:getfilesize"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"_PyMarshal_ReadLastObjectFromFile": {
|
||||
"impl": [
|
||||
"extension/src/port/ScriptLib/PythonMarshal.cpp:_PyMarshal_ReadLastObjectFromFile"
|
||||
],
|
||||
"status": "PORTED",
|
||||
"test": "extension/tests/port_python_launcher_test.cpp (port.python_launcher)"
|
||||
},
|
||||
"_PyMarshal_ReadObjectFromFile": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"_PyMarshal_ReadObjectFromString": {
|
||||
"status": "TODO"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"reference": "ScriptLib/PythonUtils.cpp",
|
||||
"reference_sha256": "ede046a6a16563cb65976c8c99199f401a29fe9614c07a32e577176c2827aaba",
|
||||
"priority": "P4",
|
||||
"contracts": [],
|
||||
"functions": {
|
||||
"Py_BadArgument": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"Py_BuildException": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"Py_BuildNone": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"Py_ReleaseNone": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"PyTuple_GetObject": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"PyTuple_GetLong": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"PyTuple_GetDouble": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"PyTuple_GetFloat": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"PyTuple_GetByte": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"PyTuple_GetInteger": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"PyTuple_GetUnsignedLong": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"PyTuple_GetUnsignedInteger": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"PyTuple_GetString": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"PyTuple_GetBoolean": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"PyCallClassMemberFunc": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"PyCallClassMemberFunc_ByPyString": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"__PyCallClassMemberFunc_ByCString": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"__PyCallClassMemberFunc_ByPyString": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"__PyCallClassMemberFunc": {
|
||||
"status": "TODO"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user