[Bug] Windows 原生环境下后端导入失败:模块级引用 POSIX-only 依赖(fcntl / os.O_DIRECTORY) · Issue #1097 · xerrors/Yuxi · GitHub
Skip to content

[Bug] Windows 原生环境下后端导入失败:模块级引用 POSIX-only 依赖(fcntl / os.O_DIRECTORY) #1097

Open

Description

@AWUQAQ

1️⃣ 描述一下问题

环境:Windows 11、Python 3.13.5、main 分支(031e2c7)。

在 Windows 原生环境(非 WSL/容器)下,后端包存在多处模块级 POSIX-only 依赖,导入阶段即失败,pytest test/unit 无法完成收集:

  • package/yuxi/utils/paths.py:8:_DIRECTORY_OPEN_FLAGS = os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW,import yuxi.utils.paths(以及 yuxi.workspace)抛 AttributeError: module 'os' has no attribute 'O_DIRECTORY'
  • package/yuxi/services/skills/projection.py:6:模块级 import fcntl,Windows 无此模块
  • test/unit/utils/test_paths.py:13:测试内直接使用 os.O_DIRECTORY

2️⃣ 报错日志

File "...backend\package\yuxi\workspace\__init__.py", line 3, in <module>
    from .filesystem import Workspace
File "...backend\package\yuxi\workspace\filesystem.py", line 12, in <module>
    from yuxi.utils.paths import open_directory_fd, open_regular_file_fd
File "...backend\package\yuxi\utils\paths.py", line 8, in <module>
    _DIRECTORY_OPEN_FLAGS = os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW
AttributeError: module 'os' has no attribute 'O_DIRECTORY'

量化验证:将 paths.py:8 的常量临时改为 getattr 兜底后执行 pytest test/unit --collect-only,结果为 1197 个用例收集成功、94 个收集错误,其中 83 个为 ModuleNotFoundError: No module named 'fcntl'(projection.py),1 个为 os.O_DIRECTORY(test_paths.py),其余 10 个为 No module named 'test.performance' 等 test 包内导入错误(未进一步定位)。

3️⃣ 相关截图

无

4️⃣ 其他相关信息

README 快速开始包含 Windows PowerShell 初始化步骤(.\scripts\init.ps1)。若 Windows 原生开发不在支持范围(开发与测试均通过 Docker 容器进行),该问题也可以按文档说明处理;若希望至少导入不失败,可能的处理方式包括将常量改为 getattr(os, "O_DIRECTORY", 0) 形式的兜底定义、fcntl 改为函数内按需导入等。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions