cnitlrt Claude Opus 4.6 (1M context) commited on
Commit
168414d
·
1 Parent(s): dd7ab62

fix: Windows 支持 — 跳过虚拟显示器,xvfbwrapper 改为 Linux-only 依赖

Browse files

Windows 没有 fcntl 模块,xvfbwrapper 不支持。
display.py 改为只在 Linux 且无 DISPLAY 环境变量时才启动 Xvfb。
pyproject.toml 中 xvfbwrapper 加 sys_platform == 'linux' 条件。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Files changed (2) hide show
  1. pyproject.toml +1 -1
  2. src/autoteam/display.py +10 -5
pyproject.toml CHANGED
@@ -9,7 +9,7 @@ dependencies = [
9
  "requests>=2.28.0",
10
  "rich>=14.3.4",
11
  "uvicorn[standard]>=0.44.0",
12
- "xvfbwrapper>=0.2.9",
13
  ]
14
 
15
  [project.scripts]
 
9
  "requests>=2.28.0",
10
  "rich>=14.3.4",
11
  "uvicorn[standard]>=0.44.0",
12
+ "xvfbwrapper>=0.2.9; sys_platform == 'linux'",
13
  ]
14
 
15
  [project.scripts]
src/autoteam/display.py CHANGED
@@ -1,16 +1,21 @@
1
- """自动设置虚拟显示器(无头服务器)— 在 import 时执行"""
2
 
3
  import logging
4
  import os
 
5
 
6
  logger = logging.getLogger(__name__)
7
 
8
- if not os.environ.get("DISPLAY"):
 
9
  try:
10
  from xvfbwrapper import Xvfb
11
 
12
  _vdisplay = Xvfb(width=1280, height=800)
13
  _vdisplay.start()
14
- except ImportError:
15
- os.system("Xvfb :99 -screen 0 1280x800x24 &")
16
- os.environ["DISPLAY"] = ":99"
 
 
 
 
1
+ """自动设置虚拟显示器(无头服务器)— 在 import 时执行,Windows/macOS 跳过"""
2
 
3
  import logging
4
  import os
5
+ import sys
6
 
7
  logger = logging.getLogger(__name__)
8
 
9
+ # Windows 和 macOS 不需要虚拟显示器(有真实显示器或 Playwright 自带 headless)
10
+ if sys.platform == "linux" and not os.environ.get("DISPLAY"):
11
  try:
12
  from xvfbwrapper import Xvfb
13
 
14
  _vdisplay = Xvfb(width=1280, height=800)
15
  _vdisplay.start()
16
+ except (ImportError, OSError):
17
+ try:
18
+ os.system("Xvfb :99 -screen 0 1280x800x24 &")
19
+ os.environ["DISPLAY"] = ":99"
20
+ except Exception:
21
+ pass