Files
xian_algorithm_new/start.py
T

50 lines
1.3 KiB
Python
Raw Normal View History

2026-05-05 19:49:12 +08:00
"""
项目启动脚本 - 支持多环境和跨平台
2026-05-08 15:42:32 +08:00
使用 Dynaconf 进行环境隔离配置
2026-05-05 19:49:12 +08:00
"""
import sys
2026-05-08 15:42:32 +08:00
import platform
2026-05-05 19:49:12 +08:00
from pathlib import Path
2026-05-08 15:42:32 +08:00
from app.utils.logger import get_logger
2026-05-05 19:49:12 +08:00
# 添加项目根目录到Python路径
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
2026-05-08 15:42:32 +08:00
logger = get_logger()
2026-05-05 19:49:12 +08:00
2026-05-08 15:42:32 +08:00
def check_environment():
"""检查系统和Python版本"""
# 识别操作系统
os_name = platform.system()
print(f"当前操作系统: {os_name}")
2026-05-05 19:49:12 +08:00
2026-05-08 15:42:32 +08:00
if os_name not in ['Windows', 'Linux']:
print(f"警告: 未测试的操作系统 {os_name},可能存在问题")
2026-05-05 19:49:12 +08:00
2026-05-08 15:42:32 +08:00
# 检查Python版本
python_version = platform.python_version()
print(f"当前Python版本: {python_version}")
2026-05-05 19:49:12 +08:00
2026-05-08 15:42:32 +08:00
# 解析版本号
major, minor, *_ = map(int, python_version.split('.'))
2026-05-05 19:49:12 +08:00
2026-05-08 15:42:32 +08:00
if major == 3 and minor == 13:
print("✓ Python版本符合要求 (3.13)")
2026-05-05 19:49:12 +08:00
return True
2026-05-08 15:42:32 +08:00
else:
print(f"✗ Python版本不符合要求!")
print(f" 当前版本: {python_version}")
print(f" 要求版本: 3.13.x")
print(f"\n请使用 Python 3.13 版本运行此项目")
print(f"下载地址: https://www.python.org/downloads/")
2026-05-05 19:49:12 +08:00
return False
def main():
2026-05-08 15:42:32 +08:00
check_environment()
2026-05-05 19:49:12 +08:00
if __name__ == "__main__":
main()