Skip to content

henriwoodcock/c-in-my-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c-in-my-python (cimp)

How to use your clibrary in Python with ctypes.

Getting Started

To get started with this project locally, yourself you first need a few prerequisites. This project was built for macOS and may need a few tweaks to get started on Windows or Linux.

Prerequisites

For this project you will need:

  • Cmake
  • C compiler
  • Python3

This instructions show how to do this on macOS, for Linux or Windows please check the specific installations.

  1. Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Install cmake, gcc and Python3
brew update
brew install cmake gcc pyenv
pyenv install 3.9.1
  1. Download this repository and set a local Python version
git clone https://github.com/henriwoodcock/c-in-my-python.git
cd c-in-my-python
pyenv local 3.9.1

Installation

To build the library we create a build directory, use cmake to build the makefiles and finally build the application.

mkdir build
cd build
cmake ..
make -j8
cd ../

Run the tests

Before running in Python, make sure the c application has build correctly:

./run_tests.sh

Run the Python script

The c library will now be used in Python:

python main.py

You should see "ALL TESTS PASSED".

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published