setup.py 5.6 KB

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