A Cursor-written project demonstrating how to call C libraries from Python. This project includes a simple C library that implements integer addition functionality and provides a Python interface.
- C library implementation of integer addition function
- Python wrapper interface
- Cross-platform support (Windows, Linux, macOS)
- Using xmake as C library build tool
- Python 3.6+
- xmake (for building C library)
- C compiler (GCC, MSVC, or Clang)
pip install pylibdemo- Clone the repository:
git clone https://github.com/funcman/pylibdemo.git
cd pylibdemo- Install the package:
pip install .If you only want to build the C library:
cd src/clib
xmakefrom pylibdemo import add_numbers, accumulate_n_times
# Using C library addition function
result = add_numbers(5, 3) # returns 8
# Using Python wrapper accumulation function
sum_result = accumulate_n_times(2, 3) # returns 6 (2+2+2)MIT License