Skip to content

Commit 82303fc

Browse files
fix: demos on win (#2092)
* fix: demo1 * fix: ten_gn * fix: demo 1 * fix: tman check clang-cl * fix: .env file markdown * fix: install python deps * fix: python3 alias * fix: python3 symlink * fix: refine codes --------- Co-authored-by: Hu Yueh-Wei <[email protected]>
1 parent 58aac6b commit 82303fc

File tree

8 files changed

+293
-87
lines changed

8 files changed

+293
-87
lines changed

ai_agents/agents/examples/websocket-example/tenapp/scripts/install_python_deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def main():
102102
print("Starting Python dependencies installation...")
103103

104104
# Determine pip command
105-
pip_cmd = ["uv", "pip", "install"]
105+
pip_cmd = ["uv", "pip", "install", "--system"]
106106

107107
# Try to install server requirements
108108
server_req = app_dir.parent / "server" / "requirements.txt"

core/src/ten_manager/src/check_env/check_cpp.rs

Lines changed: 101 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ use anyhow::Result;
88

99
use super::types::{CheckStatus, CppCheckResult, Suggestion, ToolInfo};
1010

11-
/// Use vswhere.exe to locate cl.exe from the latest VS installation.
12-
/// vswhere.exe ships with every VS 2017+ install and lives at a fixed path,
13-
/// so this works even when the Developer Command Prompt has not been activated.
11+
/// Check whether Visual Studio (with any C++ workload) is installed by
12+
/// querying vswhere.exe.
1413
#[cfg(windows)]
15-
fn find_cl_exe_via_vswhere() -> Option<String> {
14+
fn is_vs_installed() -> bool {
1615
let vswhere = r"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe";
1716
if !std::path::Path::new(vswhere).exists() {
18-
return None;
17+
return false;
1918
}
2019

21-
let vs_path = std::process::Command::new(vswhere)
20+
std::process::Command::new(vswhere)
2221
.args([
2322
"-latest",
2423
"-products",
@@ -31,24 +30,51 @@ fn find_cl_exe_via_vswhere() -> Option<String> {
3130
.output()
3231
.ok()
3332
.filter(|o| o.status.success())
34-
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())?;
33+
.map(|o| !String::from_utf8_lossy(&o.stdout).trim().is_empty())
34+
.unwrap_or(false)
35+
}
3536

36-
// Read the default MSVC toolset version from the version file.
37-
let version_file =
38-
format!(r"{}\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt", vs_path);
39-
let msvc_ver = std::fs::read_to_string(&version_file).ok()?;
40-
let msvc_ver = msvc_ver.trim();
37+
#[cfg(not(windows))]
38+
fn is_vs_installed() -> bool {
39+
false
40+
}
4141

42-
let cl = format!(r"{}\VC\Tools\MSVC\{}\bin\Hostx64\x64\cl.exe", vs_path, msvc_ver);
43-
if std::path::Path::new(&cl).exists() {
44-
Some(cl)
42+
/// Use vswhere.exe to locate clang-cl.exe from the latest VS installation.
43+
/// clang-cl.exe is available when the "C++ Clang tools" component is installed.
44+
#[cfg(windows)]
45+
fn find_clang_cl_exe_via_vswhere() -> Option<String> {
46+
let vswhere = r"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe";
47+
if !std::path::Path::new(vswhere).exists() {
48+
return None;
49+
}
50+
51+
let vs_path = std::process::Command::new(vswhere)
52+
.args([
53+
"-latest",
54+
"-products",
55+
"*",
56+
"-requires",
57+
"Microsoft.VisualStudio.Component.VC.Llvm.Clang",
58+
"-property",
59+
"installationPath",
60+
])
61+
.output()
62+
.ok()
63+
.filter(|o| o.status.success())
64+
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
65+
.filter(|s| !s.is_empty())?;
66+
67+
let clang_cl =
68+
format!(r"{}\VC\Tools\Llvm\x64\bin\clang-cl.exe", vs_path);
69+
if std::path::Path::new(&clang_cl).exists() {
70+
Some(clang_cl)
4571
} else {
4672
None
4773
}
4874
}
4975

5076
#[cfg(not(windows))]
51-
fn find_cl_exe_via_vswhere() -> Option<String> {
77+
fn find_clang_cl_exe_via_vswhere() -> Option<String> {
5278
None
5379
}
5480

@@ -308,40 +334,50 @@ pub fn check() -> Result<CppCheckResult> {
308334
});
309335
}
310336
} else if os == "windows" {
311-
// On Windows, cl.exe is not in PATH unless running inside a Developer
312-
// Command Prompt / Developer PowerShell. We use vswhere.exe (bundled
313-
// with every VS installation) to locate it directly.
314-
let cl_path = find_cl_exe_via_vswhere();
337+
// Check whether Visual Studio is installed via vswhere.
338+
let has_vs = is_vs_installed();
339+
340+
// Check clang-cl.exe (shipped with VS "C++ Clang tools" component).
341+
let clang_cl_path = find_clang_cl_exe_via_vswhere();
315342

316-
let msvc_check = if let Some(ref path) = cl_path {
317-
std::process::Command::new(path).arg("/?").output()
343+
let clang_cl_check = if let Some(ref path) = clang_cl_path {
344+
std::process::Command::new(path).arg("--version").output()
318345
} else {
319346
// Fallback: maybe the user already has it in PATH.
320-
std::process::Command::new("cl.exe").arg("/?").output()
347+
std::process::Command::new("clang-cl.exe")
348+
.arg("--version")
349+
.output()
321350
};
322351

323-
match msvc_check {
324-
Ok(output) if output.status.success() || !output.stderr.is_empty() => {
325-
// cl.exe prints version info to stderr, not stdout.
326-
let version_str = String::from_utf8_lossy(&output.stderr);
327-
let version = version_str.lines().next().map(|s| s.trim().to_string());
328-
329-
let resolved_path = cl_path.or_else(|| {
352+
match clang_cl_check {
353+
Ok(output) if output.status.success() => {
354+
let version_str =
355+
String::from_utf8_lossy(&output.stdout);
356+
let version = version_str
357+
.lines()
358+
.next()
359+
.map(|s| s.trim().to_string());
360+
361+
let resolved_path = clang_cl_path.or_else(|| {
330362
std::process::Command::new("where.exe")
331-
.arg("cl.exe")
363+
.arg("clang-cl.exe")
332364
.output()
333365
.ok()
334366
.and_then(|o| {
335367
if o.status.success() {
336-
Some(String::from_utf8_lossy(&o.stdout).trim().to_string())
368+
Some(
369+
String::from_utf8_lossy(&o.stdout)
370+
.trim()
371+
.to_string(),
372+
)
337373
} else {
338374
None
339375
}
340376
})
341377
});
342378

343379
compilers.push(ToolInfo {
344-
name: "cl.exe (MSVC)".to_string(),
380+
name: "clang-cl.exe".to_string(),
345381
version,
346382
path: resolved_path,
347383
status: CheckStatus::Ok,
@@ -351,7 +387,7 @@ pub fn check() -> Result<CppCheckResult> {
351387
}
352388
_ => {
353389
compilers.push(ToolInfo {
354-
name: "cl.exe (MSVC)".to_string(),
390+
name: "clang-cl.exe".to_string(),
355391
version: None,
356392
path: None,
357393
status: CheckStatus::Error,
@@ -361,13 +397,37 @@ pub fn check() -> Result<CppCheckResult> {
361397
}
362398

363399
if !has_compiler {
364-
suggestions.push(Suggestion {
365-
issue: "MSVC compiler not found".to_string(),
366-
command: Some("Install Visual Studio with C++ build tools".to_string()),
367-
help_text: Some(
368-
"Please install Visual Studio with C++ development tools".to_string(),
369-
),
370-
});
400+
if has_vs {
401+
// VS is installed but the Clang component is missing.
402+
suggestions.push(Suggestion {
403+
issue: "clang-cl.exe not found".to_string(),
404+
command: None,
405+
help_text: Some(
406+
"Visual Studio is installed but the C++ Clang tools \
407+
component is missing. Please open Visual Studio \
408+
Installer, click \"Modify\", and enable the \
409+
\"C++ Clang tools\" component under \
410+
\"Individual components\", then install it."
411+
.to_string(),
412+
),
413+
});
414+
} else {
415+
// VS is not installed at all.
416+
suggestions.push(Suggestion {
417+
issue: "clang-cl.exe not found".to_string(),
418+
command: Some(
419+
"Install Visual Studio with C++ build tools"
420+
.to_string(),
421+
),
422+
help_text: Some(
423+
"Please install Visual Studio with C++ development \
424+
tools. During installation, make sure to also enable \
425+
the \"C++ Clang tools\" component under \
426+
\"Individual components\"."
427+
.to_string(),
428+
),
429+
});
430+
}
371431
}
372432
}
373433

core/ten_gn

docs/getting-started/quick-start.cn.md

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,11 @@ _portal_target: getting-started/quick-start.cn.md
3131

3232
### Python 3.10
3333

34-
**Linux / macOS:**
35-
3634
```bash
3735
python3 --version
3836
# 应显示: Python 3.10.x
3937
```
4038

41-
**Windows:**
42-
43-
```powershell
44-
python --version
45-
# 应显示: Python 3.10.x
46-
```
47-
4839
> 💡 **重要**:TEN Framework 目前仅支持 Python 3.10。推荐使用 `pyenv``venv` 创建 Python 虚拟环境:
4940
>
5041
> **Linux / macOS:**
@@ -65,18 +56,40 @@ python --version
6556
>
6657
> 注意,点击Install Now前务必勾选 "Add Python to PATH"
6758
>
59+
> ```bash
60+
> # Windows平台需要配置python3命令:
61+
>
62+
> # 首先,确认python的安装路径:
63+
> where.exe python
64+
> # 输出示例: C:\Users\YourName\AppData\Local\Programs\Python\Python310\python.exe
65+
>
66+
> # 然后,以管理员身份打开 PowerShell,在python.exe同目录下创建symlink:
67+
> New-Item -ItemType SymbolicLink -Path "C:\Users\YourName\AppData\Local\Programs\Python\Python310\python3.exe" -Target "C:\Users\YourName\AppData\Local\Programs\Python\Python310\python.exe"
68+
> # 请将上面的路径替换为 where.exe python 的实际输出路径
69+
>
70+
> # 验证:
71+
> python3 --version
72+
> ```
73+
>
6874
> ```powershell
6975
> # 推荐安装后使用 venv 创建虚拟环境,在该环境中工作
7076
> py -3.10 -m venv $env:USERPROFILE\ten-venv
71-
> # 每次工作前,激活环境
77+
> # 激活环境
7278
> & "$env:USERPROFILE\ten-venv\Scripts\Activate.ps1"
79+
>
80+
> # 若有权限错误,关闭终端/IDE,右键选择“以管理员身份运行”重新打开
81+
> # 或者改变执行策略来允许ps1脚本执行
82+
> Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
7383
> ```
7484
7585
### Go 1.20+
7686
7787
```bash
7888
go version
7989
# 应显示: go version go1.20 或更高版本
90+
91+
$env:CGO_ENABLED = "1"
92+
# Windows下需要显式启用CGO
8093
```
8194
8295
### Node.js / npm
@@ -87,6 +100,25 @@ npm --version
87100
# 确保 node 和 npm 命令可用
88101
```
89102

103+
### GCC (MinGW)
104+
💡仅在windows上需要安装
105+
``` bash
106+
# 首先确定winget存在。
107+
winget --version
108+
109+
# 若不存在则需要从 <https://apps.microsoft.com/detail/9nblggh4nns1?hl=en-US&gl=US> 安装。
110+
#(系统需要满足:Windows10 高于 1709 (Build 16299),或者是Windows11)
111+
112+
#安装MinGW
113+
winget install BrechtSanders.WinLibs.POSIX.MSVCRT
114+
115+
# 或查找后自行选择合适版本安装
116+
winget search "mingw"
117+
118+
#检查安装
119+
gcc --version
120+
```
121+
90122
> 💡 **提示**:如果缺少上述环境,请先安装对应版本后再继续。
91123
92124
## 第二步:安装 TEN Manager (tman)
@@ -111,14 +143,6 @@ brew install TEN-framework/ten-framework/tman
111143

112144
**Windows:**
113145

114-
```powershell
115-
# 首先确定winget存在。
116-
winget --version
117-
```
118-
119-
若不存在则需要从 <https://apps.microsoft.com/detail/9nblggh4nns1?hl=en-US&gl=US> 安装。
120-
(系统需要满足:Windows10 高于 1709 (Build 16299),或者是Windows11)
121-
122146
```powershell
123147
winget install TEN-framework.tman
124148
```
@@ -439,10 +463,13 @@ xcode-select --install
439463
```powershell
440464
# 方式一:安装 Visual Studio Build Tools(推荐)
441465
# 从 https://visualstudio.microsoft.com/visual-cpp-build-tools/ 下载安装
442-
# 安装时选择 "使用 C++ 的桌面开发" 工作负载
443466
444467
# 方式二:使用 winget 安装
445468
winget install Microsoft.VisualStudio.2022.BuildTools --override "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --passive"
469+
470+
# 💡注意:
471+
# - 安装时选择 "使用 C++ 的桌面开发" 工作负载
472+
# - 且务必勾选“适用于Windows的C++ Clang工具”
446473
```
447474

448475
验证编译器安装:
@@ -460,7 +487,7 @@ clang --version
460487

461488
```powershell
462489
# 在 "Developer PowerShell for VS" 中执行
463-
cl
490+
clang-cl --version
464491
```
465492

466493
### 常见问题(C++ 扩展)
@@ -525,6 +552,12 @@ export DYLD_LIBRARY_PATH=/usr/local/opt/[email protected]/Frameworks/Python.framework/
525552
**解决方案**
526553

527554
```bash
555+
# 设置代理
556+
# Linux/macOS
557+
export GOPROXY=https://goproxy.cn,direct
558+
# Windows PowerShell
559+
$env:GOPROXY = "https://goproxy.cn,direct"
560+
528561
# 清理 Go module 缓存
529562
go clean -modcache
530563

@@ -549,6 +582,12 @@ pip3 install --index-url https://pypi.tuna.tsinghua.edu.cn/simple -r requirement
549582

550583
**解决方案**:检查.env文件中的配置是否正确,确保 AZURE_STT_KEY 和 AZURE_STT_REGION 填写无误
551584

585+
### 7. Windows下权限问题
586+
587+
**问题**:Windows下在访问文件时报PermissionError
588+
589+
**解决方案**:右键点击PowerShell,选择“以管理员身份运行”
590+
552591
## 获取帮助
553592

554593
- **GitHub Issues**<https://github.com/TEN-framework/ten-framework/issues>

0 commit comments

Comments
 (0)