Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!python
#cython: language_level=3, boundscheck=False
# distutils: language = c++
from setuptools import setup
from setuptools.extension import Extension
from Cython.Distutils import build_ext
import os
import numpy
from Cython.Build import cythonize
extensions = cythonize([
Extension(name="calibmertis", # output py-mportable compiled module name: must match source code file name!!
sources=[ "calibmertis.pyx"],
libraries=["MertisCalibFull"], # refers to "libMertisCalibFull.{so,a}"
library_dirs=[os.getcwd()+'/LibCalibMertis'], # path to .a or .so file(s)
include_dirs=[os.getcwd()+'/LibCalibMertis', numpy.get_include()], # path to .h file(s)
extra_compile_args=[
"-install_name @rpath/LibCalibMertis/libMertisCalibFull.so",
"-Wl,-rpath,@rpath/LibCalibMertis",
'-Wno-#warnings', # disable warning, Cython uses deprecated Numpy C API
'-w',
'-fmax-errors=5',
# '-std=c++11',
# '-std=gnu++11',
# '-Wl,-no_compact_unwind', # only using .a on mac
'-malign-double',
'-fPIC',
'-lpthread',
'-lm',
'-DLIB_MER_CAL_SCRIPTING_SUPPORT=1',
],
language="c++")
])
# https://stackoverflow.com/a/48635876/1435167
# differences between C and C++ is the name mangling, C++ mangles it.
# make clear to compiler that C++-convention is used by adding language="c++" to the setup
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = extensions
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment