The example does not explain how to handle .h file.
sun1638650145 opened this issue · 2 comments
This example does not explain how to deal with the .h file. When I package it according to the example, I find that the wheel file is normal, but the .h file is not packaged in the source code of tar.gz. The code is below.
extension_modules = [
Pybind11Extension(
'classicML/backend/cc/ops',
sorted(glob('classicML/backend/cc/*.cc')),
include_dirs=[
'/usr/local/include/eigen3', # /path/to/eigen3/download
],
language='c++',
)
]When I realized this problem, I modified the source code to the following.
sorted(glob('classicML/backend/cc/*[cc.h]'))Runpython3 setup.py sdist bdist_wheel. The .h file can be packaged into the source code, and there is a problem with generating the wheel file.😭
Creating tar archive
removing 'classicML-0.5' (and everything under it)
running bdist_wheel
running build
running build_py
running build_ext
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c flagcheck.cpp -o flagcheck.o -std=c++17
building 'classicML/backend/cc/ops' extension
error: unknown file type '.h' (from 'classicML/backend/cc/matrix_op.h')I just started learning to use pybind. I don’t know if this is a problem with setuptools or pybind.
Add the file to your MANIFEST.in. That controls the SDist. Don't add it to your sources, that controls the compile. I think there's a headers slot in Extension, but that's optional and has no effect on the SDist. Or the include paths IIRC.
Use pip wheel . to build wheels, or better yet use pip install build followed by python -m build to build both sdist and wheel.
Add the file to your MANIFEST.in. That controls the SDist. Don't add it to your sources, that controls the compile. I think there's a headers slot in Extension, but that's optional and has no effect on the SDist. Or the include paths IIRC.
Use
pip wheel .to build wheels, or better yet usepip install buildfollowed bypython -m buildto build both sdist and wheel.
I solved the problem using the method you provided. Thanks.