Files
hertz_django/init_backend.bat
2025-12-13 15:41:17 +08:00

62 lines
1.4 KiB
Batchfile
Raw 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.

@echo off
chcp 65001 >nul
echo ================================
echo Hertz Django 项目初始化脚本
echo ================================
echo 检查 Python 环境...
python --version
if %errorlevel% neq 0 (
echo 错误: 未检测到 Python请先安装 Python!
pause
exit /b 1
)
echo 配置 pip 全局镜像源...
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
echo 创建虚拟环境...
python -m venv venv
if %errorlevel% neq 0 (
echo 错误: 创建虚拟环境失败!
pause
exit /b 1
)
echo 激活虚拟环境...
call venv\Scripts\activate
if %errorlevel% neq 0 (
echo 错误: 激活虚拟环境失败!
pause
exit /b 1
)
echo 升级 pip...
python -m pip install --upgrade pip
if %errorlevel% neq 0 (
echo 错误: 升级 pip 失败!
pause
exit /b 1
)
echo 安装 Python 第三方依赖...
pip install -r requirements.txt
if %errorlevel% neq 0 (
echo 错误: 安装 requirements.txt 失败!
pause
exit /b 1
)
echo 安装 Hertz 官方依赖...
pip install -r hertz.txt -i https://hertz:hertz@hzpypi.hzsystems.cn/simple/
if %errorlevel% neq 0 (
echo 错误: 安装 hertz.txt 失败! 请先激活机器码。
pause
exit /b 1
)
echo ================================
echo 项目初始化完成!
echo ================================
echo 请运行 start_project.bat 启动项目
pause