Test Failed
Push — master ( cc9054...a8608f )
by Nicolas
03:40
created

setup.get_install_extras_require()   B

Complexity

Conditions 3

Size

Total Lines 42
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 37
nop 0
dl 0
loc 42
rs 8.9919
c 0
b 0
f 0
1
#!/usr/bin/env python
2
3
import builtins
4
import glob
5
import os
6
import re
7
import sys
8
9
from setuptools import Command, setup
10
11
# If the minimal Python version is changed then do not forget to change it in:
12
# - ./pyproject.toml
13
# - .github/workflows/test.yml
14
if not (sys.version_info >= (3, 8)):
15
    print('Glances requires at least Python 3.8 to run.')
16
    sys.exit(1)
17
18
# Global functions
19
##################
20
21
with builtins.open(os.path.join('glances', '__init__.py'), encoding='utf-8') as f:
22
    version = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", f.read(), re.M).group(1)
23
24
if not version:
25
    raise RuntimeError('Cannot find Glances version information.')
26
27
with builtins.open('README.rst', encoding='utf-8') as f:
28
    long_description = f.read()
29
30
31
def get_data_files():
32
    return [
33
        (
34
            'share/doc/glances',
35
            ['AUTHORS', 'COPYING', 'NEWS.rst', 'README.rst', "SECURITY.md", 'CONTRIBUTING.md', 'conf/glances.conf'],
36
        ),
37
        ('share/man/man1', ['docs/man/glances.1']),
38
    ]
39
40
41
def get_install_requires():
42
    required = []
43
    with open('requirements.txt') as f:
44
        required = f.read().splitlines()
45
46
    # On Windows, install WebUI by default
47
    if sys.platform.startswith('win'):
48
        required.append('fastapi>=0.82.0')
49
        required.append('uvicorn')
50
        required.append('jinja2')
51
        required.append('requests')
52
53
    return required
54
55
56
def get_install_extras_require():
57
    extras_require = {
58
        'action': ['chevron'],
59
        'browser': ['zeroconf>=0.19.1'],
60
        'cloud': ['requests'],
61
        'containers': ['docker>=6.1.1', 'python-dateutil', 'six', 'podman', 'packaging'],
62
        'export': [
63
            'bernhard',
64
            'cassandra-driver',
65
            'elasticsearch',
66
            'graphitesender',
67
            'ibmcloudant',
68
            'influxdb>=1.0.0',
69
            'influxdb-client',
70
            'pymongo',
71
            'kafka-python',
72
            'pika',
73
            'paho-mqtt',
74
            'potsdb',
75
            'prometheus_client',
76
            'pyzmq',
77
            'statsd',
78
        ],
79
        'gpu': ['nvidia-ml-py'],
80
        'graph': ['pygal'],
81
        'ip': ['netifaces'],
82
        'raid': ['pymdstat'],
83
        'smart': ['pySMART.smartx'],
84
        'snmp': ['pysnmp'],
85
        'sparklines': ['sparklines'],
86
        'web': ['fastapi>=0.82.0', 'uvicorn', 'jinja2', 'requests'],
87
        'wifi': ['wifi'],
88
    }
89
    if sys.platform.startswith('linux'):
90
        extras_require['sensors'] = ['batinfo']
91
92
    # Add automatically the 'all' target
93
    extras_require['all'] = []
94
    for p in extras_require.values():
95
        extras_require['all'].extend(p)
96
97
    return extras_require
98
99
100
class tests(Command):
101
    user_options = []
102
103
    def initialize_options(self):
104
        pass
105
106
    def finalize_options(self):
107
        pass
108
109
    def run(self):
110
        import subprocess
111
        import sys
112
113
        for t in glob.glob('unittest-core.py'):
114
            ret = subprocess.call([sys.executable, t]) != 0
115
            if ret != 0:
116
                raise SystemExit(ret)
117
        raise SystemExit(0)
118
119
120
# Setup !
121
122
setup(
123
    name='Glances',
124
    version=version,
125
    description="A cross-platform curses-based monitoring tool",
126
    long_description=long_description,
127
    author='Nicolas Hennion',
128
    author_email='[email protected]',
129
    url='https://github.com/nicolargo/glances',
130
    license='LGPLv3',
131
    keywords="cli curses monitoring system",
132
    python_requires=">=3.8",
133
    install_requires=get_install_requires(),
134
    extras_require=get_install_extras_require(),
135
    packages=['glances'],
136
    include_package_data=True,
137
    data_files=get_data_files(),
138
    cmdclass={'test': tests},
139
    test_suite="unittest-core.py",
140
    entry_points={"console_scripts": ["glances=glances:main"]},
141
    classifiers=[
142
        'Development Status :: 5 - Production/Stable',
143
        'Environment :: Console :: Curses',
144
        'Environment :: Web Environment',
145
        'Framework :: FastAPI',
146
        'Intended Audience :: Developers',
147
        'Intended Audience :: End Users/Desktop',
148
        'Intended Audience :: System Administrators',
149
        'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)',
150
        'Operating System :: OS Independent',
151
        'Programming Language :: Python :: 3',
152
        'Programming Language :: Python :: 3.8',
153
        'Programming Language :: Python :: 3.9',
154
        'Programming Language :: Python :: 3.10',
155
        'Programming Language :: Python :: 3.11',
156
        'Programming Language :: Python :: 3.12',
157
        'Topic :: System :: Monitoring',
158
    ],
159
)
160