环境
- 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 依次尝试 cmake → gmake → make:
FileNotFoundError: [Errno 2] No such file or directory: 'cmake'
FileNotFoundError: [Errno 2] No such file or directory: 'gmake'
macOS 默认只有 BSD make,没有 cmake 和 gmake。
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 端到端加密群聊功能,普通消息、文件传输等不受影响。
建议修复方向
- 上游 libolm:修复
include/olm/list.hh 将 T * const other_pos 改为 T * other_pos
- python-olm:升级捆绑的 libolm 或发布新版本
- matrix-nio:考虑支持
libolm(PyPI 上的替代 Python 绑定)作为可选依赖
相关
环境
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依次尝试cmake→gmake→make:macOS 默认只有 BSD
make,没有cmake和gmake。2. libolm C++ const-correctness bug(致命)
即使安装了 cmake,编译仍会失败:
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 端到端加密群聊功能,普通消息、文件传输等不受影响。
建议修复方向
include/olm/list.hh将T * const other_pos改为T * other_poslibolm(PyPI 上的替代 Python 绑定)作为可选依赖相关