-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
303 lines (258 loc) · 8.37 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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
"""
Lakesuperior setup script.
Proudly ripped from https://github.com/pypa/sampleproject/blob/master/setup.py
"""
import sys
# Always prefer setuptools over distutils
from setuptools import Extension, setup, find_packages
# To use a consistent encoding
from codecs import open
from glob import glob
from os import path
import lakesuperior
# Use this version to build C files from .pyx sources.
CYTHON_VERSION='0.29.22'
KLEN = 5 # TODO Move somewhere else (config?)
try:
import Cython
from Cython.Build import cythonize
except ImportError:
USE_CYTHON = False
else:
cy_installed_version = Cython.__version__
if cy_installed_version == CYTHON_VERSION:
USE_CYTHON = True
else:
raise ImportError(
f'The installed Cython version ({cy_installed_version}) '
f'does not match the required version ({CYTHON_VERSION}). '
'Please insstall the exact required Cython version in order to '
'generate the C sources.'
)
# ``pytest_runner`` is referenced in ``setup_requires``.
# See https://github.com/pytest-dev/pytest-runner#conditional-requirement
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
pytest_runner = ['pytest-runner'] if needs_pytest else []
# Get the long description from the README file
readme_fpath = path.join(path.dirname(lakesuperior.basedir), 'README.rst')
with open(readme_fpath, encoding='utf-8') as f:
long_description = f.read()
# Extensions directory.
coll_src_dir = path.join('ext', 'collections-c', 'src')
lmdb_src_dir = path.join('ext', 'lmdb', 'libraries', 'liblmdb')
spookyhash_src_dir = path.join('ext', 'spookyhash', 'src')
tpl_src_dir = path.join('ext', 'tpl', 'src')
include_dirs = [
path.join(coll_src_dir, 'include'),
lmdb_src_dir,
spookyhash_src_dir,
tpl_src_dir,
]
cy_include_dir = path.join('lakesuperior', 'cy_include')
if USE_CYTHON:
print(f'Using Cython {CYTHON_VERSION} to generate C extensions.')
include_dirs.append(cy_include_dir)
ext = 'pyx'
pxdext = 'pxd'
else:
print(f'Cython {CYTHON_VERSION} not found. Using provided C extensions.')
ext = pxdext = 'c'
extensions = [
Extension(
'lakesuperior.model.base',
[
path.join(tpl_src_dir, 'tpl.c'),
path.join('lakesuperior', 'model', f'base.{ext}'),
],
include_dirs=include_dirs,
#extra_compile_args=['-fopenmp', '-g'],
#extra_link_args=['-fopenmp', '-g']
),
Extension(
'lakesuperior.model.callbacks',
[
path.join('lakesuperior', 'model', f'callbacks.{ext}'),
],
include_dirs=include_dirs,
#extra_compile_args=['-g'],
#extra_link_args=['-g'],
),
Extension(
'lakesuperior.model.structures.hash',
[
#path.join(spookyhash_src_dir, 'context.c'),
#path.join(spookyhash_src_dir, 'globals.c'),
path.join(spookyhash_src_dir, 'spookyhash.c'),
path.join('lakesuperior', 'model', 'structures', f'hash.{ext}'),
],
include_dirs=include_dirs,
#extra_compile_args=['-g'],
#extra_link_args=['-g']
),
Extension(
'lakesuperior.model.structures.keyset',
[
path.join('lakesuperior', 'model', 'structures', f'keyset.{ext}'),
],
include_dirs=include_dirs,
#extra_compile_args=['-fopenmp', '-g'],
#extra_link_args=['-fopenmp', '-g']
),
Extension(
'lakesuperior.store.base_lmdb_store',
[
path.join(tpl_src_dir, 'tpl.c'),
path.join(lmdb_src_dir, 'mdb.c'),
path.join(lmdb_src_dir, 'midl.c'),
path.join('lakesuperior', 'store', f'base_lmdb_store.{ext}'),
],
include_dirs=include_dirs,
#extra_compile_args=['-g'],
#extra_link_args=['-g'],
),
Extension(
'lakesuperior.model.rdf.term',
[
path.join(tpl_src_dir, 'tpl.c'),
path.join('lakesuperior', 'model', 'rdf', f'term.{ext}'),
],
include_dirs=include_dirs,
#extra_compile_args=['-g'],
#extra_link_args=['-g'],
),
Extension(
'lakesuperior.model.rdf.triple',
[
path.join('lakesuperior', 'model', 'rdf', f'triple.{ext}'),
],
include_dirs=include_dirs,
#extra_compile_args=['-g'],
#extra_link_args=['-g'],
),
Extension(
'lakesuperior.model.rdf.graph',
[
path.join('lakesuperior', 'model', 'rdf', f'graph.{ext}'),
],
include_dirs=include_dirs,
#extra_compile_args=['-g'],
#extra_link_args=['-g'],
),
Extension(
'lakesuperior.store.ldp_rs.lmdb_triplestore',
[
path.join(coll_src_dir, 'common.c'),
path.join(coll_src_dir, 'array.c'),
path.join(coll_src_dir, 'hashtable.c'),
path.join(coll_src_dir, 'hashset.c'),
path.join(lmdb_src_dir, 'mdb.c'),
path.join(lmdb_src_dir, 'midl.c'),
path.join(
'lakesuperior', 'store', 'ldp_rs', f'lmdb_triplestore.{ext}'),
],
include_dirs=include_dirs,
#extra_compile_args=['-g', '-fopenmp'],
#extra_link_args=['-g', '-fopenmp']
),
]
# Great reference read about dependency management:
# https://caremad.io/posts/2013/07/setup-vs-requirement/
install_requires = [
'CoilMQ',
'Flask',
'PyYAML',
'arrow',
'click',
'click-log',
'cymem',
'gevent',
'gunicorn',
'rdflib',
'rdflib-jsonld',
'requests',
'requests-toolbelt',
'sphinx-rtd-theme',
'stomp.py',
]
if USE_CYTHON:
extensions = cythonize(
extensions,
include_path=include_dirs,
annotate=True,
compiler_directives={
'language_level': 3,
'boundscheck': False,
'wraparound': False,
'profile': True,
'embedsignature': True,
'linetrace': True,
'binding': True,
}
)
setup(
name='lakesuperior',
version=lakesuperior.release,
description='A Linked Data Platform repository sever.',
long_description=long_description,
url='https://lakesuperior.readthedocs.io',
author='Stefano Cossu <@scossu>',
#author_email='',
license='Apache License Version 2.0',
ext_modules=extensions,
zip_safe=False,
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Environment :: Web Environment',
'Framework :: Flask',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Cython',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Database :: Database Engines/Servers',
'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
'Topic :: Software Development :: Libraries :: Application Frameworks',
],
keywords='repository linked-data',
python_requires='>=3.6',
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
install_requires=install_requires,
setup_requires=[
'setuptools>=18.0',
] + pytest_runner,
tests_require=[
'Pillow',
'numpy',
'pytest',
'pytest-flask',
],
include_package_data=True,
#extras_require={},
#package_data={
#},
#data_files=[],
entry_points={
'console_scripts': [
'lsup-admin=lakesuperior.lsup_admin:admin',
'lsup-benchmark=lakesuperior.util.benchmark:run',
'lsup-profiler=lakesuperior.profiler:run',
'lsup-server=lakesuperior.server:run',
],
},
scripts=['bin/fcrepo'],
project_urls={
'Source Code': 'https://github.com/scossu/lakesuperior/',
'Documentation': 'https://lakesuperior.readthedocs.io',
'Discussion': 'https://groups.google.com/forum/#!forum/lakesuperior',
'Bug Reports': 'https://github.com/scossu/lakesuperior/issues',
}
)