Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Initiated pybind11 Configuration #123

Merged
merged 1 commit into from
Jul 29, 2021

Conversation

EmperorYP7
Copy link
Member

@EmperorYP7 EmperorYP7 commented Jul 20, 2021

Fixes #84 partially

Signed-off-by: Yash Pandey (YP) yash.btech.cs19@iiitranchi.ac.in


Description

This code initiated the configuration of pybind11 into the project through CMake.

  • I configured it so that it finds if pybind11 is installed locally. If it's not, the build system fetches version 2.7.0 from GitHub into the build/_deps directory and makes it available to our targets.
  • Added a target named pycasbin which compiles to a dynamic library i.e. a python module which can be imported in Python code.
  • Added an option CASBIN_BUILD_BINDINGS to specify whether to build language bindings, and CASBIN_BUILD_PYTHON_BINDINGS to toggle builds specific to python bindings.
  • When disabled, CASBIN_BUILD_BINDINGS and CASBIN_BUILD_PYTHON_BINDINGS won't fetch anything from GitHub adding modularity to our build system.
  • Added a mock binding for
    int sum(int a, int b);
    [](int i, int j){ return i - j; }
    referring to pybind11's docs.
  • Removed the makefile since it is now auto-generated through CMake.

Noteworthy

  • Although the build system works well and needs minimal configuration from the user's standpoint, I encountered many errors related to C++ standard used when trying to link pycasbin with the casbin target.

  • Vital template definitions like std::variant were undefined. This is becuase pycasbin is built with C++11 standard while casbin is compiled with C++17 standard.

  • I referred (no copy-pasting) to the build system config for pybind11 from AcademySoftwareFoundation/OpenColorIO for this as I think it was suitable for our use case.

Signed-off-by: Yash Pandey (YP) <yash.btech.cs19@iiitranchi.ac.in>
@hsluoyz hsluoyz requested a review from xcaptain July 20, 2021 13:33
@hsluoyz
Copy link
Member

hsluoyz commented Jul 20, 2021

@xcaptain @divy9881

@EmperorYP7
Copy link
Member Author

@xcaptain @divy9881 @hsluoyz
I think we should merge this to avoid merge conflicts in the subsequent PRs.

@hsluoyz hsluoyz merged commit 249d177 into casbin:master Jul 29, 2021
@github-actions
Copy link

🎉 This PR is included in version 1.28.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python bindings to facilitate PyCasbin-on-CPP
2 participants