• Stars
    star
    825
  • Rank 53,201 (Top 2 %)
  • Language
    C++
  • License
    Boost Software Li...
  • Created about 13 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Some examples for the use of boost::python

boost::python examples

Build Status FOSSA Status

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.67, but should work with >= 1.3.2)
  • Python (tested with 2.7 and 3.6, 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 OSX, but currently have not been tested much 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, its path must be provided to cmake. This is handled in the build.sh script, but for reference, or if any issues arise, that can be done manually as follows (substitute the path as appropriate for your Python version):

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 Python 3 both on Linux and on OS X. However, there are several caveats.

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 ./build.sh

OS X (again with homebrew)

Some effort has been made to make Python 3 compilation automatic, by making modifications to build.sh and CMakeLists.txt that account for quirks on the Apple platform regarding cmake, paths, and naming conventions for python/python3. Having said that, if you use build.sh, then you will still need to do the following:

  • Build Boost::Python against Python 3 (needs at least version 1.56.0) or brew install boost-python3
  • make sure python resolves to python3 (e.g., by using virtualenv)
  • check that cmake uses matching python interpreter and libraries (down to the last digit). Otherwise you run into #17.

If you are building without build.sh, then you will additionally need to:

  • run cmake -DBOOST_LIBRARYDIR=xxx -DPYTHON_LIBRARY=xxx -DPYTHON_INCLUDE_DIR=xxx ..

Contributing

Contributions are very welcome. The following will provide some helpful guidelines.

How to contribute

If you want to submit a contribution, please follow the following workflow:

  • Fork the project
  • Create a feature branch
  • Add your contribution
  • When you're completely done, build the project and run all tests
  • Create a Pull Request

Commits

Commit messages should be clear and fully elaborate the context and the reason of a change. If your commit refers to an issue, please post-fix it with the issue number, e.g.

Issue: #123

Furthermore, commits should be signed (git commit -s) according to the DCO.

Pull Requests

If your Pull Request resolves an issue, please add a respective line to the end, like

Resolves #123

License

FOSSA Status

More Repositories

1

ArchUnit

A Java architecture test library, to specify and assert architecture rules in plain Java
Java
3,065
star
2

ArchUnitNET

A C# architecture test library to specify and assert architecture rules in C# for automated testing.
C#
792
star
3

ArchUnit-Examples

Examples for ArchUnit (A Java architecture test library, to specify and assert architecture rules in plain Java)
Java
535
star
4

JGiven

Behavior-Driven Development in plain Java
Java
431
star
5

junit-dataprovider

A TestNG like dataprovider runner for JUnit with many additional features
Java
242
star
6

virtual-office

Virtual Office gives you transparency on what Zoom.us rooms are currently occupied and who is present
TypeScript
122
star
7

keycloak-mock

A Java library to test REST endpoints secured by Keycloak via OpenID connect.
Java
111
star
8

ngqp

Declaratively synchronize form controls with the URL
TypeScript
80
star
9

next-generation-scrum-poker

Prototype for a new Scrum Poker
TypeScript
46
star
10

please-cli

An AI helper for creating CLI commands
Shell
45
star
11

cumulus

Cumulus. Threat modeling the Clouds.
TeX
28
star
12

ApiCenter

A repository for all your API specifications
TypeScript
25
star
13

momo-scheduler

A scheduler that persists jobs in MongoDB
TypeScript
19
star
14

gs-rs

Rust
15
star
15

svnfiltereddump

A tool to extract parts from Subversion repositories
Python
14
star
16

flink-connector-email

IMAP / SMTP connectors for Apache Flinkยฎ
Java
13
star
17

ngx-structurals

Structural utility directives for Angular
TypeScript
13
star
18

mustard-cli

A command line interface for bitbucket to review, comment and approve pull requests
C++
12
star
19

sinon-helpers

Create easily configurable sinon stubs that mimic constructors and keep track of their instances
JavaScript
12
star
20

jgiven-intellij-plugin

IntelliJ Plugin for JGiven
Kotlin
11
star
21

openpgp-validation-server

Automated Validation of OpenPGP Keys
Go
7
star
22

jiradeps

Graphically assess the dependencies of your Jira stories
Python
6
star
23

property-loader

Original PropertyLoader reworked
Java
6
star
24

value-provider

Java
5
star
25

please-pwsh

An AI helper for creating CLI commands in Powershell
PowerShell
5
star
26

rest-demo-jersey

Spring-boot and Jersey based REST service showing the integration of rest-schemagen.
Java
4
star
27

NextGenerationTranslatorBackend

A translation backend for AI translation models
Python
3
star
28

homebrew-please

A Homebrew tap for the Please CLI
Ruby
2
star
29

apt-please

2
star
30

karma-child-process

JavaScript
2
star
31

xtab-converter

Convert existing dbunit XLS files to XML data sets
Java
1
star
32

TNG

1
star
33

SnapToJsClipper

JavaScript
1
star