Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在打包python库时使用CMakeLists.txt构建C库_Python_C_Cmake_Cython_Setup.py - Fatal编程技术网

在打包python库时使用CMakeLists.txt构建C库

在打包python库时使用CMakeLists.txt构建C库,python,c,cmake,cython,setup.py,Python,C,Cmake,Cython,Setup.py,我使用Cython包装C库并扩展其功能。C库由单独的团队开发,并随CMakeLists.txt一起提供。现在我使用source.c和.h文件来构建这个库。这就是我的诗歌(setup.pyanalog)的build.py文件的外观: ... # source_files_paths - list of full paths to .c files c_library = ('c_library', {'sources': source_files_paths}) ... def build(set

我使用Cython包装C库并扩展其功能。C库由单独的团队开发,并随CMakeLists.txt一起提供。现在我使用source.c和.h文件来构建这个库。这就是我的诗歌(
setup.py
analog)的
build.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
        ...
    })
是否可以使用
CMakeLists.txt
build
函数(或
setuptools.setup
函数)中构建
c_库

UPD:我也可以定义在.c文件中使用的变量。我试图添加
define_宏

c_library = ('c_library', {'sources': source_files_paths,
                           'define_macros': [('MY_MACRO': True)]})
还是不走运

UPD2:我终于找到了问题的解决方案,尽管它不是我最初问题的答案。要添加宏,应按以下方式添加宏:

c_library = ('c_library', {'sources': source_files_paths,
                           'macros': [('MY_MACRO': True)]})

根据
build_libraries
函数,您还可以指定'include_dirs'、'obj_deps'和'cflags'参数。

该软件包可以替换setuptools,并且可以使用CMakeLists.txt。(见附件)。可以。

在工作中,我编写了一些脚本,用python构建我的cmake项目。我可以使用python中的子流程模块来完成这项工作。这使我能够轻松地从python构建我的cmake项目。这就是你想要的吗?我试过了,但找不到用它构建底层C库的方法。据我所知,它只能构建Cython包cmakefile,而不能构建cmake文件链。如果我错了,你能给我举个例子吗?此外,找不到如何将其用于Poetry当你将C库的CMakeLists指令直接添加到用于构建Cython代码的CMakeLists.txt中时会发生什么?尝试手动包含此文本,或使用说明。