Python bindings for the C++ library Boost.Interprocess.
Boost.Python is the library used to create the bindings.
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.
Required:
- Python 2.x (not yet tested on Python 3)
- Boost (tested only on version 1.55+)
Optional:
- numpy (to run the tests)
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 .
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.
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.
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.
Pass the BOOST_ROOT
variable to CMake:
cmake .. -DBOOST_ROOT=/path/to/boost
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
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