【发布时间】:2018-04-01 15:08:22
【问题描述】:
我正在使用 pybind11 并使用 setuptools 和 cmake 构建 python 模块,如pybind/cmake_example 中所述:
setup(
name='libraryname',
...
ext_modules=[CMakeExtension('libraryname')],
cmdclass=dict(build_ext=CMakeBuild),
)
在本地,使用 python setup.py sdist build 一切都很好,我可以使用和/或从生成的文件安装包。
我现在想将包上传到 PyPI。 从不同的 python 包中,我知道如何通过操作轮子的平台标签来生成通用的 linux 库(另请参见here):
class bdist_wheel(bdist_wheel_):
def finalize_options(self):
from sys import platform as _platform
platform_name = get_platform()
if _platform == "linux" or _platform == "linux2":
# Linux
platform_name = 'manylinux1_x86_64'
bdist_wheel_.finalize_options(self)
self.universal = True
self.plat_name_supplied = True
self.plat_name = platform_name
setup(
...
cmdclass = {'bdist_wheel': bdist_wheel},
)
问题:
没有bdist_wheel构建时如何生成合适的平台标签?
这是否应该以某种方式构建为轮子而不是扩展(可能与this issue on GH 相关)?
另外,pybind11 是如何决定生成库的后缀的(在我的 linux 上不只是.so,而是.cpython-35m-x86_64-linux-gnu.so)?
跟进:
- 主要问题是我无法将当前 Ubuntu 构建的包更新为 PyPI:
ValueError: Unknown distribution format: 'libraryname-0.8.0.cpython-35m-x86_64-linux-gnu.so' - 如果平台标签不能或不应更改:跨平台将 pybind11 模块上传到 PyPI 的最佳做法是什么?
【问题讨论】:
标签: c++ python-3.x pypi pybind11