【发布时间】:2021-06-04 09:47:42
【问题描述】:
我想为 CMake 项目提供 Homebrew 公式,该项目构建和安装 C++ 库及其使用 pybind11 编写的 Python 绑定。理想情况下,该公式应该通过运行一个普通的来工作
cmake --build . --target install
此安装流程在本地运行良好,但使用 Homebrew 公式会在 Python 绑定的安装目录中引入问题:虽然头文件和库安装在由 #{prefix} 标识的 Cellar 的正确目录中,但绑定需要位于 Python 可见的 site-packages 目录中。我正在使用
在 CMake 中获取这样的目录install(TARGETS pyariadne DESTINATION ${Python_SITEARCH})
但 Homebrew 似乎无法写入该目录,返回一个 Operation not permitted。
通过以下方式识别安装目录
execute_process(COMMAND python3 -m site --user-site OUTPUT_VARIABLE INSTALL_DIR)
也不起作用,因为 Homebrew 在 /tmp 中标识了一个临时用户站点,因此随后删除了安装在那里的任何库。
我应该如何安装 Homebrew 中的所有内容,而不需要更改目录权限?我想避免为 pypi 打包并使用 pip 单独安装绑定。
EDIT(输出示例,涉及目录):
[109/110] Install the project...
-- Install configuration: "Release"
-- Installing:
/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyariadne.so
CMake Error at cmake_install.cmake:49 (file):
file INSTALL cannot copy file
"/tmp/ariadne-20210305-1763-ggejxl/ariadne-2.1-rc2/build/pyariadne.so" to
"/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyariadne.so":
Operation not permitted.
目录/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages 链接到/usr/local/lib/python3.9/site-packages。前者有用户lgeretti:staff,后者有用户lgeretti:admin。
这个问题不仅发生在我的机器上,而且我还在 macos:latest GitHub Actions 机器上验证它,其中唯一需要的步骤是 brew install 包。
【问题讨论】:
-
你确定你使用的是 Homebrew 安装的 Python 而不是系统默认的 Python 吗? Homebrew 目录应该是用户可写的。
-
我很积极。我在原始帖子中添加了一个输出示例。
-
您是否运行
brew doctor并确认没有安装问题? -
brew医生很好。在 OP 的底部,我添加了所涉及的目录和每个用户:组,但我不希望出现一些用户权限问题。
标签: python macos cmake homebrew pybind11