如何解决在 python setuptools 中混合 cython 和 cmake 扩展
ValueError: `decode_predictions` expects a batch of predictions (i.e. a 2D array of shape (samples,1000)). Found array with shape: (1,100352)
我想知道我是否可以调用 from setuptools import setup,Extension
from setuptools.command.build_ext import build_ext
class CMakeExtension(Extension):
# ...
class CMakeBuild(build_ext):
# ...
extensions = [
CMakeExtension("cmake_extension","path-to-sources"),Extension("cython_extension",["file.pyx"]),]
setup(
# ...
ext_modules=extensions,# ...
)
并使用适当的构建器构建每个扩展。
我知道 python setup.py build_ext --inplace
设置函数参数,但没有找到指定 cmdclass
用于 cython 扩展和 build_ext
用于 cmake 扩展的方法。>
请注意,每个扩展都使用正确的构建器类(和 CMakeBuild
参数)构建良好。
谢谢!
解决方法
最好的办法是确保 CMakeBuild
检测到扩展的类型并在扩展不是 build_ext
的实例时恢复到原始 CMakeExtension
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。