Skip to content

Instantly share code, notes, and snippets.

@tfmoraes
Created Aug 26, 2019
Embed
What would you like to do?
import os
import sys
from distutils.core import setup
from distutils.extension import Extension
import numpy
from Cython.Build import cythonize
from Cython.Distutils import build_ext
copt = {"msvc": ["/openmp"], "mingw32": ["-fopenmp"], "unix": ["-fopenmp"]}
lopt = {"mingw32": ["-fopenmp"], "unix": ["-fopenmp"]}
class build_ext_subclass(build_ext):
def build_extensions(self):
c = self.compiler.compiler_type
print("Compiler", c)
if c in copt:
for e in self.extensions:
e.extra_compile_args = copt[c]
if c in lopt:
for e in self.extensions:
e.extra_link_args = lopt[c]
self.include_dirs = [numpy.get_include()]
build_ext.build_extensions(self)
setup(
cmdclass={"build_ext": build_ext_subclass},
ext_modules=cythonize(
[
Extension(
"invesalius.data.mips",
["invesalius/data/mips.pyx"],
include_dirs=[numpy.get_include()],
),
Extension(
"invesalius.data.interpolation",
["invesalius/data/interpolation.pyx"],
include_dirs=[numpy.get_include()],
),
Extension(
"invesalius.data.transforms",
["invesalius/data/transforms.pyx"],
include_dirs=[numpy.get_include()],
),
Extension(
"invesalius.data.floodfill",
["invesalius/data/floodfill.pyx"],
include_dirs=[numpy.get_include()],
language="c++",
),
Extension(
"invesalius.data.cy_mesh",
["invesalius/data/cy_mesh.pyx"],
include_dirs=[numpy.get_include()],
language="c++",
),
]
),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment