[英]Build C library with CMakeLists.txt while packaging python library
I use Cython to wrap C library and extend its functionality.我使用 Cython 包装 C 库并扩展其功能。 C library is developed by separate team and is provided with CMakeLists.txt.
C 库由单独的团队开发,并随 CMakeLists.txt 提供。 For now I use source.c and.h files to build this library.
现在我使用 source.c 和 .h 文件来构建这个库。 This is how my
build.py
file for poetry ( setup.py
analog) looks like:这就是我的诗歌
build.py
文件( setup.py
模拟)的样子:
...
# 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)?是否可以在
build
function (或setuptools.setup
函数)中使用CMakeLists.txt
构建c_library
?
UPD: It is also ok for me to define variable that is used in.c files. UPD:我也可以定义在.c 文件中使用的变量。 I tried to add
define_macros
:我试图添加
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. UPD2:我终于找到了解决问题的方法,尽管这不是我最初问题的答案。 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. 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. scikit-build package 可以替换 setuptools 并且可以使用 CMakeLists.txt。 (See Basic Usage guide for scikit-build ).
(请参阅scikit-build 的基本使用指南)。 It can do CMake with Cython .
它可以用 Cython 做 CMake 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.