Update Conan setup to use Python venv.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-26 09:28:42 +08:00
parent 330cd686db
commit d22a0102e2
6 changed files with 57 additions and 33 deletions

View File

@@ -10,6 +10,6 @@ if exist "%TOOLS%ninja" set "PATH=%TOOLS%ninja;%PATH%"
if exist "%TOOLS%llvm\bin" set "PATH=%TOOLS%llvm\bin;%PATH%"
if exist "%TOOLS%llvm\bin\clang.exe" set "CC=%TOOLS%llvm\bin\clang.exe"
if exist "%TOOLS%llvm\bin\clang++.exe" set "CXX=%TOOLS%llvm\bin\clang++.exe"
if exist "%TOOLS%conan2" set "PATH=%TOOLS%conan2;%PATH%"
if exist "%TOOLS%.venv\Scripts" set "PATH=%TOOLS%.venv\Scripts;%PATH%"
echo [dstalk] tools\ 工具链已加载

View File

@@ -105,28 +105,52 @@ if exist "%TOOLS%llvm\bin\clang.exe" (
)
:: ============================================================
:: 4. Conan2 (独立安装器)
:: 4. Python venv + Conan2
:: ============================================================
echo [4/5] Conan2 ...
if exist "%TOOLS%conan2\conan.exe" (
echo [OK] 已存在
) else (
mkdir "%TOOLS%conan2" 2>nul
curl -L -o "%TOOLS%conan2\conan-installer.exe" "https://github.com/conan-io/conan/releases/latest/download/conan-2-win-64.exe" 2>nul
if !errorlevel! neq 0 (
echo [FAIL] 请手动下载: https://conan.org.cn/downloads
) else (
"%TOOLS%conan2\conan-installer.exe" /S /D="%TOOLS%conan2"
del "%TOOLS%conan2\conan-installer.exe" 2>nul
echo [OK] Conan2
echo [4/5] Python venv + Conan2 ...
set "PYTHON="
for %%p in (python python3) do (
if not defined PYTHON (
where %%p >nul 2>nul
if !errorlevel! equ 0 set "PYTHON=%%p"
)
)
if not defined PYTHON (
echo [FAIL] 未找到 Python 3.10+
echo 请先安装 Python并确保 python.exe 在 PATH 中
pause
exit /b 1
)
if not exist "%TOOLS%.venv\Scripts\python.exe" (
call %PYTHON% -m venv "%TOOLS%.venv"
if !errorlevel! neq 0 (
echo [FAIL] 创建 Python venv 失败
pause
exit /b 1
)
)
call "%TOOLS%.venv\Scripts\python.exe" -m pip install --upgrade pip
if !errorlevel! neq 0 (
echo [FAIL] pip 更新失败
pause
exit /b 1
)
call "%TOOLS%.venv\Scripts\python.exe" -m pip install "conan>=2,<3"
if !errorlevel! neq 0 (
echo [FAIL] Conan2 安装失败
pause
exit /b 1
)
echo [OK] Conan2
:: ============================================================
:: 5. 配置 Conan profile
:: ============================================================
echo [5/5] 配置 Conan ...
call "%TOOLS%conan2\conan.exe" profile detect --force 2>nul
call "%TOOLS%.venv\Scripts\conan.exe" profile detect --force 2>nul
if errorlevel 1 (
echo [WARN] Conan profile 配置失败 (可能首次运行需手动配置)
)