We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
answer.c
int answer(void) { return 42; }
answer.h
int answer(void);
answer.pxd
cdef extern from "answer.h": int answer()
answer.pyx
cimport answer cpdef test(): return answer()
setup.py
import sys from distutils.core import setup from distutils.command.build_clib import build_clib from distutils.extension import Extension from Cython.Distutils import build_ext libanswer = ('answer', {'sources': ['answer.c']}) ext_modules=[ Extension("demo", ["answer.pyx"]) ] def main(): setup( name = 'answer', libraries = [libanswer], cmdclass = {'build_clib': build_clib, 'build_ext': build_ext}, ext_modules = ext_modules ) if __name__ == '__main__': main()
test.py
import answer def test_answer(): ret = demo.test() assert(ret == 42) if __name__ == '__main__': test_answer()
Build the C library:
$ python setup.py build_clib
Build the extension module in place
$ python setup.py build_ext --inplace
The text was updated successfully, but these errors were encountered:
veit
No branches or pull requests
answer.c
answer.h
answer.pxd
answer.pyx
cimport answer cpdef test(): return answer()
setup.py
test.py
Build the C library:
Build the extension module in place
The text was updated successfully, but these errors were encountered: