1
- PORT? =8008
2
- LASTTAG = $(shell git describe --tags --abbrev=0)
1
+ PORT ?= 8008
2
+ VENV := venv/bin
3
+ VENV_DEV := venv-dev/bin
4
+ VENV_MIN := venv-min/bin
5
+ CONF := conf/glances.conf
6
+ PIP := $(VENV ) /pip
7
+ PYTHON := $(VENV ) /python
8
+ UNITTEST := unittest
9
+
10
+ DOCKER_BUILD := docker buildx build
11
+ DOCKER_RUN := docker run
12
+ DOCKERFILE_UBUNTU := docker-files/ubuntu.Dockerfile
13
+ DOCKERFILE_ALPINE := docker-files/alpine.Dockerfile
14
+ PODMAN_SOCK ?= /run/user/$(shell id -u) /podman/podman.sock
15
+ DOCKER_SOCK ?= /var/run/docker.sock
16
+ DOCKER_SOCKS := -v $(PODMAN_SOCK ) :$(PODMAN_SOCK ) :ro -v $(DOCKER_SOCK ) :$(DOCKER_SOCK ) :ro
17
+ DOCKER_OPTS := --rm -e TZ="${TZ}" -e GLANCES_OPT="" --pid host --network host
18
+
19
+ LASTTAG = $(shell git describe --tags --abbrev=0)
3
20
4
21
# if the command is only `make`, the default tasks will be the printing of the help.
5
22
.DEFAULT_GOAL := help
6
23
7
- .PHONY : help
24
+ .PHONY : help test docs docs-server venv venv-min venv-dev
25
+
8
26
help : # # List all make commands available
9
- @grep -E ' ^[\.a-zA-Z_%-]+:.*?## .*$$' $(MAKEFILE_LIST ) | awk -F " :" ' {print $1}' | grep -v % | sed ' s/\\//g' | sort | awk ' BEGIN {FS = ":[^:]*?##"}; {printf "\033[1;34mmake %-50s\033[0m %s\n", $$1, $$2}'
27
+ @grep -E ' ^[\.a-zA-Z_%-]+:.*?## .*$$' $(MAKEFILE_LIST ) | \
28
+ awk -F " :" ' {print $1}' | \
29
+ grep -v % | \
30
+ sed ' s/\\//g' | \
31
+ sort | \
32
+ awk ' BEGIN {FS = ":[^:]*?##"}; {printf "\033[1;34mmake %-50s\033[0m %s\n", $$1, $$2}'
10
33
11
34
# ===================================================================
12
35
# Virtualenv
@@ -24,117 +47,117 @@ venv-full-python: ## Install Python 3 venv
24
47
virtualenv -p /usr/bin/python3 venv
25
48
26
49
venv-full : venv-python # # Install Python 3 run-time dependencies
27
- ./venv/bin/pip install -r requirements.txt
28
- ./venv/bin/pip install -r optional-requirements.txt
50
+ $( PIP ) install -r requirements.txt
51
+ $( PIP ) install -r optional-requirements.txt
29
52
30
53
venv-full-upgrade : # # Upgrade Python 3 run-time dependencies
31
- ./venv/bin/pip install --upgrade pip
32
- ./venv/bin/pip install --upgrade -r requirements.txt
33
- ./venv/bin/pip install --upgrade -r optional-requirements.txt
54
+ $( PIP ) install --upgrade pip
55
+ $( PIP ) install --upgrade -r requirements.txt
56
+ $( PIP ) install --upgrade -r optional-requirements.txt
34
57
35
58
# For minimal installation (without optional dependencies)
36
59
37
60
venv-min-python : # # Install Python 3 venv minimal
38
61
virtualenv -p /usr/bin/python3 venv-min
39
62
40
63
venv-min : venv-min-python # # Install Python 3 minimal run-time dependencies
41
- ./venv-min/bin /pip install -r requirements.txt
64
+ $( VENV_MIN ) /pip install -r requirements.txt
42
65
43
66
venv-min-upgrade : # # Upgrade Python 3 minimal run-time dependencies
44
- ./venv-min/bin /pip install --upgrade pip
45
- ./venv-min/bin /pip install --upgrade -r requirements.txt
67
+ $( VENV_MIN ) /pip install --upgrade pip
68
+ $( VENV_MIN ) /pip install --upgrade -r requirements.txt
46
69
47
70
# For development
48
71
49
72
venv-dev-python : # # Install Python 3 venv
50
73
virtualenv -p /usr/bin/python3 venv-dev
51
74
52
75
venv-dev : venv-python # # Install Python 3 dev dependencies
53
- ./venv-dev/bin /pip install -r dev-requirements.txt
54
- ./venv-dev/bin /pip install -r doc-requirements.txt
55
- ./venv-dev/bin /pre-commit install --hook-type pre-commit
76
+ $( VENV_DEV ) /pip install -r dev-requirements.txt
77
+ $( VENV_DEV ) /pip install -r doc-requirements.txt
78
+ $( VENV_DEV ) /pre-commit install --hook-type pre-commit
56
79
57
80
venv-dev-upgrade : # # Upgrade Python 3 dev dependencies
58
- ./venv-dev/bin /pip install --upgrade pip
59
- ./venv-dev/bin /pip install --upgrade -r dev-requirements.txt
60
- ./venv-dev/bin /pip install --upgrade -r doc-requirements.txt
81
+ $( VENV_DEV ) /pip install --upgrade pip
82
+ $( VENV_DEV ) /pip install --upgrade -r dev-requirements.txt
83
+ $( VENV_DEV ) /pip install --upgrade -r doc-requirements.txt
61
84
62
85
# ===================================================================
63
86
# Tests
64
87
# ===================================================================
65
88
66
89
test-core : # # Run core unit tests
67
- ./venv/bin/python ./unittest -core.py
90
+ $( PYTHON ) $( UNITTEST ) -core.py
68
91
69
92
test-restful : # # Run Restful unit tests
70
- ./venv/bin/python ./unittest -restful.py
93
+ $( PYTHON ) $( UNITTEST ) -restful.py
71
94
72
95
test-xmlrpc : # # Run XMLRPC unit tests
73
- ./venv/bin/python ./unittest -xmlrpc.py
96
+ $( PYTHON ) $( UNITTEST ) -xmlrpc.py
74
97
75
98
test : test-core test-restful test-xmlrpc # # Run unit tests
76
99
77
100
test-with-upgrade : venv-upgrade venv-dev-upgrade test # # Upgrade deps and run unit tests
78
101
79
102
test-min : # # Run core unit tests in minimal environment
80
- ./venv-min/bin/ python ./unittest -core.py
103
+ $( VENV_MIN ) / python $( UNITTEST ) -core.py
81
104
82
105
test-min-with-upgrade : venv-min-upgrade # # Upgrade deps and run unit tests in minimal environment
83
- ./venv-min/bin/ python ./unittest -core.py
106
+ $( VENV_MIN ) / python $( UNITTEST ) -core.py
84
107
85
108
# ===================================================================
86
109
# Linters, profilers and cyber security
87
110
# ===================================================================
88
111
89
112
format : # # Format the code
90
- ./venv-dev/bin /python -m ruff format .
113
+ $( VENV_DEV ) /python -m ruff format .
91
114
92
115
lint : # # Lint the code.
93
- ./venv-dev/bin /python -m ruff check . --fix
116
+ $( VENV_DEV ) /python -m ruff check . --fix
94
117
95
118
codespell : # # Run codespell to fix common misspellings in text files
96
- ./venv-dev/bin /codespell -S .git,./docs/_build,./Glances.egg-info,./venv* ,./glances/outputs,* .svg -L hart,bu,te,statics -w
119
+ $( VENV_DEV ) /codespell -S .git,./docs/_build,./Glances.egg-info,./venv* ,./glances/outputs,* .svg -L hart,bu,te,statics -w
97
120
98
121
semgrep : # # Run semgrep to find bugs and enforce code standards
99
- ./venv-dev/bin /semgrep scan --config=auto
122
+ $( VENV_DEV ) /semgrep scan --config=auto
100
123
101
124
profiling-gprof : # # Callgraph profiling (need "apt install graphviz")
102
125
@echo " Start Glances for 30 iterations (more or less 1 mins, please do not exit !)"
103
126
sleep 3
104
- ./venv/bin/python -m cProfile -o ./glances.cprof ./run.py --stop-after 30
105
- ./venv-dev/bin /gprof2dot -f pstats ./glances.cprof | dot -Tsvg -o ./docs/_static/glances-cgraph.svg
127
+ $( PYTHON ) -m cProfile -o ./glances.cprof ./run.py --stop-after 30
128
+ $( VENV_DEV ) /gprof2dot -f pstats ./glances.cprof | dot -Tsvg -o ./docs/_static/glances-cgraph.svg
106
129
rm -f ./glances.cprof
107
130
108
131
profiling-pyinstrument : # # PyInstrument profiling
109
132
@echo " Start Glances for 30 iterations (more or less 1 mins, please do not exit !)"
110
133
sleep 3
111
- ./venv/bin/pip install pyinstrument
112
- ./venv/bin/python -m pyinstrument -r html -o ./docs/_static/glances-pyinstrument.html -m glances --stop-after 30
134
+ $( PIP ) install pyinstrument
135
+ $( PYTHON ) -m pyinstrument -r html -o ./docs/_static/glances-pyinstrument.html -m glances --stop-after 30
113
136
114
137
profiling-pyspy : # # Flame profiling (currently not compatible with Python 3.12)
115
138
@echo " Start Glances for 30 iterations (more or less 1 mins, please do not exit !)"
116
139
sleep 3
117
- ./venv-dev/bin/ py-spy record -o ./docs/_static/glances-flame.svg -d 60 -s -- ./venv/bin/python ./run.py --stop-after 30
140
+ $( VENV_DEV ) / py-spy record -o ./docs/_static/glances-flame.svg -d 60 -s -- $( PYTHON ) ./run.py --stop-after 30
118
141
119
142
profiling : profiling-gprof profiling-pyinstrument profiling-pyspy # # Profiling of the Glances software
120
143
121
144
trace-malloc : # # Trace the malloc() calls
122
145
@echo " Malloc test is running, please wait ~30 secondes..."
123
- ./venv/bin/python -m glances -C ./conf/glances.conf --trace-malloc --stop-after 15 --quiet
146
+ $( PYTHON ) -m glances -C $( CONF ) --trace-malloc --stop-after 15 --quiet
124
147
125
148
memory-leak : # # Profile memory leaks
126
- ./venv/bin/python -m glances -C ./conf/glances.conf --memory-leak
149
+ $( PYTHON ) -m glances -C $( CONF ) --memory-leak
127
150
128
151
memory-profiling : # # Profile memory usage
129
152
@echo " It's a very long test (~4 hours)..."
130
153
rm -f mprofile_* .dat
131
154
@echo " 1/2 - Start memory profiling with the history option enable"
132
- ./venv-dev/bin/ mprof run -T 1 -C run.py -C ./conf/glances.conf --stop-after 2400 --quiet
133
- ./venv-dev/bin /mprof plot --output ./docs/_static/glances-memory-profiling-with-history.png
155
+ $( VENV_DEV ) / mprof run -T 1 -C run.py -C $( CONF ) --stop-after 2400 --quiet
156
+ $( VENV_DEV ) /mprof plot --output ./docs/_static/glances-memory-profiling-with-history.png
134
157
rm -f mprofile_* .dat
135
158
@echo " 2/2 - Start memory profiling with the history option disable"
136
- ./venv-dev/bin/ mprof run -T 1 -C run.py -C ./conf/glances.conf --disable-history --stop-after 2400 --quiet
137
- ./venv-dev/bin /mprof plot --output ./docs/_static/glances-memory-profiling-without-history.png
159
+ $( VENV_DEV ) / mprof run -T 1 -C run.py -C $( CONF ) --disable-history --stop-after 2400 --quiet
160
+ $( VENV_DEV ) /mprof plot --output ./docs/_static/glances-memory-profiling-without-history.png
138
161
rm -f mprofile_* .dat
139
162
140
163
# Trivy installation: https://aquasecurity.github.io/trivy/latest/getting-started/installation/
@@ -146,7 +169,7 @@ trivy: ## Run Trivy to find vulnerabilities in container images
146
169
# ===================================================================
147
170
148
171
docs : # # Create the documentation
149
- ./venv/bin/python -m glances -C ./conf/glances.conf --api-doc > ./docs/api.rst
172
+ $( PYTHON ) -m glances -C $( CONF ) --api-doc > ./docs/api.rst
150
173
cd docs && ./build.sh && cd ..
151
174
152
175
docs-server : docs # # Start a Web server to serve the documentation
@@ -181,7 +204,7 @@ webui-audit-fix: ## Fix audit the Web UI
181
204
182
205
flatpak : venv-dev-upgrade # # Generate FlatPack JSON file
183
206
git clone https://github.com/flatpak/flatpak-builder-tools.git
184
- ./venv/bin/python ./flatpak-builder-tools/pip/flatpak-pip-generator glances
207
+ $( PYTHON ) ./flatpak-builder-tools/pip/flatpak-pip-generator glances
185
208
rm -rf ./flatpak-builder-tools
186
209
@echo " Now follow: https://github.com/flathub/flathub/wiki/App-Submission"
187
210
@@ -201,91 +224,91 @@ docker: docker-alpine docker-ubuntu ## Generate local docker images
201
224
docker-alpine : docker-alpine-full docker-alpine-minimal docker-alpine-dev # # Generate local docker images (Alpine)
202
225
203
226
docker-alpine-full : # # Generate local docker image (Alpine full)
204
- docker buildx build --target full -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-full .
227
+ $( DOCKER_BUILD ) --target full -f $( DOCKERFILE_ALPINE ) -t glances:local-alpine-full .
205
228
206
229
docker-alpine-minimal : # # Generate local docker image (Alpine minimal)
207
- docker buildx build --target minimal -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-minimal .
230
+ $( DOCKER_BUILD ) --target minimal -f $( DOCKERFILE_ALPINE ) -t glances:local-alpine-minimal .
208
231
209
232
docker-alpine-dev : # # Generate local docker image (Alpine dev)
210
- docker buildx build --target dev -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-dev .
233
+ $( DOCKER_BUILD ) --target dev -f $( DOCKERFILE_ALPINE ) -t glances:local-alpine-dev .
211
234
212
235
docker-ubuntu : docker-ubuntu-full docker-ubuntu-minimal docker-ubuntu-dev # # Generate local docker images (Ubuntu)
213
236
214
237
docker-ubuntu-full : # # Generate local docker image (Ubuntu full)
215
- docker buildx build --target full -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-full .
238
+ $( DOCKER_BUILD ) --target full -f $( DOCKERFILE_UBUNTU ) -t glances:local-ubuntu-full .
216
239
217
240
docker-ubuntu-minimal : # # Generate local docker image (Ubuntu minimal)
218
- docker buildx build --target minimal -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-minimal .
241
+ $( DOCKER_BUILD ) --target minimal -f $( DOCKERFILE_UBUNTU ) -t glances:local-ubuntu-minimal .
219
242
220
243
docker-ubuntu-dev : # # Generate local docker image (Ubuntu dev)
221
- docker buildx build --target dev -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-dev .
244
+ $( DOCKER_BUILD ) --target dev -f $( DOCKERFILE_UBUNTU ) -t glances:local-ubuntu-dev .
222
245
223
246
# ===================================================================
224
247
# Run
225
248
# ===================================================================
226
249
227
250
run : # # Start Glances in console mode (also called standalone)
228
- ./venv/bin/python -m glances -C ./conf/glances.conf
251
+ $( PYTHON ) -m glances -C $( CONF )
229
252
230
253
run-debug : # # Start Glances in debug console mode (also called standalone)
231
- ./venv/bin/python -m glances -C ./conf/glances.conf -d
254
+ $( PYTHON ) -m glances -C $( CONF ) -d
232
255
233
256
run-local-conf : # # Start Glances in console mode with the system conf file
234
- ./venv/bin/python -m glances
257
+ $( PYTHON ) -m glances
235
258
236
259
run-local-conf-hide-public : # # Start Glances in console mode with the system conf file and hide public information
237
- ./venv/bin/python -m glances --hide-public-info
260
+ $( PYTHON ) -m glances --hide-public-info
238
261
239
262
run-min : # # Start minimal Glances in console mode (also called standalone)
240
- ./venv-min/bin/ python -m glances -C ./conf/glances.conf
263
+ $( VENV_MIN ) / python -m glances -C $( CONF )
241
264
242
265
run-min-debug : # # Start minimal Glances in debug console mode (also called standalone)
243
- ./venv-min/bin/ python -m glances -C ./conf/glances.conf -d
266
+ $( VENV_MIN ) / python -m glances -C $( CONF ) -d
244
267
245
268
run-min-local-conf : # # Start minimal Glances in console mode with the system conf file
246
- ./venv-min/bin /python -m glances
269
+ $( VENV_MIN ) /python -m glances
247
270
248
271
run-docker-alpine-minimal : # # Start Glances Alpine Docker minimal in console mode
249
- docker run --rm -e TZ= " ${TZ} " -e GLANCES_OPT= " " -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-alpine-minimal
272
+ $( DOCKER_RUN ) $( DOCKER_OPTS ) $( DOCKER_SOCKS ) -it glances:local-alpine-minimal
250
273
251
274
run-docker-alpine-full : # # Start Glances Alpine Docker full in console mode
252
- docker run --rm -e TZ= " ${TZ} " -e GLANCES_OPT= " " -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-alpine-full
275
+ $( DOCKER_RUN ) $( DOCKER_OPTS ) $( DOCKER_SOCKS ) -it glances:local-alpine-full
253
276
254
277
run-docker-alpine-dev : # # Start Glances Alpine Docker dev in console mode
255
- docker run --rm -e TZ= " ${TZ} " -e GLANCES_OPT= " " -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-alpine-dev
278
+ $( DOCKER_RUN ) $( DOCKER_OPTS ) $( DOCKER_SOCKS ) -it glances:local-alpine-dev
256
279
257
280
run-docker-ubuntu-minimal : # # Start Glances Ubuntu Docker minimal in console mode
258
- docker run --rm -e TZ= " ${TZ} " -e GLANCES_OPT= " " -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-ubuntu-minimal
281
+ $( DOCKER_RUN ) $( DOCKER_OPTS ) $( DOCKER_SOCKS ) -it glances:local-ubuntu-minimal
259
282
260
283
run-docker-ubuntu-full : # # Start Glances Ubuntu Docker full in console mode
261
- docker run --rm -e TZ= " ${TZ} " -e GLANCES_OPT= " " -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-ubuntu-full
284
+ $( DOCKER_RUN ) $( DOCKER_OPTS ) $( DOCKER_SOCKS ) -it glances:local-ubuntu-full
262
285
263
286
run-docker-ubuntu-dev : # # Start Glances Ubuntu Docker dev in console mode
264
- docker run --rm -e TZ= " ${TZ} " -e GLANCES_OPT= " " -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-ubuntu-dev
287
+ $( DOCKER_RUN ) $( DOCKER_OPTS ) $( DOCKER_SOCKS ) -it glances:local-ubuntu-dev
265
288
266
289
run-webserver : # # Start Glances in Web server mode
267
- ./venv/bin/python -m glances -C ./conf/glances.conf -w
290
+ $( PYTHON ) -m glances -C $( CONF ) -w
268
291
269
292
run-webserver-local-conf : # # Start Glances in Web server mode with the system conf file
270
- ./venv/bin/python -m glances -w
293
+ $( PYTHON ) -m glances -w
271
294
272
295
run-webserver-local-conf-hide-public : # # Start Glances in Web server mode with the system conf file and hide public info
273
- ./venv/bin/python -m glances -w --hide-public-info
296
+ $( PYTHON ) -m glances -w --hide-public-info
274
297
275
298
run-restapiserver : # # Start Glances in REST API server mode
276
- ./venv/bin/python -m glances -C ./conf/glances.conf -w --disable-webui
299
+ $( PYTHON ) -m glances -C $( CONF ) -w --disable-webui
277
300
278
301
run-server : # # Start Glances in server mode (RPC)
279
- ./venv/bin/python -m glances -C ./conf/glances.conf -s
302
+ $( PYTHON ) -m glances -C $( CONF ) -s
280
303
281
304
run-client : # # Start Glances in client mode (RPC)
282
- ./venv/bin/python -m glances -C ./conf/glances.conf -c localhost
305
+ $( PYTHON ) -m glances -C $( CONF ) -c localhost
283
306
284
307
run-browser : # # Start Glances in browser mode (RPC)
285
- ./venv/bin/python -m glances -C ./conf/glances.conf --browser
308
+ $( PYTHON ) -m glances -C $( CONF ) --browser
286
309
287
310
run-issue : # # Start Glances in issue mode
288
- ./venv/bin/python -m glances -C ./conf/glances.conf --issue
311
+ $( PYTHON ) -m glances -C $( CONF ) --issue
289
312
290
313
run-multipass : # # Install and start Glances in a VM (only available on Ubuntu with multipass already installed)
291
314
multipass launch -n glances-on-lts lts
@@ -295,6 +318,4 @@ run-multipass: ## Install and start Glances in a VM (only available on Ubuntu wi
295
318
multipass delete glances-on-lts
296
319
297
320
show-version : # # Show Glances version number
298
- ./venv/bin/python -m glances -C ./conf/glances.conf -V
299
-
300
- .PHONY : test docs docs-server venv venv-min venv-dev
321
+ $(PYTHON ) -m glances -C $(CONF ) -V
0 commit comments