-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsetup.py
121 lines (106 loc) · 3.25 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
from setuptools import setup, Extension
from codecs import open
import sys
import os
# is_windows = sys.platform.startswith('win')
def is_platform_mac():
return sys.platform == 'darwin'
def is_platform_windows():
return sys.platform == 'win32' or sys.platform == 'cygwin'
try:
from Cython.Distutils import build_ext
except ImportError:
use_cython = False
else:
use_cython = True
if use_cython:
sourcefiles = ['pycspade/cspade.pyx']
else:
sourcefiles = ['pycspade/cspade.cpp']
extra_files = ['csrc/{}'.format(x) for x in [
'makebin.cc',
'getconf.cc',
'exttpose.cc',
'wrappers.cc',
'calcdb.cc',
'TransArray.cc',
'Array.cc',
'Itemset.cc',
'Lists.cc',
'Eqclass.cc',
'InvertDatabase.cc',
'Partition.cc',
'Sequence.cc',
'common.cc',
'argv_parser.cc',
'SpadeArguments.cc',
'FreqIt.cc',
'EqGrNode.cc',
'ClassInfo.cc'
]]
# Fix compatibility when compiling on Mac Mojave.
# Explanation: https://github.com/pandas-dev/pandas/issues/23424#issuecomment-446393981
# Code credit: https://github.com/pandas-dev/pandas/pull/24274/commits/256faf2011a12424e684a42c147e1ba7ac32c6fb
if is_platform_mac():
import _osx_support
import distutils.sysconfig
if not 'MACOSX_DEPLOYMENT_TARGET' in os.environ:
current_system = list(map(int, _osx_support._get_system_version().split('.')))
python_osx_target_str = distutils.sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
python_osx_target = list(map(int, python_osx_target_str.split('.')))
if python_osx_target < [10, 9] and current_system >= [10, 9]:
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
os.environ['CC'] = 'clang'
os.environ['CXX'] = 'clang'
if is_platform_windows():
extra_compiler_args = []
else:
extra_compiler_args = [
'-std=c++11',
'-Wno-sign-compare',
'-Wno-incompatible-pointer-types',
'-Wno-unused-variable',
'-Wno-absolute-value',
'-Wno-visibility',
'-Wno-#warnings',
]
if is_platform_mac():
ext_modules = [
Extension('pycspade.cspade',
sourcefiles + extra_files,
include_dirs=['csrc/'],
language='c++',
extra_compile_args=extra_compiler_args,
extra_link_args=["-O2", "-march=native", '-stdlib=libc++'],
),
]
else:
ext_modules = [
Extension('pycspade.cspade',
sourcefiles + extra_files,
include_dirs=['csrc/'],
language='c++',
extra_compile_args=extra_compiler_args,
),
]
with open('README.md', 'r') as fh:
long_description = fh.read()
setup_args = dict(
name='pycspade',
ext_modules=ext_modules,
license='MIT',
packages=['pycspade'],
version='0.6.6',
author=['Mohammed J. Zaki', 'Yukio Fukuzawa'],
description='C-SPADE Python Implementation',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/fzyukio/python-cspade',
keywords=['cspade', 'c-spade', 'sequence mining'],
install_requires=['Cython'],
)
if use_cython:
setup_args['cmdclass'] = {'build_ext': build_ext}
setup(
**setup_args
)