Skip to content

Instantly share code, notes, and snippets.

@euphoria
Created March 10, 2016 23:13
Show Gist options
  • Save euphoria/d3ed67b057ad09386105 to your computer and use it in GitHub Desktop.
Save euphoria/d3ed67b057ad09386105 to your computer and use it in GitHub Desktop.
# Imagine this is first/first_build.py
from cffi import FFI
ffi = FFI()
with open("/usr/local/include/tfc.h") as f:
ffi.cdef(f.read())
ffi.set_source("first._first",
"""
#include "tfc.h"
#include "first.h"
"""
include_dirs=["/usr/local/include", "projects/first/include"],
library_dirs=["/usr/local/lib", "projects/first/lib"],
libraries=["c", "tfc", "first"]
)
if __name__ == "__main__":
ffi.compile()
# Imagine this is second/second_build.py
from cffi import FFI
ffi = FFI()
with open("/usr/local/include/tfc.h") as f:
ffi.cdef(f.read())
ffi.set_source("second._second",
"""
#include "tfc.h"
#include "second.h"
"""
include_dirs=["/usr/local/include", "projects/second/include"],
library_dirs=["/usr/local/lib", "projects/second/lib"],
libraries=["c", "tfc", "second"]
)
if __name__ == "__main__":
ffi.compile()
# Imagine this is first/setup.py
setup(
name="first",
cffi_modules=["first_build.py:ffi"]
)
# Imagine this is second/setup.py
setup(
name="second",
cffi_modules=["second_build.py:ffi"]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment