setup.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import os
  2. import re
  3. import sys
  4. import codecs
  5. from setuptools import setup, find_packages, Command
  6. from setuptools.command.test import test as TestCommand
  7. here = os.path.abspath(os.path.dirname(__file__))
  8. setup_requires = ['pytest', 'tox']
  9. install_requires = ['six', 'tox', 'atomos']
  10. tests_require = ['six', 'pytest-cov', 'pytest-cache', 'pytest-timeout']
  11. dev_requires = ['pyflakes', 'pep8', 'pylint', 'check-manifest',
  12. 'ipython', 'ipdb', 'sphinx', 'sphinx_rtd_theme',
  13. 'sphinxcontrib-napoleon']
  14. dev_requires.append(tests_require)
  15. PY2 = sys.version_info.major is 2
  16. PY3 = sys.version_info.major is 3
  17. if PY2:
  18. install_requires.append('futures')
  19. install_requires.append('enum34')
  20. if PY3:
  21. install_requires.append('enum34')
  22. version = "0.0.0"
  23. changes = os.path.join(here, "CHANGES.md")
  24. match = '^#*\s*(?P<version>[0-9]+\.[0-9]+(\.[0-9]+)?)$'
  25. with codecs.open(changes, encoding='utf-8') as changes:
  26. for line in changes:
  27. match = re.match(match, line)
  28. if match:
  29. version = match.group("version")
  30. break
  31. # Get the long description
  32. with codecs.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
  33. long_description = f.read()
  34. # Get version
  35. with codecs.open(os.path.join(here, 'CHANGES.md'), encoding='utf-8') as f:
  36. changelog = f.read()
  37. class VersionCommand(Command):
  38. description = "print library version"
  39. user_options = []
  40. def initialize_options(self):
  41. pass
  42. def finalize_options(self):
  43. pass
  44. def run(self):
  45. print(version)
  46. class PyTest(TestCommand):
  47. def finalize_options(self):
  48. TestCommand.finalize_options(self)
  49. self.test_args = ['--strict', '--verbose', '--tb=long',
  50. '--cov', 'hystrix', '--cov-report',
  51. 'term-missing', 'tests']
  52. self.test_suite = True
  53. def run_tests(self):
  54. import pytest
  55. errno = pytest.main(self.test_args)
  56. sys.exit(errno)
  57. class Tox(TestCommand):
  58. user_options = [('tox-args=', 'a', "Arguments to pass to tox")]
  59. def initialize_options(self):
  60. TestCommand.initialize_options(self)
  61. self.tox_args = None
  62. def finalize_options(self):
  63. TestCommand.finalize_options(self)
  64. self.test_args = []
  65. self.test_suite = True
  66. def run_tests(self):
  67. # import here, cause outside the eggs aren't loaded
  68. import tox
  69. import shlex
  70. args = self.tox_args
  71. if args:
  72. args = shlex.split(self.tox_args)
  73. errno = tox.cmdline(args=args)
  74. sys.exit(errno)
  75. setup(
  76. name='hystrix-py',
  77. version='0.1.0',
  78. description='A Netflix Hystrix implementation in Python',
  79. long_description=long_description,
  80. url='https://github.com/wiliamsouza/hystrix-py',
  81. author='The Hystrix Python Authors',
  82. author_email='wiliamsouza83@gmail.com',
  83. license='Apache Software License 2.0',
  84. classifiers=[
  85. 'Development Status :: 3 - Alpha',
  86. 'Intended Audience :: Developers',
  87. 'Topic :: Software Development :: Library',
  88. 'License :: OSI Approved :: Apache Software License 2.0',
  89. 'Programming Language :: Python :: 2',
  90. 'Programming Language :: Python :: 2.7',
  91. 'Programming Language :: Python :: 3',
  92. 'Programming Language :: Python :: 3.3',
  93. 'Programming Language :: Python :: 3.4',
  94. ],
  95. keywords='sample setuptools development',
  96. packages=find_packages(exclude=['docs', 'tests']),
  97. setup_requires=setup_requires,
  98. install_requires=install_requires,
  99. tests_require=tests_require,
  100. extras_require={
  101. 'dev': dev_requires,
  102. 'test': tests_require,
  103. },
  104. cmdclass={
  105. "version": VersionCommand,
  106. 'test': PyTest,
  107. "tox": Tox,
  108. },
  109. )