setup.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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']
  9. install_requires = ['aiohttp==0.16.5', 'aioredis==0.2.2', 'prettyconf==0.3.3']
  10. dev_requires = ['pyflakes', 'pep8', 'pylint', 'check-manifest',
  11. 'ipython', 'ipdb', 'sphinx', 'sphinx_rtd_theme',
  12. 'sphinxcontrib-napoleon']
  13. tests_require = ['pytest-cov', 'pytest-cache', 'pytest-timeout',
  14. 'pytest-asyncio==0.2.0', 'tox', 'redis']
  15. dev_requires.append(tests_require)
  16. version = "0.0.0"
  17. changes = os.path.join(here, "CHANGES.md")
  18. match = b'^#*\s*(?P<version>[0-9]+\.[0-9]+(\.[0-9]+)?)$'
  19. with codecs.open(changes, encoding='utf-8') as changes:
  20. for line in changes:
  21. match = re.match(match, bytes(line, encoding='utf-8'))
  22. if match:
  23. version = match.group("version")
  24. break
  25. # Get the long description
  26. with codecs.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
  27. long_description = f.read()
  28. # Get version
  29. with codecs.open(os.path.join(here, 'CHANGES.md'), encoding='utf-8') as f:
  30. changelog = f.read()
  31. class VersionCommand(Command):
  32. description = "print library version"
  33. user_options = []
  34. def initialize_options(self):
  35. pass
  36. def finalize_options(self):
  37. pass
  38. def run(self):
  39. print(version)
  40. class PyTest(TestCommand):
  41. def finalize_options(self):
  42. TestCommand.finalize_options(self)
  43. self.test_args = ['--strict', '--verbose', '--tb=long',
  44. '--cov', 'echo', '--cov-report',
  45. 'term-missing', 'tests']
  46. self.test_suite = True
  47. def run_tests(self):
  48. import pytest
  49. errno = pytest.main(self.test_args)
  50. sys.exit(errno)
  51. class Tox(TestCommand):
  52. user_options = [('tox-args=', 'a', "Arguments to pass to tox")]
  53. def initialize_options(self):
  54. TestCommand.initialize_options(self)
  55. self.tox_args = None
  56. def finalize_options(self):
  57. TestCommand.finalize_options(self)
  58. self.test_args = []
  59. self.test_suite = True
  60. def run_tests(self):
  61. # import here, cause outside the eggs aren't loaded
  62. import tox
  63. import shlex
  64. args = self.tox_args
  65. if args:
  66. args = shlex.split(self.tox_args)
  67. errno = tox.cmdline(args=args)
  68. sys.exit(errno)
  69. setup(
  70. name='echod',
  71. version='0.1.0',
  72. description='Echo is a mock server, chaos proxy and a callback recorder.',
  73. long_description=long_description,
  74. url='https://github.com/wiliamsouza/echo',
  75. author='The Echo Authors',
  76. author_email='wiliamsouza83@gmail.com',
  77. classifiers=[
  78. 'Development Status :: 3 - Alpha',
  79. 'Intended Audience :: Developers',
  80. 'Programming Language :: Python :: 3',
  81. 'Programming Language :: Python :: 3.3',
  82. 'Programming Language :: Python :: 3.4',
  83. 'Environment :: No Input/Output (Daemon)',
  84. 'Topic :: Internet :: WWW/HTTP :: HTTP Servers',
  85. 'Topic :: Software Development :: Libraries',
  86. 'Topic :: Software Development :: Testing'
  87. ],
  88. keywords='mock chaos monkey proxy callback',
  89. packages=find_packages(exclude=['docs', 'tests*']),
  90. setup_requires=setup_requires,
  91. install_requires=install_requires,
  92. tests_require=tests_require,
  93. extras_require={
  94. 'dev': dev_requires,
  95. 'test': tests_require,
  96. },
  97. cmdclass={
  98. "version": VersionCommand,
  99. 'test': PyTest,
  100. "tox": Tox,
  101. },
  102. entry_points={
  103. 'console_scripts': [
  104. 'echod = echo.echod:main',
  105. ]
  106. },
  107. )