https://github.com/grgomariani/python-boost-module-cpp
Should you need to compile Python modules written in C++ using Boost library
https://github.com/grgomariani/python-boost-module-cpp
boost cpp python python-boost python-modules
Last synced: 2 months ago
JSON representation
Should you need to compile Python modules written in C++ using Boost library
- Host: GitHub
- URL: https://github.com/grgomariani/python-boost-module-cpp
- Owner: GrgoMariani
- License: mit
- Created: 2018-06-19T10:11:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-19T12:45:00.000Z (over 7 years ago)
- Last Synced: 2025-04-24T03:47:45.395Z (8 months ago)
- Topics: boost, cpp, python, python-boost, python-modules
- Language: Makefile
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Python Boost module C++
### ___Short___
You want to write a module in C++ for use in Python and as easy as possible ?
### ___Prerequisites___
>```
>sudo apt-get install libboost-all-dev
>sudo apt-get install python-dev python3-dev
>```
### ___Prerequisites2___
>Check ___Makefile___ and make sure the _PYTHON_VERSION_ is the same as the one you'll be using, while you're there check the dirs as well.
>
>Also make sure your _TARGET_ (in Makefile) and _BOOST_PYTHON_MODULE_ name (in .cpp) are the same.
### ___Installation___
>```make``` builds .so file in build directory
>
>```sudo make install``` copies .so file to python libs directory
>
>```sudo make uninstall``` deletes .so file from python libs directory
### ___Python usage___
Once installed open python
##### Example 1
>```
>from custom_module import ADD
>a = ADD(2, 5)
>print( a.result() )
>a.x = 10
>print( a.result() )
>a.y = 12
>print( a.y )
>print( a.result() )
>```
##### Example 2
>```
>from custom_module import TLAA
>a = TLAA([12, 8, 17, 22])
>print( a.getAt(0))
>print( a.getAt(3))
>print( a.size() )
>print( a.sumAll() )
>```
### ___Links___
[Python Boost]( https://www.boost.org/doc/libs/1_63_0/libs/python/doc/html/tutorial/tutorial/exposing.html )
[Python Modules]( https://docs.python.org/3/tutorial/modules.html )
[Python Extending]( https://docs.python.org/2/extending/extending.html )