Skip to content

k-dominik/python_cpp_example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python_cpp_example

WARNING: I have significantly reorganized this repository, and a new blog post explaining the changes is forthcoming. If you'd like to see the version of the repository that corresponds to my original June 2017 blog post, go to this release.

This repository contains an example Python module which wraps C++ code. The code presented here was designed to meet four requirements:

  1. Python bindings for C++ code (using pybind11 and built with CMake)
  2. Unit tests for C++ code (using catch)
  3. Unit tests for Python code (using unittest)
  4. A setuptools setup.py script for building, installation, and testing

Please see the blog post that accompanies this repository for more information.

Installation

To build and install python_cpp_example, clone or download this repository and then, from within the repository, run:

python3 ./setup.py install

or

pip3 install .

Tests

To execute all unit tests, run the following command:

python3 ./setup.py test

Requirements

  • Python 2 or 3
  • CMake 2.8.12 or higher
  • A modern compiler with C++11 support

Acknowledgements

Much of the code in this repository was adapted from the pybind11 tutorial and the pybind11 example CMake repository.

About

An example of a hybrid python/C++ package with unit tests

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 72.5%
  • C++ 18.4%
  • CMake 9.1%