Skip to content

Instantly share code, notes, and snippets.

@tfmoraes
Created August 26, 2019 19:15
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 tfmoraes/1520539030253d9878e6f39e835b2fa0 to your computer and use it in GitHub Desktop.
Save tfmoraes/1520539030253d9878e6f39e835b2fa0 to your computer and use it in GitHub Desktop.
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