setup.py 7.8 KB

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