Python setup script extensions, how do you include a .h file?

So I've got a directory that looks something like this:

 home\
     setup.py
     some_python_file.py
     ext\
         __init__.py
         c_file1.c
         c_file2.c
         ext_header.h

Obviously the header file is necessary to compile the c files, but the problem is that I can't get the setup script to include the header file.

My extension object is something like this:

Extension('ext.the_extension', ['ext/c_file1.c', 'ext/c_file2.c'])

Which works, but doesn't include the header file. If I change it to:

Extension('ext.the_extension', ['ext/c_file1.c', 'ext/c_file2.c', 'ext_header.h'])

It includes the '.h' file but then doesn't build when I run install. Instead it gives and error error: unknown file type '.h' (from 'ext/ext_header.h')

If I include the header file as a data file like this:

data_files=[('ext', ['ext/ext_header.h'])]

it doesn't work at all, the .h file doesn't even make it into the MANIFEST file.

So my queustion is, how do you include this extension with the header file so that python setup.py install will build it correctly?

10
задан Dacav 24 July 2018 в 14:27
поделиться