Closed ChingChuan-Chen closed 9 months ago
Apologies for the delayed reponse - you should be able to exclude the file from any actions (i.e preserve all cpp
artifacts) if you do something like the following:
# hatch.toml
[build.hooks.cython.options]
# these might be NRQ
env = [{ env = "CPPFLAGS", arg = "-I./poc", platforms = "*", arch = "*" }]
extra_link_args = [{ arg = "-L./poc", platforms = "*", arch = "*" }]
[build.hooks.cython.options.files]
# this would be required
exclude = [{ matches = "*.cpp" }, { matches = "*/*.cpp" }]
You would then want to cimport
the cpp_helper.h
in your do_stuff.pyx
. Let me know if this works and I'll tag / add an example appropriately :)
Added an example into src_structure to highlight using c/c++ helpers without the above workaround. Recommend to split into two source directories and utilize a custom include path to let cython resolve the path.
My package is like below:
The
cpp_helper.cpp
will be deleted if my code failed to compile. It looks like that it clearn up everycpp
andc
files. Coud please you help fix it?