Skip to content

Instantly share code, notes, and snippets.

@kidpixo
Created February 26, 2020 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kidpixo/4b736c13dd5a2d591a0044729180997f to your computer and use it in GitHub Desktop.
Save kidpixo/4b736c13dd5a2d591a0044729180997f to your computer and use it in GitHub Desktop.
#!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