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:
shenlei
2026-09-23 09:16:37 +09:00
co-authored by Claude Opus 5
parent 43bb561551
commit 2b873f190f
13 changed files with 414 additions and 17 deletions
+5 -2
View File
@@ -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