setup.tests.initialize_options()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 1
dl 0
loc 2
rs 10
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')
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.131.0'],
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', '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.update({'all': [i[0] for i in extras_require.values()]})
94
95
    return extras_require
96
97
98
class tests(Command):
99
    user_options = []
100
101
    def initialize_options(self):
102
        pass
103
104
    def finalize_options(self):
105
        pass
106
107
    def run(self):
108
        import subprocess
109
        import sys
110
111
        for t in glob.glob('unittest-core.py'):
112
            ret = subprocess.call([sys.executable, t]) != 0
113
            if ret != 0:
114
                raise SystemExit(ret)
115
        raise SystemExit(0)
116
117
118
# Setup !
119
120
setup(
121
    name='Glances',
122
    version=version,
123
    description="A cross-platform curses-based monitoring tool",
124
    long_description=long_description,
125
    author='Nicolas Hennion',
126
    author_email='[email protected]',
127
    url='https://github.com/nicolargo/glances',
128
    license='LGPLv3',
129
    keywords="cli curses monitoring system",
130
    python_requires=">=3.8",
131
    install_requires=get_install_requires(),
132
    extras_require=get_install_extras_require(),
133
    packages=['glances'],
134
    include_package_data=True,
135
    data_files=get_data_files(),
136
    cmdclass={'test': tests},
137
    test_suite="unittest-core.py",
138
    entry_points={"console_scripts": ["glances=glances:main"]},
139
    classifiers=[
140
        'Development Status :: 5 - Production/Stable',
141
        'Environment :: Console :: Curses',
142
        'Environment :: Web Environment',
143
        'Framework :: FastAPI',
144
        'Intended Audience :: Developers',
145
        'Intended Audience :: End Users/Desktop',
146
        'Intended Audience :: System Administrators',
147
        'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)',
148
        'Operating System :: OS Independent',
149
        'Programming Language :: Python :: 3',
150
        'Programming Language :: Python :: 3.8',
151
        'Programming Language :: Python :: 3.9',
152
        'Programming Language :: Python :: 3.10',
153
        'Programming Language :: Python :: 3.11',
154
        'Programming Language :: Python :: 3.12',
155
        'Topic :: System :: Monitoring',
156
    ],
157
)
158