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