setup.py 8.2 KB

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