setup.py 3.7 KB

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