Skip to content
DEPRECATED: Being replaced with milksnake:
Python Rust C Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
example Added gitignore for example Jul 10, 2017
rust Random fixes (#2) Jul 12, 2017
.gitignore Random fixes (#2) Jul 12, 2017
LICENSE Ready for initial release Jun 12, 2017 Ship empty.c file Jun 12, 2017
Makefile Dogfood the library internally Jun 12, 2017 Added deprecation notice Oct 3, 2017 0.2.0 Sep 29, 2017


This project is (temporarily) deprecated in favour of milksnake.

Milksnake lets you do the same thing as snaek but does it on a lower level so that (until we can generate significantly higher level bindings to Python) we put more controls in the hands of the developer.


Snaek is a Python library that helps you build Rust libraries and bridge them to Python with the help of cffi.


There are already other projects that make Python and Rust play along but this one is different. Unlike other projects that build Python extension modules the goal of this project is to build regular Rust libraries that are then loaded with CFFI at runtime. The advantage of this is that it does not link against libpython which means that you only need to build a handful of Python wheels to cover all platforms you care about.

In particular you will most likely only need two wheels for Linux, one for macs and soon one for Windows independently of how many Python interpreters you want to target.

What is supported?

  • Platforms: Linux, Mac (Windows later)
  • setuptools commands: bdist_wheel, build, build_ext, develop
  • pip install --editable .
  • Universal wheels (PACKAGE-py2.py3-none-PLATFORM.whl); this can be disabled with snaek_universal=False in setup() in case the package also contains stuff that does link against libpython.


This is what a file looks like:

from setuptools import setup

        ('example._native', 'rust/'),

You then need a rust/ folder that has a Rust library (with a crate type of cdylib) and a example/ python package.

Example example/ file:

from example._native import ffi, lib

def test():
    return lib.a_function_from_rust()

And a rust/src/

pub unsafe extern "C" fn a_function_from_rust() -> i32 {
You can’t perform that action at this time.