Skip to content

CodeColdCook/python_C_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

用 C 或 C++ 扩展 Python

相关链接

python接口调用与说明——官方文档

FindPython3的cmake官方文档

python2 教程——Python与C/C++混合编程

python3 教程——C++调用Python3接口

python2的基础调用教程

直接调用python测试

  • 调用python的print

  • 测试内容test_1

调用python.py测试

  • 构建python的function,通过C进行调用。注意执行时的python环境变量

  • 测试内容test_2

使用Cython调用python

  • 通过cython对pyx文件进行编译,生成.h和.c文件,以供程序调用
  • 安装cython sudo apt-get install cython
  • 测试内容test_3

python3的基础调用教程

构建cmake工程

  • 通过cmake对python调用程序进行调用,关键为find_package
  • 指定python3编译环境
    • 若系统中存在多个版本python3,需要在cmake编译时注意当前find_package找到的版本,可能会出现Development.Module``Development.Embed无法找到的错误
    • 原因参考FindPython3的cmake官方文档,需要cmake 3.18版本
  • 编译方式cd build,cmake ..,make

基本测试内容

Class调用

  • test_class
  • 分别测试带参和不带参的类调用

jtop测试

  • 通过以上教程进行jtop功能调用

  • test_6

TODO

  • python类的调用
  • 其他常用功能测试

About

测试C/C++对python的调用

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published