port(2P step 3a/3b): stdlib on sys.path + the pack module
step 3a — 标准库: tools/py_embed/make_stdlib_zip.py packs the vendored Lib/ into <build>/python27.zip (397 modules, 6876547 bytes, ZIP_STORED — the zlib module is trimmed out of our CPython, so zipimport cannot inflate). The mtpython_stdlib target builds it; py_embed_test and the launcher test both run against it. platform/ScriptLib/PythonHost sets the embedding flags before Py_Initialize and, after it, puts the zip on sys.path and re-registers encodings.search_function with codecs — 2.7 builds the codec registry once, at startup, so replacing sys.path afterwards needs it back. step 3b — pack 模块: UserInterface/PythonPackModule.cpp copied verbatim; packExist/packGet/ initpack read root/ and uiscript/ through CEterPackManager, i.e. through asset_io. The CHINA_CRYPT_KEY block in that unit is CAccountConnector's and is kept #if 0 until the login slice (2V1). UserInterface/StdAfx.h is a documented partial mirror — the original is the whole client's PCH. The launcher test now runs initpack() as RunMainScript does (its first line), reads system.py / uiscript / locale text back out of the packs, and confirms cp1252 decoding works off the zip. system.py still stops at "No module named app" — the C++ modules are the 2V0 slice. gates: port_map.py check 0 errors · key leak check 8/8 none · macOS ctest 27/27 · android + ios port_platform compile clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+16
-1
@@ -82,7 +82,7 @@ extension/third_party/cpython-2.7.18/ # 静态库(2P 批次
|
||||
| — | 定下目录结构,评估内嵌 Python;Android 独立程序验证 | 完成(9d0e50de、b02c49bb) |
|
||||
| **2A** | 基础:Win32 类型层、参考公共头的最小闭包、`port_logic` CMake 目标、platform 接口骨架、头文件可编译门禁、port-map 重新基线 | **进行中**(剩 Python 库闭包头,等 2P) |
|
||||
| 2R | 资源包能力盘点:EPK 类型/密钥/覆盖顺序/路径大小写/移动端交付 | 完成:只有 NONE/COMPRESS/SECURITY,不需要服务器密钥;设备上直接读 EPK |
|
||||
| **2P** | CPython 2.7.18 编进 libmtgodot,五个平台分别配置和验证 | **进行中**:step 1(静态库 + macOS/Android/iOS 配置)、step 2(ScriptLib 进 `port_logic`)完成 |
|
||||
| **2P** | CPython 2.7.18 编进 libmtgodot,五个平台分别配置和验证 | **进行中**:step 1(静态库 + macOS/Android/iOS 配置)、step 2(ScriptLib 进 `port_logic`)、step 3a/3b(python27.zip + `PythonHost` + `pack` 模块)完成 |
|
||||
| 2D | 数据源切到 40250(msm 路径、proto、资源根、严格资源测试) | 完成(5a26e93f、232d0461、240d2827、a9b31dec);资源根只切了 proto/pack 后端,其余按第 5 节由 2V 切片逐个切换 |
|
||||
| **2V0** | UI 壳:真实 `PythonLauncher/wndMgr/grp/app` + platform UI,其他玩法模块用桩,显示并操作 Logo/Popup | 需要 2A、2P 和 root/uiscript 子集 |
|
||||
| **2V1** | 登录/选角:真实 `net` phase、登录/选角脚本及所需模块,走到 Loading | 2V0 之后 |
|
||||
@@ -299,6 +299,21 @@ extension/third_party/cpython-2.7.18/ # 静态库(2P 批次
|
||||
- Android/iOS 首次启动从应用资源复制到应用沙盒,校验提交在资源清单中的 sha256,再加入 `sys.path`;
|
||||
- `zipimport` 静态编进解释器。`system.py` 的导入钩子只负责 pack 内的简单 root 模块,不能用来加载标准库 package、
|
||||
dotted import 或 `encodings`。
|
||||
|
||||
**已完成(3a 标准库 + 3b pack 模块)**:`tools/py_embed/make_stdlib_zip.py` 把 vendored `Lib/` 打成
|
||||
`<build>/python27.zip`(397 个模块 / 6.9MB,全部 STORED——没有 zlib 模块,zipimport 解不了 deflate;
|
||||
内容确定性写入,sha256 就是 3c 的校验值),CMake 目标 `mtpython_stdlib` 跟着 `Lib/*.py` 重建。
|
||||
宿主引导收进 `extension/src/platform/ScriptLib/PythonHost.{h,cpp}`:`Configure()` 设四个标志和程序名,
|
||||
`InstallStdLib()` 在 `Py_Initialize` 之后换掉 `sys.path` 并重新 `codecs.register(encodings.search_function)`
|
||||
(2.7 的 codec 注册表只在启动时初始化一次)。`python.embed` 现在直接跑 zip。
|
||||
`UserInterface/PythonPackModule.cpp` 已移植(`packExist`/`packGet`/`initpack`),经 `CEterPackManager`
|
||||
读 pack,即 `asset_io` 的 `pack://` 用的同一套;`port.python_launcher` 验证 `pack.Get` 取到的
|
||||
`system.py` 与 `CEterPackManager` 的字节数一致,并能读 `uiscript/selectcharacterwindow.py`、
|
||||
`locale/en/locale_game.txt`,非 `.py/.pyc/.txt` 和不存在的文件返回 `None`。
|
||||
`UserInterface/StdAfx.h` 只镜像了当前能编的部分(原文件 include 整个客户端和 DirectShow),
|
||||
`PythonPackModule.cpp` 里属于 `CAccountConnector` 的登录密钥函数原样保留但编译时排除,随 2V1 回来。
|
||||
**未完成(3c)**:Android/iOS 从应用资源把 zip 复制进沙盒并校验 sha256;`PythonHost::DefaultStdLibPath()`
|
||||
现在只认 `MT_PYTHON_STDLIB`。
|
||||
4. 五个平台分别验证:编译、链接无未定义符号、`Py_Initialize`、静态 C 模块逐个 `import`、在 app 进程里跑 `system.py` → `prototype.RunApp()`(对照结果:74 个模块中 66 个加载成功,引导期调用 33 个 C++ 函数)。
|
||||
|
||||
| 平台 | 状态 |
|
||||
|
||||
+5
-2
@@ -100,8 +100,11 @@ one via a 1-line shim header, see below).
|
||||
`Python-2.7.18.tgz` (sha256 `b62c0e7937551d0cc02b8fd5cb0f544f9405bafc9a54d3808ed4594812edef43`)
|
||||
trimmed of what an embedded interpreter never builds or ships: `Doc Demo Tools
|
||||
Mac PCbuild`, `Modules/{_ctypes,expat,zlib,_sqlite}`, the stdlib test trees and
|
||||
the pre-VS2010 `PC/` project files. `Lib/` stays — batch 2P step 3 ships it as
|
||||
`python27.zip`.
|
||||
the pre-VS2010 `PC/` project files. `Lib/` stays: the `mtpython_stdlib` target
|
||||
packs it into `<build>/python27.zip` with `tools/py_embed/make_stdlib_zip.py`,
|
||||
which is what the host puts on `sys.path` (batch 2P step 3). Entries are
|
||||
**stored, never deflated** — the `zlib` module is trimmed out above, so
|
||||
`zipimport` has nothing to inflate with.
|
||||
* **Why vendored:** 2.7 is end-of-life, so there is no package to fetch on the
|
||||
four target SDKs, and the build must keep working offline and on the
|
||||
cross-build machines. It is the version the 40250 scripts are written for
|
||||
|
||||
Reference in New Issue
Block a user