joshua-auchincloss / hatch-cython

cython hooks for hatch
MIT License
27 stars 5 forks source link

Support pure C/CPP extensions #48

Open vhdirk opened 7 months ago

vhdirk commented 7 months ago

Hi!

I'm trying to port a cython extension using hatch-cython. But contrary to all examples, it's composed completely in C, rather than pyx/pxd/py files. This is the one I'm trying to port: https://github.com/hbldh/b2ac/blob/master/setup.py

Do you have any suggestions/ides on how you would do this?

If I add c to the precompiled extensions and just replace the 'sources' parameter for setuptools Extension in the generated setup.py, it seems to work. Does the order of the files in 'sources' matter?

joshua-auchincloss commented 7 months ago

Hey! No problem - there's actually a test case for this (or closest to). You'll want to set up a build hook first, and then you’ll want to point hatch to the build hook. You should then be able to utilize the c/c++ source in Cython to develop the bridge code between the two (eg). If you're trying to build the bridge (ie no cython at all) automatically, I'm open to this as a FR - granted though, there would still need to be something to point to for the namespace imports / externs else we are opening the case for full global emissions.