123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- import os
- import re
- import sys
- import codecs
- from setuptools import setup, find_packages, Command
- from setuptools.command.test import test as TestCommand
- here = os.path.abspath(os.path.dirname(__file__))
- setup_requires = ['pytest', 'tox']
- install_requires = ['six', 'tox', 'atomos']
- tests_require = ['six', 'pytest-cov', 'pytest-cache', 'pytest-timeout']
- dev_requires = ['pyflakes', 'pep8', 'pylint', 'check-manifest',
- 'ipython', 'ipdb', 'sphinx', 'sphinx_rtd_theme',
- 'sphinxcontrib-napoleon']
- dev_requires.append(tests_require)
- PY2 = sys.version_info.major is 2
- PY3 = sys.version_info.major is 3
- if PY2:
- install_requires.append('futures')
- install_requires.append('enum34')
- if PY3:
- install_requires.append('enum34')
- version = "0.0.0"
- changes = os.path.join(here, "CHANGES.md")
- match = '^#*\s*(?P<version>[0-9]+\.[0-9]+(\.[0-9]+)?)$'
- with codecs.open(changes, encoding='utf-8') as changes:
- for line in changes:
- match = re.match(match, line)
- if match:
- version = match.group("version")
- break
- # Get the long description
- with codecs.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
- long_description = f.read()
- # Get version
- with codecs.open(os.path.join(here, 'CHANGES.md'), encoding='utf-8') as f:
- changelog = f.read()
- class VersionCommand(Command):
- description = "print library version"
- user_options = []
- def initialize_options(self):
- pass
- def finalize_options(self):
- pass
- def run(self):
- print(version)
- class PyTest(TestCommand):
- def finalize_options(self):
- TestCommand.finalize_options(self)
- self.test_args = ['--strict', '--verbose', '--tb=long',
- '--cov', 'hystrix', '--cov-report',
- 'term-missing', 'tests']
- self.test_suite = True
- def run_tests(self):
- import pytest
- errno = pytest.main(self.test_args)
- sys.exit(errno)
- class Tox(TestCommand):
- user_options = [('tox-args=', 'a', "Arguments to pass to tox")]
- def initialize_options(self):
- TestCommand.initialize_options(self)
- self.tox_args = None
- def finalize_options(self):
- TestCommand.finalize_options(self)
- self.test_args = []
- self.test_suite = True
- def run_tests(self):
- # import here, cause outside the eggs aren't loaded
- import tox
- import shlex
- args = self.tox_args
- if args:
- args = shlex.split(self.tox_args)
- errno = tox.cmdline(args=args)
- sys.exit(errno)
- setup(
- name='hystrix-py',
- version='0.1.0',
- description='A Netflix Hystrix implementation in Python',
- long_description=long_description,
- url='https://github.com/wiliamsouza/hystrix-py',
- author='The Hystrix Python Authors',
- author_email='wiliamsouza83@gmail.com',
- license='Apache Software License 2.0',
- classifiers=[
- 'Development Status :: 3 - Alpha',
- 'Intended Audience :: Developers',
- 'Topic :: Software Development :: Library',
- 'License :: OSI Approved :: Apache Software License 2.0',
- 'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.3',
- 'Programming Language :: Python :: 3.4',
- ],
- keywords='sample setuptools development',
- packages=find_packages(exclude=['docs', 'tests']),
- setup_requires=setup_requires,
- install_requires=install_requires,
- tests_require=tests_require,
- extras_require={
- 'dev': dev_requires,
- 'test': tests_require,
- },
- cmdclass={
- "version": VersionCommand,
- 'test': PyTest,
- "tox": Tox,
- },
- )
|