setup.py 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. """
  2. Lakesuperior setup script.
  3. Proudly ripped from https://github.com/pypa/sampleproject/blob/master/setup.py
  4. """
  5. import sys
  6. # Always prefer setuptools over distutils
  7. from setuptools import Extension, setup, find_packages
  8. # To use a consistent encoding
  9. from codecs import open
  10. from glob import glob
  11. from os import path
  12. import lakesuperior
  13. # Use this version to build C files from .pyx sources.
  14. CYTHON_VERSION='0.29.22'
  15. KLEN = 5 # TODO Move somewhere else (config?)
  16. try:
  17. import Cython
  18. from Cython.Build import cythonize
  19. except ImportError:
  20. USE_CYTHON = False
  21. else:
  22. cy_installed_version = Cython.__version__
  23. if cy_installed_version == CYTHON_VERSION:
  24. USE_CYTHON = True
  25. else:
  26. raise ImportError(
  27. f'The installed Cython version ({cy_installed_version}) '
  28. f'does not match the required version ({CYTHON_VERSION}). '
  29. 'Please insstall the exact required Cython version in order to '
  30. 'generate the C sources.'
  31. )
  32. # ``pytest_runner`` is referenced in ``setup_requires``.
  33. # See https://github.com/pytest-dev/pytest-runner#conditional-requirement
  34. needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
  35. pytest_runner = ['pytest-runner'] if needs_pytest else []
  36. # Get the long description from the README file
  37. readme_fpath = path.join(path.dirname(lakesuperior.basedir), 'README.rst')
  38. with open(readme_fpath, encoding='utf-8') as f:
  39. long_description = f.read()
  40. # Extensions directory.
  41. coll_src_dir = path.join('ext', 'collections-c', 'src')
  42. lmdb_src_dir = path.join('ext', 'lmdb', 'libraries', 'liblmdb')
  43. spookyhash_src_dir = path.join('ext', 'spookyhash', 'src')
  44. tpl_src_dir = path.join('ext', 'tpl', 'src')
  45. include_dirs = [
  46. path.join(coll_src_dir, 'include'),
  47. lmdb_src_dir,
  48. spookyhash_src_dir,
  49. tpl_src_dir,
  50. ]
  51. cy_include_dir = path.join('lakesuperior', 'cy_include')
  52. if USE_CYTHON:
  53. print(f'Using Cython {CYTHON_VERSION} to generate C extensions.')
  54. include_dirs.append(cy_include_dir)
  55. ext = 'pyx'
  56. pxdext = 'pxd'
  57. else:
  58. print(f'Cython {CYTHON_VERSION} not found. Using provided C extensions.')
  59. ext = pxdext = 'c'
  60. extensions = [
  61. Extension(
  62. 'lakesuperior.model.base',
  63. [
  64. path.join(tpl_src_dir, 'tpl.c'),
  65. path.join('lakesuperior', 'model', f'base.{ext}'),
  66. ],
  67. include_dirs=include_dirs,
  68. #extra_compile_args=['-fopenmp', '-g'],
  69. #extra_link_args=['-fopenmp', '-g']
  70. ),
  71. Extension(
  72. 'lakesuperior.model.callbacks',
  73. [
  74. path.join('lakesuperior', 'model', f'callbacks.{ext}'),
  75. ],
  76. include_dirs=include_dirs,
  77. #extra_compile_args=['-g'],
  78. #extra_link_args=['-g'],
  79. ),
  80. Extension(
  81. 'lakesuperior.model.structures.hash',
  82. [
  83. #path.join(spookyhash_src_dir, 'context.c'),
  84. #path.join(spookyhash_src_dir, 'globals.c'),
  85. path.join(spookyhash_src_dir, 'spookyhash.c'),
  86. path.join('lakesuperior', 'model', 'structures', f'hash.{ext}'),
  87. ],
  88. include_dirs=include_dirs,
  89. #extra_compile_args=['-g'],
  90. #extra_link_args=['-g']
  91. ),
  92. Extension(
  93. 'lakesuperior.model.structures.keyset',
  94. [
  95. path.join('lakesuperior', 'model', 'structures', f'keyset.{ext}'),
  96. ],
  97. include_dirs=include_dirs,
  98. #extra_compile_args=['-fopenmp', '-g'],
  99. #extra_link_args=['-fopenmp', '-g']
  100. ),
  101. Extension(
  102. 'lakesuperior.store.base_lmdb_store',
  103. [
  104. path.join(tpl_src_dir, 'tpl.c'),
  105. path.join(lmdb_src_dir, 'mdb.c'),
  106. path.join(lmdb_src_dir, 'midl.c'),
  107. path.join('lakesuperior', 'store', f'base_lmdb_store.{ext}'),
  108. ],
  109. include_dirs=include_dirs,
  110. #extra_compile_args=['-g'],
  111. #extra_link_args=['-g'],
  112. ),
  113. Extension(
  114. 'lakesuperior.model.rdf.term',
  115. [
  116. path.join(tpl_src_dir, 'tpl.c'),
  117. path.join('lakesuperior', 'model', 'rdf', f'term.{ext}'),
  118. ],
  119. include_dirs=include_dirs,
  120. #extra_compile_args=['-g'],
  121. #extra_link_args=['-g'],
  122. ),
  123. Extension(
  124. 'lakesuperior.model.rdf.triple',
  125. [
  126. path.join('lakesuperior', 'model', 'rdf', f'triple.{ext}'),
  127. ],
  128. include_dirs=include_dirs,
  129. #extra_compile_args=['-g'],
  130. #extra_link_args=['-g'],
  131. ),
  132. Extension(
  133. 'lakesuperior.model.rdf.graph',
  134. [
  135. path.join('lakesuperior', 'model', 'rdf', f'graph.{ext}'),
  136. ],
  137. include_dirs=include_dirs,
  138. #extra_compile_args=['-g'],
  139. #extra_link_args=['-g'],
  140. ),
  141. Extension(
  142. 'lakesuperior.store.ldp_rs.lmdb_triplestore',
  143. [
  144. path.join(coll_src_dir, 'common.c'),
  145. path.join(coll_src_dir, 'array.c'),
  146. path.join(coll_src_dir, 'hashtable.c'),
  147. path.join(coll_src_dir, 'hashset.c'),
  148. path.join(lmdb_src_dir, 'mdb.c'),
  149. path.join(lmdb_src_dir, 'midl.c'),
  150. path.join(
  151. 'lakesuperior', 'store', 'ldp_rs', f'lmdb_triplestore.{ext}'),
  152. ],
  153. include_dirs=include_dirs,
  154. #extra_compile_args=['-g', '-fopenmp'],
  155. #extra_link_args=['-g', '-fopenmp']
  156. ),
  157. ]
  158. # Great reference read about dependency management:
  159. # https://caremad.io/posts/2013/07/setup-vs-requirement/
  160. install_requires = [
  161. 'CoilMQ',
  162. 'Flask',
  163. 'PyYAML',
  164. 'arrow',
  165. 'click',
  166. 'click-log',
  167. 'cymem',
  168. 'gevent',
  169. 'gunicorn',
  170. 'rdflib',
  171. 'rdflib-jsonld',
  172. 'requests',
  173. 'requests-toolbelt',
  174. 'sphinx-rtd-theme',
  175. 'stomp.py',
  176. ]
  177. if USE_CYTHON:
  178. extensions = cythonize(
  179. extensions,
  180. include_path=include_dirs,
  181. annotate=True,
  182. compiler_directives={
  183. 'language_level': 3,
  184. 'boundscheck': False,
  185. 'wraparound': False,
  186. 'profile': True,
  187. 'embedsignature': True,
  188. 'linetrace': True,
  189. 'binding': True,
  190. }
  191. )
  192. setup(
  193. name='lakesuperior',
  194. version=lakesuperior.release,
  195. description='A Linked Data Platform repository sever.',
  196. long_description=long_description,
  197. url='https://lakesuperior.readthedocs.io',
  198. author='Stefano Cossu <@scossu>',
  199. #author_email='',
  200. license='Apache License Version 2.0',
  201. ext_modules=extensions,
  202. zip_safe=False,
  203. # https://pypi.python.org/pypi?%3Aaction=list_classifiers
  204. classifiers=[
  205. 'Development Status :: 3 - Alpha',
  206. 'Environment :: Console',
  207. 'Environment :: Web Environment',
  208. 'Framework :: Flask',
  209. 'Intended Audience :: Developers',
  210. 'Intended Audience :: Information Technology',
  211. 'Intended Audience :: Science/Research',
  212. 'License :: OSI Approved :: Apache Software License',
  213. 'Natural Language :: English',
  214. 'Operating System :: MacOS',
  215. 'Operating System :: Microsoft :: Windows',
  216. 'Operating System :: POSIX :: Linux',
  217. 'Programming Language :: Cython',
  218. 'Programming Language :: Python :: 3',
  219. 'Programming Language :: Python :: 3.6',
  220. 'Programming Language :: Python :: 3.7',
  221. 'Topic :: Database :: Database Engines/Servers',
  222. 'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
  223. 'Topic :: Software Development :: Libraries :: Application Frameworks',
  224. ],
  225. keywords='repository linked-data',
  226. python_requires='>=3.6',
  227. packages=find_packages(exclude=['contrib', 'docs', 'tests']),
  228. install_requires=install_requires,
  229. setup_requires=[
  230. 'setuptools>=18.0',
  231. ] + pytest_runner,
  232. tests_require=[
  233. 'Pillow',
  234. 'numpy',
  235. 'pytest',
  236. 'pytest-flask',
  237. ],
  238. include_package_data=True,
  239. #extras_require={},
  240. #package_data={
  241. #},
  242. #data_files=[],
  243. entry_points={
  244. 'console_scripts': [
  245. 'lsup-admin=lakesuperior.lsup_admin:admin',
  246. 'lsup-benchmark=lakesuperior.util.benchmark:run',
  247. 'lsup-profiler=lakesuperior.profiler:run',
  248. 'lsup-server=lakesuperior.server:run',
  249. ],
  250. },
  251. scripts=['bin/fcrepo'],
  252. project_urls={
  253. 'Source Code': 'https://github.com/scossu/lakesuperior/',
  254. 'Documentation': 'https://lakesuperior.readthedocs.io',
  255. 'Discussion': 'https://groups.google.com/forum/#!forum/lakesuperior',
  256. 'Bug Reports': 'https://github.com/scossu/lakesuperior/issues',
  257. }
  258. )