Test Failed
Push — master ( b668b0...91d406 )
by Nicolas
07:51 queued 03:03
created

setup.get_install_extras_require()   A

Complexity

Conditions 2

Size

Total Lines 26
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 22
nop 0
dl 0
loc 26
rs 9.352
c 0
b 0
f 0
1
#!/usr/bin/env python
2
3
import glob
4
import os
5
import re
6
import sys
7
from io import open
8
9
from setuptools import setup, Command
10
11
12
if sys.version_info < (2, 7) or (3, 0) <= sys.version_info < (3, 4):
13
    print('Glances requires at least Python 2.7 or 3.4 to run.')
14
    sys.exit(1)
15
16
PY2 = sys.version_info[0] == 2
17
PY3 = sys.version_info[0] == 3
18
19
20
# Global functions
21
##################
22
23
with open(os.path.join('glances', '__init__.py'), encoding='utf-8') as f:
24
    version = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", f.read(), re.M).group(1)
25
26
if not version:
27
    raise RuntimeError('Cannot find Glances version information.')
28
29
with open('README.rst', encoding='utf-8') as f:
30
    long_description = f.read()
31
32
33
def get_data_files():
34
    data_files = [
35
        ('share/doc/glances', ['AUTHORS', 'COPYING', 'NEWS.rst', 'README.rst',
36
                               'CONTRIBUTING.md', 'conf/glances.conf']),
37
        ('share/man/man1', ['docs/man/glances.1'])
38
    ]
39
40
    return data_files
41
42
43
def get_install_requires():
44
    requires = ['psutil>=5.3.0', 'future']
45
    if sys.platform.startswith('win'):
46
        requires.append('bottle')
47
        requires.append('requests')
48
49
    return requires
50
51
52
def get_install_extras_require():
53
    extras_require = {
54
        'action': ['pystache'],
55
        # Zeroconf 0.19.1 is the latest one compatible with Python 2 (issue #1293)
56
        'browser': ['zeroconf==0.19.1' if PY2 else 'zeroconf>=0.19.1'],
57
        'cloud': ['requests'],
58
        'cpuinfo': ['py-cpuinfo'],
59
        'docker': ['docker>=2.0.0'],
60
        'export': ['bernhard', 'cassandra-driver', 'couchdb', 'elasticsearch',
61
                   'influxdb>=1.0.0', 'kafka-python', 'pika', 'paho-mqtt', 'potsdb',
62
                   'prometheus_client', 'pyzmq', 'statsd'],
63
        'folders': ['scandir'],  # python_version<"3.5"
64
        'gpu': ['nvidia-ml-py3'],  # python_version=="2.7"
65
        'graph': ['pygal'],
66
        'ip': ['netifaces'],
67
        'raid': ['pymdstat'],
68
        'smart': ['pySMART.smartx'],
69
        'snmp': ['pysnmp'],
70
        'sparklines': ['sparklines'],
71
        'web': ['bottle', 'requests'],
72
        'wifi': ['wifi']
73
    }
74
    # Add automatically the 'all' target
75
    extras_require.update({'all': [i[0] for i in extras_require.values()]})
76
77
    return extras_require
78
79
80
class tests(Command):
81
    user_options = []
82
83
    def initialize_options(self):
84
        pass
85
86
    def finalize_options(self):
87
        pass
88
89
    def run(self):
90
        import subprocess
91
        import sys
92
        for t in glob.glob('unitest.py'):
93
            ret = subprocess.call([sys.executable, t]) != 0
94
            if ret != 0:
95
                raise SystemExit(ret)
96
        raise SystemExit(0)
97
98
99
# Setup !
100
101
setup(
102
    name='Glances',
103
    version=version,
104
    description="A cross-platform curses-based monitoring tool",
105
    long_description=long_description,
106
    author='Nicolas Hennion',
107
    author_email='[email protected]',
108
    url='https://github.com/nicolargo/glances',
109
    license='LGPLv3',
110
    keywords="cli curses monitoring system",
111
    python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
112
    install_requires=get_install_requires(),
113
    extras_require=get_install_extras_require(),
114
    packages=['glances'],
115
    include_package_data=True,
116
    data_files=get_data_files(),
117
    cmdclass={'test': tests},
118
    test_suite="unitest.py",
119
    entry_points={"console_scripts": ["glances=glances:main"]},
120
    classifiers=[
121
        'Development Status :: 5 - Production/Stable',
122
        'Environment :: Console :: Curses',
123
        'Environment :: Web Environment',
124
        'Framework :: Bottle',
125
        'Intended Audience :: Developers',
126
        'Intended Audience :: End Users/Desktop',
127
        'Intended Audience :: System Administrators',
128
        'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)',
129
        'Operating System :: OS Independent',
130
        'Programming Language :: Python :: 2',
131
        'Programming Language :: Python :: 2.7',
132
        'Programming Language :: Python :: 3',
133
        'Programming Language :: Python :: 3.4',
134
        'Programming Language :: Python :: 3.5',
135
        'Programming Language :: Python :: 3.6',
136
        'Topic :: System :: Monitoring'
137
    ]
138
)
139