I use Cython to wrap C library and extend its functionality. C library is developed by separate team and is provided with CMakeLists.txt. For now I use source.c and.h files to build this library. This is how my build.py
file for poetry ( setup.py
analog) looks like:
...
# source_files_paths - list of full paths to .c files
c_library = ('c_library', {'sources': source_files_paths})
...
def build(setup_kwargs):
setup_kwargs.update({
...,
'libraries': [c_library], # Here c library is built with build_clib command
...
})
Is it possible to use CMakeLists.txt
to build c_library
in build
function (or in setuptools.setup
function)?
UPD: It is also ok for me to define variable that is used in.c files. I tried to add define_macros
:
c_library = ('c_library', {'sources': source_files_paths,
'define_macros': [('MY_MACRO': True)]})
Still no luck with it.
UPD2: I finally found the solution to my problem though it is not the answer to my initial question. To add macros you should add it in this way:
c_library = ('c_library', {'sources': source_files_paths,
'macros': [('MY_MACRO': True)]})
According to build_libraries
function from http://svn.python.org/projects/python/branches/pep-0384/Lib/distutils/command/build_clib.py you can also specify 'include_dirs', 'obj_deps' and 'cflags' arguments.
The scikit-build package can replace setuptools and it is able to use CMakeLists.txt. (See Basic Usage guide for scikit-build ). It can do CMake with Cython .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.