Files
post-ocr/rthook_paddle.py
let5sne.win10 86cb704eae fix: 解决打包后三个运行时问题
- rthook_paddle.py: stub paddle.utils.cpp_extension,避免Cython缺文件崩溃
- build_exe.py: 显式收集paddle DLLs(mklml.dll等)
- ocr_offline.py: 非ASCII路径自动复制模型到临时目录,绕过PaddlePaddle C++路径限制

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 20:31:28 +08:00

34 lines
868 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
PyInstaller runtime hook: stub 掉 paddle 中仅开发时需要的模块,
避免打包后因缺少 Cython Utility 文件而崩溃。
"""
import types
import sys
class _Stub(types.ModuleType):
"""空模块 stub所有属性访问返回空类"""
def __getattr__(self, name):
if name.startswith("_"):
raise AttributeError(name)
return type(name, (), {})
def _inject(name):
if name not in sys.modules:
m = _Stub(name)
m.__path__ = []
m.__package__ = name
m.__spec__ = None
sys.modules[name] = m
# paddle.utils.cpp_extension 会拉入 Cython 编译器,推理不需要
for _p in [
"paddle.utils.cpp_extension",
"paddle.utils.cpp_extension.cpp_extension",
"paddle.utils.cpp_extension.extension_utils",
"paddle.utils.cpp_extension.jit_compile",
]:
_inject(_p)