setup.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import re
  4. import sys
  5. import platform
  6. from os.path import join, dirname
  7. from setuptools import setup, find_packages
  8. from setuptools.extension import Extension
  9. with open(join(dirname(__file__), 'thriftpy2', '__init__.py'), 'r') as f:
  10. version = re.match(r".*__version__ = '(.*?)'", f.read(), re.S).group(1)
  11. install_requires = [
  12. "ply>=3.4,<4.0",
  13. ]
  14. tornado_requires = [
  15. "tornado>=4.0,<6.0",
  16. ]
  17. try:
  18. from tornado import version as tornado_version
  19. if tornado_version < '5.0':
  20. tornado_requires.append("toro>=0.6")
  21. except ImportError:
  22. # tornado will now only get installed and we'll get the newer one
  23. pass
  24. dev_requires = [
  25. "cython>=0.28.4",
  26. "flake8>=2.5",
  27. "pytest>=2.8",
  28. "sphinx-rtd-theme>=0.1.9",
  29. "sphinx>=1.3",
  30. ] + tornado_requires
  31. # cython detection
  32. try:
  33. from Cython.Build import cythonize
  34. CYTHON = True
  35. except ImportError:
  36. CYTHON = False
  37. cmdclass = {}
  38. ext_modules = []
  39. # pypy detection
  40. PYPY = "__pypy__" in sys.modules
  41. UNIX = platform.system() in ("Linux", "Darwin")
  42. # only build ext in CPython with UNIX platform
  43. if UNIX and not PYPY:
  44. # rebuild .c files if cython available
  45. if CYTHON:
  46. cythonize("thriftpy2/transport/cybase.pyx")
  47. cythonize("thriftpy2/transport/**/*.pyx")
  48. cythonize("thriftpy2/protocol/cybin/cybin.pyx")
  49. ext_modules.append(Extension("thriftpy2.transport.cybase",
  50. ["thriftpy2/transport/cybase.c"]))
  51. ext_modules.append(Extension("thriftpy2.transport.buffered.cybuffered",
  52. ["thriftpy2/transport/buffered/cybuffered.c"]))
  53. ext_modules.append(Extension("thriftpy2.transport.memory.cymemory",
  54. ["thriftpy2/transport/memory/cymemory.c"]))
  55. ext_modules.append(Extension("thriftpy2.transport.framed.cyframed",
  56. ["thriftpy2/transport/framed/cyframed.c"]))
  57. ext_modules.append(Extension("thriftpy2.protocol.cybin",
  58. ["thriftpy2/protocol/cybin/cybin.c"]))
  59. setup(name="thriftpy2",
  60. version=version,
  61. description="Pure python implementation of Apache Thrift.",
  62. keywords="thrift python thriftpy thriftpy2",
  63. author="ThriftPy Organization",
  64. author_email="gotzehsing@gmail.com",
  65. packages=find_packages(exclude=['benchmark', 'docs', 'tests']),
  66. entry_points={},
  67. url="https://thriftpy2.readthedocs.io/",
  68. license="MIT",
  69. zip_safe=False,
  70. long_description=open("README.rst").read(),
  71. install_requires=install_requires,
  72. tests_require=tornado_requires,
  73. python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
  74. extras_require={
  75. "dev": dev_requires,
  76. "tornado": tornado_requires
  77. },
  78. cmdclass=cmdclass,
  79. ext_modules=ext_modules,
  80. include_package_data=True,
  81. classifiers=[
  82. "Topic :: Software Development",
  83. "Development Status :: 4 - Beta",
  84. "Intended Audience :: Developers",
  85. "License :: OSI Approved :: MIT License",
  86. "Programming Language :: Python :: 2",
  87. "Programming Language :: Python :: 2.7",
  88. "Programming Language :: Python :: 3",
  89. "Programming Language :: Python :: 3.4",
  90. "Programming Language :: Python :: 3.5",
  91. "Programming Language :: Python :: 3.6",
  92. "Programming Language :: Python :: 3.7",
  93. "Programming Language :: Python :: Implementation :: CPython",
  94. "Programming Language :: Python :: Implementation :: PyPy",
  95. ])