setup.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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__), 'thriftpy', '__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,<5.0",
  16. "toro==0.6"
  17. ]
  18. dev_requires = [
  19. "cython>=0.23",
  20. "flake8>=2.5",
  21. "pytest>=2.8",
  22. "sphinx-rtd-theme>=0.1.9",
  23. "sphinx>=1.3",
  24. ] + tornado_requires
  25. # cython detection
  26. try:
  27. from Cython.Build import cythonize
  28. CYTHON = True
  29. except ImportError:
  30. CYTHON = False
  31. cmdclass = {}
  32. ext_modules = []
  33. # pypy detection
  34. PYPY = "__pypy__" in sys.modules
  35. UNIX = platform.system() in ("Linux", "Darwin")
  36. # only build ext in CPython with UNIX platform
  37. if UNIX and not PYPY:
  38. # rebuild .c files if cython available
  39. if CYTHON:
  40. cythonize("thriftpy/transport/cybase.pyx")
  41. cythonize("thriftpy/transport/**/*.pyx")
  42. cythonize("thriftpy/protocol/cybin/cybin.pyx")
  43. ext_modules.append(Extension("thriftpy.transport.cybase",
  44. ["thriftpy/transport/cybase.c"]))
  45. ext_modules.append(Extension("thriftpy.transport.buffered.cybuffered",
  46. ["thriftpy/transport/buffered/cybuffered.c"]))
  47. ext_modules.append(Extension("thriftpy.transport.memory.cymemory",
  48. ["thriftpy/transport/memory/cymemory.c"]))
  49. ext_modules.append(Extension("thriftpy.transport.framed.cyframed",
  50. ["thriftpy/transport/framed/cyframed.c"]))
  51. ext_modules.append(Extension("thriftpy.protocol.cybin",
  52. ["thriftpy/protocol/cybin/cybin.c"]))
  53. setup(name="thriftpy",
  54. version=version,
  55. description="Pure python implementation of Apache Thrift.",
  56. keywords="thrift python thriftpy",
  57. author="Lx Yu",
  58. author_email="i@lxyu.net",
  59. packages=find_packages(exclude=['benchmark', 'docs', 'tests']),
  60. package_data={"thriftpy": ["contrib/tracking/tracking.thrift"]},
  61. entry_points={},
  62. url="https://thriftpy.readthedocs.org/",
  63. license="MIT",
  64. zip_safe=False,
  65. long_description=open("README.rst").read(),
  66. install_requires=install_requires,
  67. tests_require=tornado_requires,
  68. extras_require={
  69. "dev": dev_requires,
  70. "tornado": tornado_requires
  71. },
  72. cmdclass=cmdclass,
  73. ext_modules=ext_modules,
  74. classifiers=[
  75. "Topic :: Software Development",
  76. "Development Status :: 4 - Beta",
  77. "Intended Audience :: Developers",
  78. "License :: OSI Approved :: MIT License",
  79. "Programming Language :: Python :: 2.6",
  80. "Programming Language :: Python :: 2.7",
  81. "Programming Language :: Python :: 3.3",
  82. "Programming Language :: Python :: 3.4",
  83. "Programming Language :: Python :: 3.5",
  84. "Programming Language :: Python :: Implementation :: CPython",
  85. "Programming Language :: Python :: Implementation :: PyPy",
  86. ])