setup.py 6.6 KB

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