-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
81 lines (69 loc) · 1.97 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
''' setup
'''
import re
import io
from distutils.command.build_ext import build_ext as build_ext_orig
from setuptools import setup, find_packages, Extension
# source: https://stackoverflow.com/a/39671214
__version__ = re.search(
r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
io.open('pyckmeans/__init__.py', encoding='utf_8_sig').read()
).group(1)
# ==== ctypes extensions
class CTypesExtension(Extension):
'''CTypesExtension'''
class build_ext(build_ext_orig):
'''build_ext'''
def build_extension(self, ext):
self._ctypes = isinstance(ext, CTypesExtension)
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)
distance_module = CTypesExtension(
'pyckmeans.distance.lib.distance',
sources=['pyckmeans/distance/src/distance.cpp'],
language='c++',
)
nucencode_module = CTypesExtension(
'pyckmeans.io.lib.nucencode',
sources=['pyckmeans/io/src/nucencode.cpp'],
language='c++',
)
ext_modules = [
distance_module,
nucencode_module,
]
install_requires = [
'numpy',
'pandas',
'scipy',
'scikit-learn',
'matplotlib',
'tqdm',
]
# ====
description = 'A consensus K-Means implementation.'
long_description = io.open('README.md').read()
long_description_content_type = 'text/markdown'
# ====
setup(
name='pyckmeans',
version=__version__,
packages=find_packages(),
description=description,
long_description=long_description,
long_description_content_type=long_description_content_type,
author='Tankred Ott',
platforms=['any'],
python_requires='>=3.6',
install_requires=install_requires,
cmdclass={'build_ext': build_ext},
ext_modules=ext_modules,
url='https://github.com/TankredO/pyckmeans',
)