Skip to content

python-olm 3.2.16 在 macOS Python 3.14 + Apple Clang 21 下编译失败 (matrix-nio[e2e]) #462

@Klausc06

Description

@Klausc06

环境

  • macOS (Apple Silicon, arm64)
  • Python 3.14.2
  • Apple Clang 21.0.0 (clang-2100.0.123.102)
  • 安装 matrix-nio[e2e] 时触发

复现步骤

pip install matrix-nio[e2e]
#
uv pip install matrix-nio[e2e]

错误日志

python-olm 3.2.16 从源码编译时失败,两个问题

1. 缺少 cmake / gmake

构建脚本 olm_build.py 依次尝试 cmakegmakemake

FileNotFoundError: [Errno 2] No such file or directory: 'cmake'
FileNotFoundError: [Errno 2] No such file or directory: 'gmake'

macOS 默认只有 BSD make,没有 cmakegmake

2. libolm C++ const-correctness bug(致命)

即使安装了 cmake,编译仍会失败:

include/olm/list.hh:106:13: error: cannot assign to variable 'other_pos' 
    with const-qualified type 'T *const'
  106 |             ++other_pos;
      |             ^ ~~~~~~~~~
include/olm/list.hh:102:19: note: variable 'other_pos' declared const here
  102 |         T * const other_pos = other._data;
      |         ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

T * const 声明了一个不可修改的 const 指针,但后续代码对其做了 ++,这在标准 C++ 中是硬错误。Apple Clang 21 对此严格执行,非 -Werror 问题。

根因

python-olm 捆绑的 libolm 源码有 const-correctness bug,且该包自 2023 年以来未更新,与新编译器不兼容。

临时规避方案

跳过 e2e 加密支持:

pip install matrix-nio  # 不加 [e2e]

或修改 requirements/matrix.txt / pyproject.toml[matrix] extra,去掉 [e2e]

- matrix-nio[e2e]>=0.25.2,<1.0.0
+ matrix-nio>=0.25.2,<1.0.0

副作用:失去 Matrix 端到端加密群聊功能,普通消息、文件传输等不受影响。

建议修复方向

  1. 上游 libolm:修复 include/olm/list.hhT * const other_pos 改为 T * other_pos
  2. python-olm:升级捆绑的 libolm 或发布新版本
  3. matrix-nio:考虑支持 libolm(PyPI 上的替代 Python 绑定)作为可选依赖

相关

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions