setup.py 5.6 KB

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