This project provides a python programming interface for SGTELIB using pybind11
, so that the C++
methods and classes defined in SGTELIB
are usable in python.
The project uses a CMakeLists.txt file to define the build project and compile the SGTELIB
library. You need to compile it successfully so that the python wrapper works
To complete this tutorial, you'll need:
- A compatible operating system (e.g. Linux, macOS, Windows).
- A compatible C++ compiler that supports at least C++14.
- CMake and a compatible build tool for building the
project.
- Compatible build tools include Make, Ninja, and others - see CMake Generators for more information.
- A Python distribution to run the scripts and compile the
pybind11
library.so
file which will be imported. Recommended distributions: - A PDM installation for python environment management
If you don't already have CMake installed, see the CMake installation guide.
Note: The terminal commands in this tutorial show a Unix shell prompt and this has not been tested on Windows.
First clone the repository:
git clone --recurse-submodules https://github.com/khbalhandawi/pysgtelib.git
cd pysgtelib
Now, in root
create a virtual environment
pdm install
Next, build the module using
mkdir build
cd build
cmake -S .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release
cmake --install . --config Release
This should create a pysgtelib.cpython-39-x86_64-linux-gnu.so
file in your build
directory. The file name will vary based on your python version and linux distribution.
Optional: Generate stub file .pyi
to help you with intellisense and be able to understand how to use pysgtelib
stubgen -m pysgtelib -o .
You may run your python scripts now. For example test.py