-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
51 lines (40 loc) · 1.13 KB
/
setup.py
File metadata and controls
51 lines (40 loc) · 1.13 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Magic from https://stackoverflow.com/a/34830639
from setuptools import find_packages
from distutils.core import setup, Extension
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, CTypes)
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 + '.so'
return super().get_ext_filename(ext_name)
class CTypes(Extension):
pass
files = [
'cpp/main.cpp', 'cpp/vector.cpp',
]
setup(
name='mc',
version='1.0',
py_modules=['mc.wrapper', 'mc.vector', 'mc.utils'],
ext_modules=[
CTypes(
'ct',
sources=files,
include_dirs=['cpp']
),
Extension(
'ext',
sources=files,
include_dirs=['cpp']
)
],
cmdclass={'build_ext': build_ext},
packages=find_packages()
)