Skip to content

sandeep-gh/pyboost_ipc

This branch is up to date with ESSS/pyboost_ipc:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8e26106 · Dec 20, 2016

History

69 Commits
Nov 24, 2015
Nov 25, 2015
Aug 5, 2015
Dec 20, 2016
Jul 20, 2015
Nov 25, 2015
Dec 20, 2016
Jul 20, 2015
Aug 4, 2015
Aug 19, 2015

Repository files navigation

Python bindings for the C++ library Boost.Interprocess.

Boost.Python is the library used to create the bindings.

Goal

To provide an almost 1-1 of the Boost.Interprocess library. It is not meant to expand on the features of Boost.Interprocess.

The ideal usage scenario is when you have a C++ code and you want to expose its data through IPC (using Boost.Interprocess) and receive that data in python.

Requirements

Required:

  • Python 2.x (not yet tested on Python 3)
  • Boost (tested only on version 1.55+)

Optional:

  • numpy (to run the tests)

Building

Out-of-source builds will be assumed, if you don't know what that is, read about it here: http://www.cmake.org/Wiki/CMake_FAQ#Out-of-source_build_trees

cmake ..
cmake --build .

Installation

The cmake scripts will use what the cmake find_package(PythonLibs) returns. In case this can't be found, it will attempt to use the current python (by calling python in the command-line) in order to find where the site-packages directory is.

  • On Linux: make install
  • On Windows using Visual Studio: build the INSTALL project inside Visual Studio.

Running tests

Tests are written using pytest.

To run the tests, the option COMPILE_TESTS must be passed to CMake so that the pyboost_ipc_tests is compiled too.

CTest can then be used to run them.

ctest .

or:

ctest -C Debug --output-on-failure (for better error messages if the tests fail)

If using Windows, don't forget that the PATH variable must be set to a directory containing the Boost.Python dll.

Using the library

Bindings for common types are provided. This can be a rather limited scenario though, since Boost.Interprocess is a C++ library it relies heavily on the types being "communicated".

To benefit from these types an api was defined. It can be seen at the file <pyboost_ipc/api.hpp>.

The main method is:

template <typename Type>
void register_ipc_type();

By calling this method on your own bindings you will be able to use the managed_shared_memory.find() passing the type of the registered type.

In order to make it work you also have to link with the pyboost_ipc library.

Compilation troubleshooting

Boost not found

Pass the BOOST_ROOT variable to CMake:

cmake .. -DBOOST_ROOT=/path/to/boost

Python libs nor interpreter not found

You must pass these variables to cmake:

PYTHON_LIBRARY             - path to the python library
PYTHON_INCLUDE_DIR         - path to where Python.h is found

Like this:

cmake .. -DPYTHON_LIBRARY=/path/to/python.lib -DPYTHON_INCLUDE_DIR=/path/to/python.h

Visual studio 2013 compilation error on Boost 1.55

If you see this error:

left of '.select_on_container_copy_construction' must have class/struct/union

This means that the Boost.Container library has problems with this version of boost. See this boost ticket.

You can either:

  • Upgrade boost
  • Apply the patch proposed in the ticket

About

Python bindings for Boost.Interprocess

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 66.2%
  • Python 24.4%
  • CMake 6.6%
  • Batchfile 2.1%
  • Shell 0.7%