python绑定生成器

PyBindGen的Python项目详细描述


关于

Pybindgen是(惊喜!)python绑定生成器。主要功能有:

  • Generates clean C or C++ code, nearly as readable as code written manually by a developer;
  • Generated code is self contained and does not require any external libraries or macros; after generating the python module only python header files are required, nothing else;
  • Does not require Boost.Python (no C++ template magic, also works in C);
  • The interface for code generation is a simple Python API, not some obscure interface definition language. Additionally PyBindGen can parse header files with gccxml, if gccxml and pygccxml are installed in the system (note: pygccxml has not been ported to Python 3 yet);
  • Can be easily extended with new type handlers;
  • Type handlers can allocate memory and register cleanup code to free;
  • Supports in, out, and inout parameters (e.g. with pointers or C++ references);
  • Supports multiple return values (e.g. due to out/inout parameters);
  • Supports wrapping of simple C++ classes;
  • Supports virtual methods in classes;
  • Supports reference counted classes and, to some extent, smart pointers;
  • Multiple inheritance;
  • Wrapping templated classes;

未实现的显著功能:

  • Converting exceptions from Python to C++ (only from C++ to Python is currently supported);
  • Callbacks.

支持的Python版本

请参阅documentation

安装

注意:如果从Bazaar签出Pybindgen,不要忘记查看 其他指令的文件黑客攻击。

在继续之前,请确保满足系统要求。PyBindGen需要:

  1. Python (http://www.python.org)
  2. Python development files (the python-dev package in Ubuntu/Debian, for example)
  3. A C/C++ Compilation tool-chain (apt-get install build-essential)
  4. (optional) GCCXML and PyGCCXML

您可以使用setup.py或waf安装pybindgen。注:至 能够运行所有涉及代码生成的测试,以及 随后的编译,您需要使用waf。

使用setup.py安装:

python setup.py install

使用waf

安装

pybindgen使用WAF作为主构建系统。 但是,waf不必预先安装,因为它是 与pybindgen一起在一个waf脚本中提供。

要安装pybindgen,请发出以下命令(win32用户应在命令中省略./prefix):

  1. /waf配置 -也可以添加选项–prefix/foo/bar。要选择非破坏性的python版本,请使用python环境变量,例如:

    PYTHON=/usr/bin/python2.4 ./waf configure
    
  2. /waf
    • 可能的选项:-jn用于并行构建,-p用于进度条
  3. /waf检查
    • 可选步骤,运行单元测试
  4. /waf–示例
    • 可选步骤,编译示例
  5. /waf安装
    • 可能需要sudo

Windows特定说明

waf并发错误

waf自动检测核心数并尝试激活 相应地有多个生成线程。但是,这种并发支持 在Windows上似乎有错误,因此应使用 -j1选项,如果您有多个CPU:

waf check -j1

编译器选择

注意,如果在win32上编译,waf将查找msvc (微软Visual C)默认情况下放弃寻找C/C++ 如果找不到编译器。如果您没有安装msvc,但是 如果有mingw或cygwin gcc,您必须告诉waf在 配置阶段:

waf configure –check-c-compiler=gcc –check-cxx-compiler=g++

安装

在win32上,waf install默认安装到临时文件夹。拥有 它为特定的python版本安装,使用–prefix选项 WAF配置。例如:

waf configure –prefix C:Python26 waf install

安装故障保护

如果你在华夫身上有任何问题 安装pybindGen,您应该知道pybindGen完全 自包含在pybindgen目录中。你可以简单地 递归地将整个pybindGen文件夹复制到python的 网站包目录,就这样!pybindgen是一种纯python 包并实际上不需要C/C++编译器;C++编译器只是 用于代码生成单元测试和编译示例模块,不需要生成代码。

文档

提供以下文档:

  1. API docs (with introductory tutorial)
  2. Many simple examples in the examples directory
  3. Advanced examples in the unit tests (tests/)
  4. The source code!
https://travis-ci.org/gjcarneiro/pybindgen.svg?branch=master

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何为ConcurrentHashMap使用并设置适当的并发级别?   java泛型方法,运行时错误,   java在页面上显示加载的图像   java Paypal定期直接支付问题   java如何延迟重新绘制组件   JavaSpringBoot+Hibernate如何维护@Transient字段   java在其方法中获取关于类的信息   在java中将别名添加到枚举   java如何解决向google报告成绩时“需要重新连接客户端”的问题   清晰的java图像背景   java未找到适合JDateChooser的构造函数(字符串、字符串、字符)   java LRU缓存实现。某些测试用例的代码失败   if语句Java嵌套的if/Else条件   java JSoup“wrap”并非每次都按预期工作   Java Spring引导循环依赖于一个环境   ssl证书无法通过Java和IntelliJ连接到SOAP服务   带整数验证的Java扫描器   java在Flex中呈现具有动态列的datagrid   java Android:通过用户选择的选项将文件上载到服务器   子类中的java抛出错误、异常和运行时异常