|
1 | 1 | #python_cpp_example |
2 | 2 | This repository contains an example Python module which wraps C++ code. The code presented here was designed to meet four requirements: |
3 | 3 |
|
4 | | -1. Python bindings for C++ code (using pybind11). |
5 | | -2. Unit tests for C++ code (using Catch). |
6 | | -3. Unit tests for Python code (using unittest). |
7 | | -4. A setuptools setup.py script for building, installation, and testing. |
| 4 | +1. Python bindings for C++ code (using[`pybind11`](http://pybind11.readthedocs.io/en/stable/index.html) and built with[CMake](http://cmake.org)) |
| 5 | +2. Unit tests for C++ code (using[`catch`](http://catch-lib.net)) |
| 6 | +3. Unit tests for Python code (using`unittest`) |
| 7 | +4. A`setuptools` setup.py script for building, installation, and testing |
| 8 | + |
| 9 | +Please see the[blog post that accompanies this repository]() for more information. |
| 10 | + |
| 11 | +#Installation |
| 12 | + |
| 13 | +To build and install`python_cpp_example` clone or download this repository and then, from within the repository, run: |
| 14 | + |
| 15 | +```bash |
| 16 | +python3 ./setup.py install |
| 17 | +``` |
| 18 | + |
| 19 | +or |
| 20 | + |
| 21 | +```bash |
| 22 | +pip3 install. |
| 23 | +``` |
| 24 | + |
| 25 | +#Tests |
| 26 | + |
| 27 | +To execute all unit tests, run the following command: |
| 28 | + |
| 29 | +```bash |
| 30 | +python3 ./setup.pytest |
| 31 | +``` |
| 32 | + |
| 33 | +#Requirements |
| 34 | + |
| 35 | +- Python 2 or 3 |
| 36 | +- CMake 2.8.12 or higher |
| 37 | +- A modern compiler with C++11 support |
| 38 | + |
| 39 | +#Acknowledgements |
| 40 | + |
| 41 | +Much of the code in this repository was adapted from the[`pybind11` tutorial](http://pybind11.readthedocs.io/en/stable/basics.html) and the[`pybind11` example CMake repository](https://github.com/pybind/cmake_example). |