-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
executable file
·255 lines (240 loc) · 10 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/usr/bin/env python3
from os import environ
from sys import platform
from setuptools import setup, Extension
macros = [('NDEBUG', None)]
include_dirs = ['geometry', 'geometry/s2', 'geometry/util/math', 'include', 'include/mcpp']
MANY_LINUX = False
if platform == 'win32':
c_args = cpp_args = None
elif platform == 'darwin':
c_args = ['-O3']
if 'TRAVIS' not in environ:
c_args.append('-march=native')
cpp_args = c_args + ['-std=c++14', '-stdlib=libc++']
else:
try:
from os import name as os_name
if os_name == 'posix':
# workaround for extraneous warnings caused by this bug:
# https://bugs.python.org/issue1222585
from distutils import sysconfig
sysconfig._init_posix()
sysconfig._config_vars['CFLAGS'] = sysconfig._config_vars['CFLAGS'].replace('-Wstrict-prototypes', '')
sysconfig._config_vars['OPT'] = sysconfig._config_vars['OPT'].replace('-Wstrict-prototypes', '')
except Exception:
pass
c_args = ['-O3']
if 'MANYLINUX' in environ:
MANY_LINUX = True
c_args.extend(['-s', '-static-libgcc', '-static-libstdc++'])
elif 'TRAVIS' not in environ:
c_args.append('-march=native')
cpp_args = c_args + ['-std=c++14']
libs = [('gzip', {
'language': 'cpp',
'include_dirs': ['include', 'include/zlib'],
'cflags': cpp_args,
'sources': ['lib/gzip.cpp']}),
('json', {
'language': 'c++',
'include_dirs': ['include'],
'cflags': cpp_args,
'sources': ['lib/json11.cpp']}),
('s2', {
'language': 'c++',
'macros': macros,
'include_dirs': include_dirs,
'cflags': cpp_args,
'sources': [
'geometry/base/logging.cc',
'geometry/strings/split.cc',
'geometry/strings/stringprintf.cc',
'geometry/strings/strtoint.cc',
'geometry/strings/strutil.cc',
'geometry/util/coding/coder.cc',
'geometry/util/coding/varint.cc',
'geometry/util/math/mathlimits.cc',
'geometry/util/math/mathutil.cc',
'geometry/s1angle.cc',
'geometry/s2.cc',
'geometry/s2cellid.cc',
'geometry/s2latlng.cc',
'geometry/s1interval.cc',
'geometry/s2cap.cc',
'geometry/s2cell.cc',
'geometry/s2cellunion.cc',
'geometry/s2edgeindex.cc',
'geometry/s2edgeutil.cc',
'geometry/s2latlngrect.cc',
'geometry/s2loop.cc',
'geometry/s2pointregion.cc',
'geometry/s2polygon.cc',
'geometry/s2polygonbuilder.cc',
'geometry/s2polyline.cc',
'geometry/s2r2rect.cc',
'geometry/s2region.cc',
'geometry/s2regioncoverer.cc',
'geometry/s2regionintersection.cc',
'geometry/s2regionunion.cc']}),
('urlencode', {
'language': 'c++',
'cflags': cpp_args,
'sources': ['lib/urlencode.cpp']}),
('vectorutils', {
'language': 'cpp',
'include_dirs': ['include'],
'cflags': cpp_args,
'sources': ['lib/vectorutils.cpp']}),
('zlib', {
'language': 'c',
'include_dirs': ['include/zlib'],
'cflags': c_args if not MANY_LINUX else c_args + ['-static'],
'sources': [
'lib/zlib/adler32.c',
'lib/zlib/compress.c',
'lib/zlib/crc32.c',
'lib/zlib/deflate.c',
'lib/zlib/trees.c',
'lib/zlib/zutil.c']})]
try:
from Cython.Build import cythonize
from Cython import __version__ as cython_version
from distutils.version import LooseVersion
file_ext = 'pyx' if LooseVersion(cython_version) >= LooseVersion('0.26') else 'cpp'
except ImportError:
file_ext = 'cpp'
if file_ext == 'cpp':
from os.path import exists, join
if not exists(join('pogeo', 'utils.cpp')):
raise ImportError("You must have Cython to build from source."
"Install Cython or install pogeo from PyPi: `pip install pogeo`")
exts = [Extension('pogeo.altitude',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args,
include_dirs=include_dirs,
sources=['pogeo/altitude.' + file_ext],
language='c++'),
Extension('pogeo.cellcache',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args,
include_dirs=include_dirs,
sources=['pogeo/cellcache.' + file_ext],
language='c++'),
Extension('pogeo.geocoder',
include_dirs=include_dirs,
extra_compile_args=cpp_args,
extra_link_args=cpp_args,
sources=['pogeo/geocoder.' + file_ext],
language='c++'),
Extension('pogeo.location',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args,
include_dirs=include_dirs,
sources=['pogeo/location.' + file_ext],
language='c++'),
Extension('pogeo.loop',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args,
include_dirs=include_dirs,
sources=['pogeo/loop.' + file_ext],
language='c++'),
Extension('pogeo.polygon',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args,
include_dirs=include_dirs,
sources=['pogeo/polygon.' + file_ext],
language='c++'),
Extension('pogeo.polyline',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args,
include_dirs=include_dirs,
sources=['pogeo/polyline.' + file_ext],
language='c++'),
Extension('pogeo.polyline_encoder',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args,
include_dirs=include_dirs,
sources=['pogeo/polyline_encoder.' + file_ext],
language='c++'),
Extension('pogeo.rectangle',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args,
include_dirs=include_dirs,
sources=['pogeo/rectangle.' + file_ext],
language='c++'),
Extension('pogeo.utils',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args,
include_dirs=include_dirs,
sources=['pogeo/utils.' + file_ext],
language='c++'),
Extension('pogeo.monotools.aiolock',
extra_compile_args=cpp_args,
extra_link_args=cpp_args,
sources=['pogeo/monotools/aiolock.' + file_ext],
language='c++'),
Extension('pogeo.monotools.aiosightingcache',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args if not MANY_LINUX else cpp_args + ['-Wl,-Bstatic', '-lzlib'],
include_dirs=include_dirs,
sources=['pogeo/monotools/aiosightingcache.' + file_ext],
language='c++'),
Extension('pogeo.monotools.aiospawncache',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args if not MANY_LINUX else cpp_args + ['-Wl,-Bstatic', '-lzlib'],
include_dirs=include_dirs,
sources=['pogeo/monotools/aiospawncache.' + file_ext],
language='c++'),
Extension('pogeo.monotools.sightingcache',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args if not MANY_LINUX else cpp_args + ['-Wl,-Bstatic', '-lzlib'],
include_dirs=include_dirs,
sources=['pogeo/monotools/sightingcache.' + file_ext],
language='c++'),
Extension('pogeo.monotools.spawncache',
define_macros=macros,
extra_compile_args=cpp_args,
extra_link_args=cpp_args if not MANY_LINUX else cpp_args + ['-Wl,-Bstatic', '-lzlib'],
include_dirs=include_dirs,
sources=['pogeo/monotools/spawncache.' + file_ext],
language='c++')]
if file_ext == 'pyx':
exts = cythonize(exts)
setup(name='pogeo',
version='0.4.0rc1',
description='Fast geography package.',
long_description="A Cython extension for geographic computation using Google's S2 library.",
url="https://github.com/Noctem/pogeo",
author='David Christenson',
author_email='mail@noctem.xyz',
license='Apache',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'Programming Language :: C++',
'Programming Language :: Cython',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Scientific/Engineering :: GIS'],
keywords='pogeo geography S2 distance geo geometry',
libraries=libs,
packages=['pogeo', 'pogeo.geo', 'pogeo.monotools'],
package_data={'pogeo': '*.pxd',
'pogeo.geo': '*.pxd',
'pogeo.monotools': '*.pxd'},
ext_modules=exts)