forked from jaduzzy/DecisionTree_C_plus_plus_Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
32 lines (26 loc) · 908 Bytes
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from setuptools import setup, Extension
# https://stackoverflow.com/questions/4529555/building-a-ctypes-based-c-library-with-distutils
from distutils.command.build_ext import build_ext as build_ext_orig
class build_ext(build_ext_orig):
def build_extension(self, ext):
self._ctypes = isinstance(ext, Extension)
return super().build_extension(ext)
def get_export_symbols(self, ext):
if self._ctypes:
return ext.export_symbols
return super().get_export_symbols(ext)
def get_ext_filename(self, ext_name):
if self._ctypes:
return ext_name + '.pyd'
return super().get_ext_filename(ext_name)
setup(
py_modules = ["decision_tree"],
ext_modules=[
Extension(
"decision_tree",
["decision_tree.cpp",
"utilities.cpp"],
),
],
cmdclass={'build_ext': build_ext},
)