Skip to content

uts-magic-lab/pyconnect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyConnect

A lightweight framework to integrate C++ programs with Python

Introduction

PyConnect is a very simple and lightweight development framework to integrate existing C/C++ programs with Python. By re-declaring the existing functions/methods and variables using PYCONNCECT macros, you can expose your program's functionality to a local or remotely running Python interpreter as a normal extension module.

PyConnect is composed of two major components:

  1. A wrapper library to be integrated (and compile) with your existing C++ code. It provides PYCONNECT macros to expose your program's variables and methods.

  2. A PyConnect extension module that act as a conduit between Python intepretor and the PyConnect wrapped program. You need to import PyConnect in Python intepretor.

PyConnect Architecture

Key features of PyConnect

  1. Minimum modifications is required to transform a generic C++ program into a Python scriptable program. Normally, you only need to add about few lines of code into your existing C++ source code. See sample code in testing subdirectory.

  2. No impact on the program's existing behaviour. Your program should still operate as usual. Your existing ways of controlling the program should remain intact.

  3. An uniform Pythonic interface. If you have wrapped multiple programs with PyConnect. All your programs will be listed under PyConnect module in the Python interpreter. You can use same programming scheme to write scripts for your programs.

  4. Dynamic binding. Your program still runs as an standalone process. Any program failure/crash will be handled gracefully without crashing the Python engine. A Python callback function is invoked when your program gets an exception and/or goes offline.

  5. Autodiscovery. PyConnect employs a very simple auto-discovery scheme. Currently, with a PyConnect enabled local network setup, the Python extension module and PyConnect wrapped programs will establish their communication automagically. See section PyConnect enabled network setup.

Supported compilers and environments

All major C++ compilers that support C++14 standard. That is,

  • GCC 4.9 or newer
  • Clang 3.4 or newer
  • Visual Studio 2015 C/C++ compiler.

PyConnect works under Linux, OS X (powerpc and intel), Solaris and Windows.

Limitations of PyConnect

  1. Only basic C/C++ data types are supported. That is, void, bool, int, float, do