def declare_cython_extension(extName, use_math=False, use_openmp=False, include_dirs=None):
"""Declare a Cython extension module for setuptools.
Parameters:
extName : str
Absolute module name, e.g. use `mylibrary.mypackage.mymodule`
for the Cython source file `mylibrary/mypackage/mymodule.pyx`.
use_math : bool
If True, set math flags and link with ``libm``.
use_openmp : bool
If True, compile and link with OpenMP.
Return value:
Extension object
that can be passed to ``setuptools.setup``.
"""
extPath = extName.replace(".", os.path.sep)+".pyx"
if use_math:
compile_args = list(my_extra_compile_args_math) # copy
link_args = list(my_extra_link_args_math)
libraries = ["m"] # link libm; this is a list of library names without the "lib" prefix
else:
compile_args = list(my_extra_compile_args_nonmath)
link_args = list(my_extra_link_args_nonmath)
libraries = None # value if no libraries, see setuptools.extension._Extension
# OpenMP
if use_openmp:
compile_args.insert( 0, openmp_compile_args )
link_args.insert( 0, openmp_link_args )
# See
# http://docs.cython.org/src/tutorial/external.html
#
# on linking libraries to your Cython extensions.
#
return Extension( extName,
[extPath],
extra_compile_args=compile_args,
extra_link_args=link_args,
include_dirs=include_dirs,
libraries=libraries
)
# Gather user-defined data files
#
# http://stackoverflow.com/questions/13628979/setuptools-how-to-make-package-contain-extra-data-folder-and-all-folders-inside
#
评论列表
文章目录