snapshot before regression test

This commit is contained in:
t
2026-07-18 19:25:40 +08:00
commit 796222a300
2295 changed files with 206453 additions and 0 deletions

37
lib/_bootstrap.py Normal file
View File

@@ -0,0 +1,37 @@
"""集中化 sys.path 引导模块
在首次导入时一次性设置好编译器运行所需的 sys.path
- 项目根目录:让 ``import TransPyC``、``from StubGen import``、动态 importlib 能解析
- lib/includes让用户注解模块中的 ``import t`` / ``import c`` 能解析
入口点TransPyC.py / Projectrans.py应在最开头 ``import lib._bootstrap``。
lib 内部模块也可 ``import lib._bootstrap`` 作为安全网,重复导入是无副作用的 no-op。
"""
from __future__ import annotations
import os
import sys
_BOOTSTRAPPED: bool = False
def _bootstrap() -> None:
global _BOOTSTRAPPED
if _BOOTSTRAPPED:
return
_BOOTSTRAPPED = True
# lib/_bootstrap.py 所在目录
_LibDir: str = os.path.dirname(os.path.abspath(__file__))
# 项目根目录 = lib 的父目录
_ProjectRoot: str = os.path.dirname(_LibDir)
# lib/includes 目录(编译器内部类型系统 t.py / c.py
_IncludesDir: str = os.path.join(_LibDir, 'includes')
if _ProjectRoot not in sys.path:
sys.path.insert(0, _ProjectRoot)
if _IncludesDir not in sys.path:
sys.path.append(_IncludesDir)
_bootstrap()