首页 > 解决方案 > Python bdist_wheel + install 有效,但由于 PEP 517 sdist + install 失败

问题描述

我正在开发一个 Python 包,它使用 Pybind11 + cmake 包装了一个 C++ 库,代码可在https://github.com/bayesmix-dev/pybmix获得

由于我在 Linux 上工作,为了通过 PyPi 分发它,我知道有两种选择:

  1. 构建一个 manylinux 轮子
  2. 分发二进制文件,用户需要在本地安装

鉴于我不确定有多少用户会使用我的包,我选择了第二个选项。此外,我通过 CMake 子模块处理所有 C++ 库,以便该库是“自包含的”。

现在问题来了:运行

python3 setup.py bdist_wheel

产生一个dist/pybmix-0.0.2-cp38-cp38-linux_x86_64.whl由于linux_...零件而损坏的文件。然而运行

pip3 install pybmix-0.0.2-cp38-cp38-linux_x86_64.whl

在我的机器上工作

跑步

python3 setup.py sdist

产生一个文件dist/pybmix-0.0.2.tar.gz,安装它失败:

pip3 install dist/pybmix-0.0.2.tar.gz

.....
 
subprocess.CalledProcessError: Command '['cmake', '--version']' returned non-zero exit status 1.
----------------------------------------
ERROR: Failed building wheel for pybmix
Failed to build pybmix
ERROR: Could not build wheels for pybmix which use PEP 517 and cannot be installed directly

也可能相关但可能不相关,我正在使用协议缓冲区生成一些 Python 和 C++ 文件,这是在 CMakeLists.txt 文件中完成的,因此在我的 setup.py 中,我已经覆盖了build_py第一次调用build_ext(被覆盖为以及在https://github.com/pybind/cmake_example中)

标签: pythonsetuptoolspython-packagingpybind11python-extensions

解决方案


推荐阅读