setup.py 7.6 KB

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