A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 29
rs 10
wmc 3
1
"""A setuptools based setup module."""
2
3
# To use a consistent encoding
4
import codecs
5
import os
6
# setup
7
import setuptools
8
# a fix for behave_test in behave 1.2.5
9
import shlex
10
import subprocess
11
import sys
12
# noinspection PyPep8Naming
13
from setuptools.command.test import test as TestCommand
14
15
16
__author__ = 'Tomasz J. Kotarba <[email protected]>'
17
__copyright__ = 'Copyright (c) 2016, Tomasz J. Kotarba. All rights reserved.'
18
__maintainer__ = 'Tomasz J. Kotarba'
19
__email__ = '[email protected]'
20
21
22
# a fix for behave_test in behave 1.2.5
23
class BehaveTest(TestCommand):
24
    user_options = [('behave-args=', 'b', 'Arguments to pass to behave')]
25
26
    # noinspection PyAttributeOutsideInit
27
    def initialize_options(self):
28
        TestCommand.initialize_options(self)
29
        self.behave_args = []
30
        #import here, cause outside the egg is not loaded
31
        from setuptools_behave import behave_test
32
33
        class _BehaveTest(behave_test):
34
            def behave(self, path):
35
                behave = os.path.join("bin", "behave")
36
                if not os.path.exists(behave):
37
                    behave = "-m behave"
38
                cmd_options = self.distribution.command_options[
39
                    'behave_test'].get('behave_args', ['', ''])[1]
40
                self.announce("CMDLINE: python %s %s" % (behave, cmd_options),
41
                              level=3)
42
                behave_cmd = shlex.split(behave)
43
                return subprocess.call(
44
                    [sys.executable] + behave_cmd + shlex.split(cmd_options))
45
        self.behave_command = _BehaveTest(self.distribution)
46
47
    def finalize_options(self):
48
        self.behave_command.finalize_options()
49
50
    def run(self):
51
        self.behave_command.run()
52
53
54
class PyTest(TestCommand):
55
    user_options = [('pytest-args=', 'p', "Arguments to pass to pytest")]
56
57
    def initialize_options(self):
58
        TestCommand.initialize_options(self)
59
        self.pytest_args = ''
60
61
    def run_tests(self):
62
        import shlex
63
        import pytest
64
        errno = pytest.main(shlex.split(self.pytest_args))
65
        sys.exit(errno)
66
67
68
install_requires = [
69
    'docopt>=0.6,<1',
70
    'rapidpro-python>=2.1.1,<3',
71
    'sqlalchemy>=1.1.3,<2',
72
]
73
74
75
tests_require = [
76
    'PyHamcrest>=1.9,<2',
77
    'behave>=1.2.5,<2',
78
    'iocapture>=0.1.2,<1',
79
    'mock>=2,<3',
80
    'pretenders>=1.4.2,<2',
81
    'pytest>=3,<4',
82
    'pytest-cov>=2.4,<3',
83
    'pytz>=2016.7',
84
    'tox-travis',
85
]
86
87
88
here = os.path.abspath(os.path.dirname(__file__))
89
90
91
# Get the long description from the README.rst file
92
with codecs.open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
93
    long_description = f.read()
94
95
96
setuptools.setup(
97
    name='rapidpro-pull',
98
    version='1.0.3',
99
    description='An open-source tool to pull and cache data from RapidPro'
100
                ' servers.',
101
    long_description=long_description,
102
    url='https://github.com/system7-open-source/rapidpro-pull',
103
    author='Tomasz J. Kotarba',
104
    author_email='[email protected]',
105
    license='GPLv3+',
106
    classifiers=[
107
        'Development Status :: 5 - Production/Stable',
108
        'Intended Audience :: End Users/Desktop',
109
        'Intended Audience :: System Administrators',
110
        'Topic :: Desktop Environment',
111
        'Topic :: Internet',
112
        'Topic :: Utilities',
113
        'Operating System :: OS Independent',
114
        'License :: OSI Approved :: GNU General Public License v3 or later '
115
        '(GPLv3+)',
116
        'Environment :: Console',
117
        'Programming Language :: Python :: 2',
118
        'Programming Language :: Python :: 2.7',
119
    ],
120
    keywords='rapidpro',
121
    package_dir={'': '.'},
122
    packages=setuptools.find_packages('.', exclude=['features', 'spec']),
123
    python_requires='>=2.7,!=3.*',
124
    setup_requires=['behave>=1.2.5,<2'],
125
    install_requires=install_requires,
126
    tests_require=tests_require,
127
    extras_require={'development': tests_require},
128
    entry_points={
129
        'console_scripts': [
130
            'rapidpro-pull = rapidpropull.cli:main',
131
        ],
132
    },
133
    cmdclass={'behave_test': BehaveTest,
134
              'pytest': PyTest},
135
)
136