setup.py for C++ Extension wrapping third party library

43 views
Skip to first unread message

Sandra Hicks

unread,
Nov 18, 2016, 1:28:20 PM11/18/16
to cython-users
Hello,
I am new to using Cython and find myself facing the following problem:
I am wrapping a C++ library (with complex dependencies) with Cython to make it accessible from sage. Now I need to write a proper setup.py script for building the extension. I do not want to build the library itself, as it is complicated. It is installed in usr/local. How does the proper setup.py look like? It does not find the header files that I include in the pxd files from the library with: cdef extern from "myLib/libHeader.h":

My trial:

from setuptools import setup, Extension
from Cython.Build import cythonize

ext = Extension(
    "IPO",                 # name of extension
    source = [<many pyx and pxd files>],
    include_dirs = ['/usr/local/include'],
    libraries = ['myLib'],
    library_dirs = ['/usr/local/lib'],
    language="c++"
    )

setup(name = 'myExtension', version = '0.1',
    ext_modules = cythonize([ext])

)

Sandra Hicks

unread,
Nov 22, 2016, 12:36:06 PM11/22/16
to cython-users
Solution found, it was my own fault that the files were not found. I previously worked with the non-installed library files which had slightly different names and I needed to rename them. Shame on me.
Reply all
Reply to author
Forward
0 new messages