setup.py 7.2 KB

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