franktakes / teexgraph

C++ library for large-scale network analysis and computation
GNU General Public License v3.0
24 stars 8 forks source link

Python bindings and cmake #4

Closed r-barnes closed 3 years ago

r-barnes commented 3 years ago

This PR uses PyBind11 to create libraries that work directly with Python, vastly simplifying the interface.

To simplify compilation of the libraries, I've switched the build system to cmake.

Scope is also made an enum class for improved safety.

The README file is modified to explain how to perform the build.

The Python bindings themselves live in python_wrapper.cpp and should be fairly straight-forward: you just need to list the methods of the class and, optionally, the names of the arguments to each function - everything else is handled automagically.

examples/python_example.py shows how to use the Python library (use build/ as the working directory).

It's also straight-forward to integrate this with numpy to avoid memory duplication when shuffling data between teexGraph and Python.

r-barnes commented 3 years ago

Updated to include most of the remaining Graph methods.

franktakes commented 3 years ago

I will make a few smaller changes after accepting this one into the master branch.

The excessive Scope:: thing is the only thing that bugs me a tiny bit, readability-wise, but that does not hinder me from really appreciating all your efforts into making this python wrapper.

r-barnes commented 3 years ago

@franktakes: The argument for enum class is that a standard enum has the same type as an integer, which drops a lot of potential safety.