Skip to content

cornusandu/autoCppToPy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

autoCppToPy

Q&A

Q: What is autoCppToPy?
A: autoCppToPy is an easy and fast way to compile C++ code into a Python module

Q: How does autoCppToPy work under the hood? A: autoCppToPy uses pybind11 to compile your C++ code into a python module

Q: How can I use CppToPy A: autoCppToPy can either be imported into your python code, allowing you to compile any C++ file yourself using autoCppToPy, or it can be used directly in the command line

CLI Documentation

Usage

(* = required)

python -m cpptopy -f <source file*> --header <header file*> -o <package name*> -l <language name = "C++"> --auto-stubs <generate auto .pyi files = False>

Example

main.hpp:

int add(int a, int b);

main.cpp:

#include "main.hpp"
int add(int a, int b) {
    return a + b
}

cli:

python -m cpptopy -f "main.cpp" --header "main.hpp" -o "my_module" --auto-stubs True

main.py

import my_module
my_module.add(2, 3)  # 5

About

Easily compile c++ code into a python module while using pybind under the hood

Topics

Resources

Stars

Watchers

Forks

Languages