setup.py 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. if Cython.__version__ == CYTHON_VERSION:
  23. USE_CYTHON = True
  24. # ``pytest_runner`` is referenced in ``setup_requires``.
  25. # See https://github.com/pytest-dev/pytest-runner#conditional-requirement
  26. needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
  27. pytest_runner = ['pytest-runner'] if needs_pytest else []
  28. # Get the long description from the README file
  29. readme_fpath = path.join(path.dirname(lakesuperior.basedir), 'README.rst')
  30. with open(readme_fpath, encoding='utf-8') as f:
  31. long_description = f.read()
  32. # Extensions directory.
  33. coll_src_dir = path.join('ext', 'collections-c', 'src')
  34. lmdb_src_dir = path.join('ext', 'lmdb', 'libraries', 'liblmdb')
  35. spookyhash_src_dir = path.join('ext', 'spookyhash', 'src')
  36. tpl_src_dir = path.join('ext', 'tpl', 'src')
  37. include_dirs = [
  38. path.join(coll_src_dir, 'include'),
  39. lmdb_src_dir,
  40. spookyhash_src_dir,
  41. tpl_src_dir,
  42. ]
  43. cy_include_dir = path.join('lakesuperior', 'cy_include')
  44. if USE_CYTHON:
  45. print(f'Using Cython {CYTHON_VERSION} to generate C extensions.')
  46. include_dirs.append(cy_include_dir)
  47. ext = 'pyx'
  48. pxdext = 'pxd'
  49. else:
  50. print(f'Cython {CYTHON_VERSION} not found. Using provided C extensions.')
  51. ext = pxdext = 'c'
  52. extensions = [
  53. Extension(
  54. 'lakesuperior.model.base',
  55. [
  56. path.join(tpl_src_dir, 'tpl.c'),
  57. path.join('lakesuperior', 'model', f'base.{ext}'),
  58. ],
  59. include_dirs=include_dirs,
  60. #extra_compile_args=['-fopenmp'],
  61. #extra_link_args=['-fopenmp']
  62. ),
  63. Extension(
  64. 'lakesuperior.model.structures.*',
  65. [
  66. path.join(spookyhash_src_dir, 'spookyhash.c'),
  67. path.join(coll_src_dir, 'common.c'),
  68. path.join(coll_src_dir, 'array.c'),
  69. path.join(coll_src_dir, 'hashset.c'),
  70. path.join(coll_src_dir, 'hashtable.c'),
  71. path.join('lakesuperior', 'model', 'structures', f'*.{ext}'),
  72. ],
  73. include_dirs=include_dirs,
  74. #extra_compile_args=['-fopenmp'],
  75. #extra_link_args=['-fopenmp']
  76. ),
  77. Extension(
  78. 'lakesuperior.model.graph.*',
  79. [
  80. path.join(tpl_src_dir, 'tpl.c'),
  81. path.join(spookyhash_src_dir, 'spookyhash.c'),
  82. path.join(coll_src_dir, 'common.c'),
  83. path.join(coll_src_dir, 'array.c'),
  84. path.join(coll_src_dir, 'hashset.c'),
  85. path.join(coll_src_dir, 'hashtable.c'),
  86. path.join('lakesuperior', 'model', 'graph', f'*.{ext}'),
  87. ],
  88. include_dirs=include_dirs,
  89. extra_compile_args=['-fopenmp'],
  90. extra_link_args=['-fopenmp']
  91. ),
  92. Extension(
  93. 'lakesuperior.store.base_lmdb_store',
  94. [
  95. path.join(tpl_src_dir, 'tpl.c'),
  96. path.join(lmdb_src_dir, 'mdb.c'),
  97. path.join(lmdb_src_dir, 'midl.c'),
  98. path.join('lakesuperior', 'store', f'base_lmdb_store.{ext}'),
  99. ],
  100. include_dirs=include_dirs,
  101. ),
  102. Extension(
  103. 'lakesuperior.store.ldp_rs.lmdb_triplestore',
  104. [
  105. path.join(lmdb_src_dir, 'mdb.c'),
  106. path.join(lmdb_src_dir, 'midl.c'),
  107. path.join(
  108. 'lakesuperior', 'store', 'ldp_rs', f'lmdb_triplestore.{ext}'),
  109. ],
  110. include_dirs=include_dirs,
  111. extra_compile_args=['-fopenmp'],
  112. extra_link_args=['-fopenmp']
  113. ),
  114. ]
  115. # Great reference read about dependency management:
  116. # https://caremad.io/posts/2013/07/setup-vs-requirement/
  117. install_requires = [
  118. 'CoilMQ',
  119. 'Flask',
  120. 'HiYaPyCo',
  121. 'PyYAML',
  122. 'arrow',
  123. 'click',
  124. 'click-log',
  125. 'cymem',
  126. 'gevent',
  127. 'gunicorn',
  128. 'rdflib',
  129. 'rdflib-jsonld',
  130. 'requests',
  131. 'requests-toolbelt',
  132. 'sphinx-rtd-theme',
  133. 'stomp.py',
  134. ]
  135. if USE_CYTHON:
  136. extensions = cythonize(
  137. extensions,
  138. include_path=include_dirs,
  139. annotate=True,
  140. compiler_directives={
  141. 'language_level': 3,
  142. 'boundscheck': False,
  143. 'wraparound': False,
  144. 'profile': True,
  145. }
  146. )
  147. setup(
  148. name='lakesuperior',
  149. version=lakesuperior.release,
  150. description='A Linked Data Platform repository sever.',
  151. long_description=long_description,
  152. url='https://lakesuperior.readthedocs.io',
  153. author='Stefano Cossu <@scossu>',
  154. #author_email='',
  155. license='Apache License Version 2.0',
  156. ext_modules=extensions,
  157. # https://pypi.python.org/pypi?%3Aaction=list_classifiers
  158. classifiers=[
  159. 'Development Status :: 3 - Alpha',
  160. 'Environment :: Console',
  161. 'Environment :: Web Environment',
  162. 'Framework :: Flask',
  163. 'Intended Audience :: Developers',
  164. 'Intended Audience :: Information Technology',
  165. 'Intended Audience :: Science/Research',
  166. 'License :: OSI Approved :: Apache Software License',
  167. 'Natural Language :: English',
  168. 'Operating System :: MacOS',
  169. 'Operating System :: Microsoft :: Windows',
  170. 'Operating System :: POSIX :: Linux',
  171. 'Programming Language :: Python :: 3',
  172. 'Programming Language :: Python :: 3.6',
  173. 'Programming Language :: Python :: 3.7',
  174. 'Topic :: Database :: Database Engines/Servers',
  175. ],
  176. keywords='repository linked-data',
  177. python_requires='~=3.6',
  178. packages=find_packages(exclude=['contrib', 'docs', 'tests']),
  179. install_requires=install_requires,
  180. setup_requires=[
  181. 'setuptools>=18.0',
  182. ] + pytest_runner,
  183. tests_require=[
  184. 'Pillow',
  185. 'numpy',
  186. 'pytest',
  187. 'pytest-flask',
  188. ],
  189. include_package_data=True,
  190. #extras_require={},
  191. #package_data={
  192. #},
  193. #data_files=[],
  194. entry_points={
  195. 'console_scripts': [
  196. 'lsup-admin=lakesuperior.lsup_admin:admin',
  197. 'lsup-benchmark=lakesuperior.util.benchmark:run',
  198. 'lsup-profiler=lakesuperior.profiler:run',
  199. 'lsup-server=lakesuperior.server:run',
  200. ],
  201. },
  202. scripts=['bin/fcrepo'],
  203. project_urls={
  204. 'Source Code': 'https://github.com/scossu/lakesuperior/',
  205. 'Documentation': 'https://lakesuperior.readthedocs.io',
  206. 'Discussion': 'https://groups.google.com/forum/#!forum/lakesuperior',
  207. 'Bug Reports': 'https://github.com/scossu/lakesuperior/issues',
  208. }
  209. )