setup.py 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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.6'
  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. #extra_compile_args=['-fopenmp'],
  80. #extra_link_args=['-fopenmp']
  81. ),
  82. Extension(
  83. 'lakesuperior.model.structures.*',
  84. [
  85. path.join(spookyhash_src_dir, 'spookyhash.c'),
  86. path.join(coll_src_dir, 'common.c'),
  87. path.join(coll_src_dir, 'array.c'),
  88. path.join(coll_src_dir, 'hashtable.c'),
  89. path.join(coll_src_dir, 'hashset.c'),
  90. path.join('lakesuperior', 'model', 'structures', f'*.{ext}'),
  91. ],
  92. include_dirs=include_dirs,
  93. extra_compile_args=['-fopenmp', '-g'],
  94. extra_link_args=['-fopenmp', '-g']
  95. ),
  96. Extension(
  97. 'lakesuperior.store.base_lmdb_store',
  98. [
  99. path.join(coll_src_dir, 'common.c'),
  100. path.join(coll_src_dir, 'array.c'),
  101. path.join(coll_src_dir, 'hashtable.c'),
  102. path.join(coll_src_dir, 'hashset.c'),
  103. path.join(tpl_src_dir, 'tpl.c'),
  104. path.join(lmdb_src_dir, 'mdb.c'),
  105. path.join(lmdb_src_dir, 'midl.c'),
  106. path.join('lakesuperior', 'store', f'base_lmdb_store.{ext}'),
  107. ],
  108. include_dirs=include_dirs,
  109. extra_compile_args=['-g'],
  110. extra_link_args=['-g'],
  111. ),
  112. Extension(
  113. 'lakesuperior.model.rdf.*',
  114. [
  115. path.join(tpl_src_dir, 'tpl.c'),
  116. path.join(spookyhash_src_dir, 'context.c'),
  117. path.join(spookyhash_src_dir, 'globals.c'),
  118. path.join(spookyhash_src_dir, 'spookyhash.c'),
  119. path.join(coll_src_dir, 'common.c'),
  120. path.join(coll_src_dir, 'array.c'),
  121. path.join(coll_src_dir, 'hashtable.c'),
  122. path.join(coll_src_dir, 'hashset.c'),
  123. path.join('lakesuperior', 'model', 'rdf', f'*.{ext}'),
  124. ],
  125. include_dirs=include_dirs,
  126. #extra_compile_args=['-fopenmp'],
  127. #extra_link_args=['-fopenmp']
  128. ),
  129. Extension(
  130. 'lakesuperior.store.ldp_rs.lmdb_triplestore',
  131. [
  132. path.join(coll_src_dir, 'common.c'),
  133. path.join(coll_src_dir, 'array.c'),
  134. path.join(coll_src_dir, 'hashtable.c'),
  135. path.join(coll_src_dir, 'hashset.c'),
  136. path.join(lmdb_src_dir, 'mdb.c'),
  137. path.join(lmdb_src_dir, 'midl.c'),
  138. path.join(
  139. 'lakesuperior', 'store', 'ldp_rs', f'lmdb_triplestore.{ext}'),
  140. ],
  141. include_dirs=include_dirs,
  142. extra_compile_args=['-g', '-fopenmp'],
  143. extra_link_args=['-g', '-fopenmp']
  144. ),
  145. ]
  146. # Great reference read about dependency management:
  147. # https://caremad.io/posts/2013/07/setup-vs-requirement/
  148. install_requires = [
  149. 'CoilMQ',
  150. 'Flask',
  151. 'HiYaPyCo',
  152. 'PyYAML',
  153. 'arrow',
  154. 'click',
  155. 'click-log',
  156. 'cymem',
  157. 'gevent',
  158. 'gunicorn',
  159. 'rdflib',
  160. 'rdflib-jsonld',
  161. 'requests',
  162. 'requests-toolbelt',
  163. 'sphinx-rtd-theme',
  164. 'stomp.py',
  165. ]
  166. if USE_CYTHON:
  167. extensions = cythonize(
  168. extensions,
  169. include_path=include_dirs,
  170. annotate=True,
  171. compiler_directives={
  172. 'language_level': 3,
  173. 'boundscheck': False,
  174. 'wraparound': False,
  175. 'profile': True,
  176. 'embedsignature': True
  177. }
  178. )
  179. setup(
  180. name='lakesuperior',
  181. version=lakesuperior.release,
  182. description='A Linked Data Platform repository sever.',
  183. long_description=long_description,
  184. url='https://lakesuperior.readthedocs.io',
  185. author='Stefano Cossu <@scossu>',
  186. #author_email='',
  187. license='Apache License Version 2.0',
  188. ext_modules=extensions,
  189. # https://pypi.python.org/pypi?%3Aaction=list_classifiers
  190. classifiers=[
  191. 'Development Status :: 3 - Alpha',
  192. 'Environment :: Console',
  193. 'Environment :: Web Environment',
  194. 'Framework :: Flask',
  195. 'Intended Audience :: Developers',
  196. 'Intended Audience :: Information Technology',
  197. 'Intended Audience :: Science/Research',
  198. 'License :: OSI Approved :: Apache Software License',
  199. 'Natural Language :: English',
  200. 'Operating System :: MacOS',
  201. 'Operating System :: Microsoft :: Windows',
  202. 'Operating System :: POSIX :: Linux',
  203. 'Programming Language :: Python :: 3',
  204. 'Programming Language :: Python :: 3.6',
  205. 'Programming Language :: Python :: 3.7',
  206. 'Topic :: Database :: Database Engines/Servers',
  207. ],
  208. keywords='repository linked-data',
  209. python_requires='~=3.6',
  210. packages=find_packages(exclude=['contrib', 'docs', 'tests']),
  211. install_requires=install_requires,
  212. setup_requires=[
  213. 'setuptools>=18.0',
  214. ] + pytest_runner,
  215. tests_require=[
  216. 'Pillow',
  217. 'numpy',
  218. 'pytest',
  219. 'pytest-flask',
  220. ],
  221. include_package_data=True,
  222. #extras_require={},
  223. #package_data={
  224. #},
  225. #data_files=[],
  226. entry_points={
  227. 'console_scripts': [
  228. 'lsup-admin=lakesuperior.lsup_admin:admin',
  229. 'lsup-benchmark=lakesuperior.util.benchmark:run',
  230. 'lsup-profiler=lakesuperior.profiler:run',
  231. 'lsup-server=lakesuperior.server:run',
  232. ],
  233. },
  234. scripts=['bin/fcrepo'],
  235. project_urls={
  236. 'Source Code': 'https://github.com/scossu/lakesuperior/',
  237. 'Documentation': 'https://lakesuperior.readthedocs.io',
  238. 'Discussion': 'https://groups.google.com/forum/#!forum/lakesuperior',
  239. 'Bug Reports': 'https://github.com/scossu/lakesuperior/issues',
  240. }
  241. )