-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.py
217 lines (190 loc) · 7.64 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/usr/bin/env python3
import sys, os, platform
import setuptools
from distutils.core import setup, Extension
from setuptools.command.develop import develop
###########################################################
# Variables
##########################################################
OS_NAME = 'linux'
if sys.platform == "win32":
OS_NAME = 'win64' if sys.maxsize > 2**32 else 'win32'
elif sys.platform == "darwin":
OS_NAME = 'osx'
os.environ["ARCHFLAGS"] = "-arch x86_64"
if platform.machine() == 'arm64':
os.environ["ARCHFLAGS"] = "-arch arm64"
os.environ['MACOSX_DEPLOYMENT_TARGET'] = platform.mac_ver()[0]
elif sys.platform == "linux2":
OS_NAME = 'linux'
LIBGEODA_SRC = 'libgeoda'
###########################################################
# INCLUDE_DIRS
###########################################################
INCLUDE_DIRS = []
if OS_NAME == 'win32' or OS_NAME == 'win64':
INCLUDE_DIRS = [
'.\\boost\\include',
'.\\' + LIBGEODA_SRC,
]
else:
INCLUDE_DIRS = [
'./boost/include',
'./' + LIBGEODA_SRC,
]
###########################################################
# LIBRARIES and INCLUDE_DIRS
###########################################################
LIBRARY_DIRS = []
LIBRARIES = [] # -lxxx
if OS_NAME == 'win32' or OS_NAME == 'win64':
LIBRARIES = [
#'comctl32','rpcrt4'
]
if OS_NAME == 'linux':
LIBRARY_DIRS += ['/usr/lib', '/usr/lib/x86_64-linux-gnu']
LIBRARIES = []
elif OS_NAME == 'osx':
LIBRARY_DIRS += ['/usr/lib']
LIBRARIES = []
###########################################################
# SWIG_OPTS and Compiler args
###########################################################
SWIG_OPTS = ['-c++']
EXTRA_COMPILE_ARGS = []
if OS_NAME == 'win32' or OS_NAME == 'win64':
EXTRA_COMPILE_ARGS += [
'/EHsc', #MSVC is not throwing exceptions, boost::throw_exception error
'/MD', # only for python 27 amd64
'/DNOMINMAX', # for win Macro define for min/max that impacts std::numeric_limits<int>::max()
]
else:
EXTRA_COMPILE_ARGS = [
'-w',
'-std=c++14',
'-fvisibility=hidden',
'-D__USE_PTHREAD__', # use pthread!!! on *nix
'-Wno-enum-constexpr-conversion' # disable enumeration warnings
]
###########################################################
# Link args
###########################################################
EXTRA_LINK_ARGS = []
if OS_NAME == 'win32' or OS_NAME == 'win64':
EXTRA_LINK_ARGS += [
'/ignore:4229',
#'/NODEFAULTLIB:msvcrt.lib'
]
else:
EXTRA_LINK_ARGS = [
'-pthread' # in *nix, using pthread instead of boost::thread
]
###########################################################
# Link objects
###########################################################
EXTRA_OBJECTS = []
if OS_NAME == 'win32' or OS_NAME == 'win64':
BOOST_ARC = 'x32' if OS_NAME == 'win32' else 'x64'
pyversion = sys.version[:3]
MSVC_VER = ''
BOOST_VER = '1_75'
MSVC_VER = 'vc142'
if pyversion in ['3.12']:
MSVC_VER = 'vc142'
EXTRA_OBJECTS = [
'.\\boost\\lib\\' + OS_NAME + '\\libboost_thread-' + MSVC_VER+ '-mt-' + BOOST_ARC + '-' + BOOST_VER + '.lib',
'.\\boost\\lib\\' + OS_NAME + '\\libboost_system-' + MSVC_VER+ '-mt-' + BOOST_ARC + '-' + BOOST_VER + '.lib',
'.\\boost\\lib\\' + OS_NAME + '\\libboost_date_time-' + MSVC_VER+ '-mt-' + BOOST_ARC + '-' + BOOST_VER + '.lib',
'.\\boost\\lib\\' + OS_NAME + '\\libboost_chrono-' + MSVC_VER+ '-mt-' + BOOST_ARC + '-' + BOOST_VER + '.lib',
]
else:
EXTRA_OBJECTS = [
]
###########################################################
# Source files
###########################################################
SOURCE_FILES = [
'pygeoda/libgeoda.cpp',
'./' + LIBGEODA_SRC + '/libgeoda.cpp',
'./' + LIBGEODA_SRC + '/gda_sa.cpp',
'./' + LIBGEODA_SRC + '/gda_data.cpp',
'./' + LIBGEODA_SRC + '/gda_weights.cpp',
'./' + LIBGEODA_SRC + '/gda_clustering.cpp',
'./' + LIBGEODA_SRC + '/GenGeomAlgs.cpp',
'./' + LIBGEODA_SRC + '/GenUtils.cpp',
'./' + LIBGEODA_SRC + '/SpatialIndAlgs.cpp',
'./' + LIBGEODA_SRC + '/pg/geoms.cpp',
'./' + LIBGEODA_SRC + '/pg/utils.cpp',
'./' + LIBGEODA_SRC + '/shapelib/shpopen.cpp',
'./' + LIBGEODA_SRC + '/shapelib/dbfopen.cpp',
'./' + LIBGEODA_SRC + '/shapelib/safileio.cpp',
'./' + LIBGEODA_SRC + '/weights/PointsToContigWeights.cpp',
'./' + LIBGEODA_SRC + '/weights/PolysToContigWeights.cpp',
'./' + LIBGEODA_SRC + '/weights/GalWeight.cpp',
'./' + LIBGEODA_SRC + '/weights/GwtWeight.cpp',
'./' + LIBGEODA_SRC + '/weights/GeodaWeight.cpp',
'./' + LIBGEODA_SRC + '/weights/VoronoiUtils.cpp',
'./' + LIBGEODA_SRC + '/sa/BatchLISA.cpp',
'./' + LIBGEODA_SRC + '/sa/BatchLocalMoran.cpp',
'./' + LIBGEODA_SRC + '/sa/LISA.cpp',
'./' + LIBGEODA_SRC + '/sa/MultiGeary.cpp',
'./' + LIBGEODA_SRC + '/sa/MultiJoinCount.cpp',
'./' + LIBGEODA_SRC + '/sa/UniG.cpp',
'./' + LIBGEODA_SRC + '/sa/UniGeary.cpp',
'./' + LIBGEODA_SRC + '/sa/UniGstar.cpp',
'./' + LIBGEODA_SRC + '/sa/UniJoinCount.cpp',
'./' + LIBGEODA_SRC + '/sa/UniLocalMoran.cpp',
'./' + LIBGEODA_SRC + '/sa/BiLocalMoran.cpp',
'./' + LIBGEODA_SRC + '/clustering/fastcluster.cpp',
'./' + LIBGEODA_SRC + '/clustering/redcap.cpp',
'./' + LIBGEODA_SRC + '/clustering/redcap_wrapper.cpp',
'./' + LIBGEODA_SRC + '/clustering/azp.cpp',
'./' + LIBGEODA_SRC + '/clustering/maxp_wrapper.cpp',
'./' + LIBGEODA_SRC + '/clustering/azp_wrapper.cpp',
'./' + LIBGEODA_SRC + '/clustering/schc_wrapper.cpp',
'./' + LIBGEODA_SRC + '/clustering/cluster.cpp',
'./' + LIBGEODA_SRC + '/clustering/joincount_ratio.cpp',
'./' + LIBGEODA_SRC + '/clustering/spatial_validation.cpp',
'./' + LIBGEODA_SRC + '/clustering/make_spatial.cpp',
'./' + LIBGEODA_SRC + '/knn/ANN.cpp',
'./' + LIBGEODA_SRC + '/knn/perf.cpp',
'./' + LIBGEODA_SRC + '/knn/kd_util.cpp',
'./' + LIBGEODA_SRC + '/knn/kd_tree.cpp',
'./' + LIBGEODA_SRC + '/knn/kd_split.cpp',
'./' + LIBGEODA_SRC + '/knn/kd_search.cpp',
'./' + LIBGEODA_SRC + '/knn/kd_pr_search.cpp',
'./' + LIBGEODA_SRC + '/knn/kd_fix_rad_search.cpp',
'./' + LIBGEODA_SRC + '/knn/kd_dump.cpp',
'./' + LIBGEODA_SRC + '/knn/brute.cpp',
'./' + LIBGEODA_SRC + '/knn/bd_tree.cpp',
'./' + LIBGEODA_SRC + '/knn/bd_search.cpp',
'./' + LIBGEODA_SRC + '/knn/bd_pr_search.cpp',
'./' + LIBGEODA_SRC + '/knn/bd_fix_rad_search.cpp',
]
###########################################################
# Extensions
###########################################################
extensions = []
package_data = {}
include_package_data = False
extensions = [Extension('pygeoda._libgeoda',
sources=SOURCE_FILES,
include_dirs=INCLUDE_DIRS,
swig_opts=SWIG_OPTS,
extra_compile_args=EXTRA_COMPILE_ARGS,
extra_link_args=EXTRA_LINK_ARGS,
library_dirs=LIBRARY_DIRS,
runtime_library_dirs=LIBRARY_DIRS,
libraries=LIBRARIES,
extra_objects=EXTRA_OBJECTS),]
setup (name = 'pygeoda',
version = '0.1.2',
author = "Xun Li",
author_email = "[email protected]",
url = "https://github.com/geodacenter/pygeoda",
description = """pygeoda is a python library for spatial data analysis based on GeoDa and libgeoda.""",
ext_modules = extensions,
package_data = package_data,
include_package_data = include_package_data,
packages=['pygeoda','pygeoda.weights','pygeoda.sa','pygeoda.clustering', 'pygeoda.classify', 'pygeoda.data']
)