christian-blades-cb / simple-oxidized-python

Example Python module from Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple Oxidized Python

This is an example of a Rust-powered python module using milksnake. It's very contrived.

How to use this repo

This is a reference (and scaffold for you copy-paste afficiandos).

Project layout:

  • /simple-rs - The rust code you want to turn into a module
  • /cabi - C dynamic library from Rust
  • /cabi/build.rs - cbindgen generates a header file (simple.h) which we'll use for our python wheel.
  • /py - our python library
  • /py/setup.py - this is where milksnake does its magic
  • /py/simple/__init__.py - the pythonic interface

Pre-reqs

Building the module

cd py; python setup.py bdist_wheel

simple-0.1.0-py2.py3-none-linux_x86_64.whl now lives in py/dist

Useful reading

About

Example Python module from Rust


Languages

Language:Rust 47.9%Language:Python 44.8%Language:C 7.3%