Giter Club home page Giter Club logo

boost-python-examples's Introduction

boost::python examples

These are a few examples on how to use the boost::python library to extend Python with C++ libraries. Some of the are based on the existing tutorial for boost::python from Joel de Guzman. Others are independent.

Prerequisites

general

  • CMake (>= 2.8.3)
  • Boost (tested with 1.4.2, but should work with >= 1.3.2)
  • Python (tested with 2.7, but should work with >= 2.2)
  • a C++ compiler for your platform, e.g. GCC or MinGW

The examples should work on Linux, Windows and Mac, but currently have not been tested under Windows.

Mac OS X with homebrew

There is a special package needed called boost-python. The standard boost package will not be recognized by cmake.

  • brew install cmake boost-python

Furthermore, for the homebrew python lib to be used, unfortunately the full path has to be given:

cmake -DPYTHON_LIBRARY=/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib ..

Building

  • Set the BOOST_ROOT environment variable if Boost is installed in a non-standard directory
  • create a build directory, e.g. directly in the project directory and cd to it: mkdir build ; cd build
  • run cmake .. and afterwards make

Alternatively, run the provided build.sh script.

Tests

All examples contain tests, but these only try to run the examples without checking the output. Their purpose is mainly to make sure that compilation works and produces valid Python modules.

Python 3

The code works with PYthon3 both on Linux and on OS X. However, there is an astonshing number of loops to hop through.

Linux

  • Build Boost::Python against Python 3 (needs at least version 1.56.0)
  • make sure python resolves to python3 (e.g., by using a python3 VE)
  • run cmake -DBOOST_ROOT=xxx ..

OS X (again with homebrew)

  • Build Boost::Python against Python 3 (needs at least version 1.56.0)
  • make sure python resolves to python3 (e.g., by using a python3 VE)
  • run cmake -DBOOST_ROOT=xxx -DPYTHON_LIBRARY=xxx -DPYTHON_INCLUDE_DIR=xxx ..
  • set DYLD_LIBRARY_PATH to the directory where the boost::python shared library resides before make test

boost-python-examples's People

Contributors

achimh3011 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.