43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""
|
|
天璇运行时隔离验证脚本。在不同机器上运行,输出应完全一致。
|
|
"""
|
|
import sys, site, importlib
|
|
|
|
ok = True
|
|
|
|
# 1. 检查 Python 路径
|
|
print(f'Python: {sys.version}')
|
|
print(f'base_exec_prefix: {sys.base_exec_prefix}')
|
|
if '天璇' not in sys.base_exec_prefix and 'runtime' not in sys.base_exec_prefix:
|
|
print('WARN: base_exec_prefix does not point to runtime Python')
|
|
# This is expected when running via uv, so not a failure
|
|
|
|
# 2. 检查 site-packages 隔离
|
|
print(f'ENABLE_USER_SITE: {site.ENABLE_USER_SITE}')
|
|
|
|
# 3. 检查核心依赖版本
|
|
checks = [
|
|
('django', '4.2'),
|
|
('polars', '1.42'),
|
|
('sklearn', '1.5'),
|
|
('numpy', '1.26'),
|
|
('yaml', ''),
|
|
('pydantic', '2.'),
|
|
]
|
|
for mod_name, ver_prefix in checks:
|
|
try:
|
|
mod = importlib.import_module(mod_name)
|
|
ver = getattr(mod, '__version__', 'unknown')
|
|
match = 'YES' if not ver_prefix or ver.startswith(ver_prefix) else f'NEEDS: {ver_prefix}xxx, GOT: {ver}'
|
|
print(f' {mod_name:15s} {ver:20s} {match}')
|
|
except Exception as e:
|
|
print(f' {mod_name:15s} FAIL: {e}')
|
|
ok = False
|
|
|
|
# 4. 检查字符编码
|
|
import sys
|
|
print(f'defaultencoding: {sys.getdefaultencoding()}')
|
|
print(f'filesystemencoding: {sys.getfilesystemencoding()}')
|
|
|
|
print(f'\nOverall: {"PASS" if ok else "FAIL"}')
|