1
1
PORT ?= 8008
2
- VENV := venv/bin
3
- VENV_DEV := venv-dev/bin
4
- VENV_MIN := venv-min/bin
2
+ venv_full : = venv/bin
3
+ venv_dev := venv-dev/bin
4
+ venv_min := venv-min/bin
5
5
CONF := conf/glances.conf
6
- PIP := $(VENV ) /pip
7
- PYTHON := $(VENV ) /python
6
+ PIP := $(venv_full ) /pip
7
+ PYTHON := $(venv_full ) /python
8
8
LASTTAG = $(shell git describe --tags --abbrev=0)
9
9
10
+ VENV_TYPES := full min dev
11
+ VENV_PYTHON := $(VENV_TYPES:%=venv-%-python )
12
+ VENV_UPG := $(VENV_TYPES:%=venv-%-upgrade )
13
+ VENV_DEPS := $(VENV_TYPES:%=venv-% )
14
+ VENV_INST_UPG := $(VENV_DEPS ) $(VENV_UPG )
15
+
10
16
IMAGES_TYPES := full minimal dev
11
17
DISTROS := alpine ubuntu
12
18
alpine_images := $(IMAGES_TYPES:%=docker-alpine-% )
@@ -38,52 +44,50 @@ help: ## List all make commands available
38
44
# Virtualenv
39
45
# ===================================================================
40
46
41
- venv-python : venv-full-python venv-min-python venv-dev-python # # Install all Python 3 venv
47
+ venv-% -upgrade : UPGRADE = --upgrade
42
48
43
- venv : venv-full venv-min venv-dev # # Install all Python 3 dependencies
49
+ define DEFINE_VARS_FOR_TYPE
50
+ venv-$(TYPE ) venv-$(TYPE ) -upgrade: VIRTUAL_ENV = $(venv_$(TYPE ) )
51
+ endef
44
52
45
- venv-upgrade : venv-full-upgrade venv-min-upgrade venv-dev-upgrade # # Upgrade all Python 3 dependencies
53
+ $(foreach TYPE,$(VENV_TYPES),$(eval $(DEFINE_VARS_FOR_TYPE)))
46
54
47
- # For full installation (with optional dependencies)
55
+ $(VENV_PYTHON ) : venv-% -python:
56
+ virtualenv -p /usr/bin/python3 $(if $(filter full,$* ) ,venv,venv-$* )
48
57
49
- venv-full-python : # # Install Python 3 venv
50
- virtualenv -p /usr/bin/python3 venv
58
+ $(VENV_INST_UPG ) : venv-% :
59
+ $(if $(UPGRADE ) ,$(VIRTUAL_ENV ) /install install --upgrade pip,)
60
+ $(foreach REQ,$(REQS ) , $(VIRTUAL_ENV ) /pip install $(UPGRADE ) -r $(REQ ) ;)
61
+ $(if $(PRE_COMMIT ) ,$(VIRTUAL_ENV ) /pre-commit install --hook-type pre-commit,)
62
+
63
+ venv-python : $(VENV_PYTHON ) # # Install all Python 3 venv
64
+ venv : $(VENV_DEPS ) # # Install all Python 3 dependencies
65
+ venv-upgrade : $(VENV_UPG ) # # Upgrade all Python 3 dependencies
66
+
67
+ # For full installation (with optional dependencies)
51
68
52
- venv-full : venv-python # # Install Python 3 run-time dependencies
53
- $(PIP ) install -r requirements.txt
54
- $(PIP ) install -r optional-requirements.txt
69
+ venv-full venv-full-upgrade : REQS = requirements.txt optional-requirements.txt
55
70
71
+ venv-full-python : # # Install Python 3 venv
72
+ venv-full : venv-python # # Install Python 3 run-time
56
73
venv-full-upgrade : # # Upgrade Python 3 run-time dependencies
57
- $(PIP ) install --upgrade pip
58
- $(PIP ) install --upgrade -r requirements.txt
59
- $(PIP ) install --upgrade -r optional-requirements.txt
60
74
61
75
# For minimal installation (without optional dependencies)
62
76
63
- venv-min-python : # # Install Python 3 venv minimal
64
- virtualenv -p /usr/bin/python3 venv-min
77
+ venv-min venv-min-upgrade : REQS = requirements.txt
65
78
79
+ venv-min-python : # # Install Python 3 venv minimal
66
80
venv-min : venv-min-python # # Install Python 3 minimal run-time dependencies
67
- $(VENV_MIN ) /pip install -r requirements.txt
68
-
69
81
venv-min-upgrade : # # Upgrade Python 3 minimal run-time dependencies
70
- $(VENV_MIN ) /pip install --upgrade pip
71
- $(VENV_MIN ) /pip install --upgrade -r requirements.txt
72
82
73
83
# For development
74
84
75
- venv-dev-python : # # Install Python 3 venv
76
- virtualenv -p /usr/bin/python3 venv-dev
85
+ venv-dev venv-dev-upgrade : REQS = dev-requirements.txt doc-requirements.txt
86
+ venv-dev : PRE_COMMIT = 1
77
87
88
+ venv-dev-python : # # Install Python 3 venv
78
89
venv-dev : venv-python # # Install Python 3 dev dependencies
79
- $(VENV_DEV ) /pip install -r dev-requirements.txt
80
- $(VENV_DEV ) /pip install -r doc-requirements.txt
81
- $(VENV_DEV ) /pre-commit install --hook-type pre-commit
82
-
83
90
venv-dev-upgrade : # # Upgrade Python 3 dev dependencies
84
- $(VENV_DEV ) /pip install --upgrade pip
85
- $(VENV_DEV ) /pip install --upgrade -r dev-requirements.txt
86
- $(VENV_DEV ) /pip install --upgrade -r doc-requirements.txt
87
91
88
92
# ===================================================================
89
93
# Tests
@@ -101,32 +105,32 @@ test: $(UNIT_TESTS) ## Run unit tests
101
105
test-with-upgrade : venv-upgrade venv-dev-upgrade test # # Upgrade deps and run unit tests
102
106
103
107
test-min : # # Run core unit tests in minimal environment
104
- $(VENV_MIN ) /python unittest-core.py
108
+ $(venv_min ) /python unittest-core.py
105
109
106
110
test-min-with-upgrade : venv-min-upgrade # # Upgrade deps and run unit tests in minimal environment
107
- $(VENV_MIN ) /python unittest-core.py
111
+ $(venv_min ) /python unittest-core.py
108
112
109
113
# ===================================================================
110
114
# Linters, profilers and cyber security
111
115
# ===================================================================
112
116
113
117
format : # # Format the code
114
- $(VENV_DEV ) /python -m ruff format .
118
+ $(venv_dev ) /python -m ruff format .
115
119
116
120
lint : # # Lint the code.
117
- $(VENV_DEV ) /python -m ruff check . --fix
121
+ $(venv_dev ) /python -m ruff check . --fix
118
122
119
123
codespell : # # Run codespell to fix common misspellings in text files
120
- $(VENV_DEV ) /codespell -S .git,./docs/_build,./Glances.egg-info,./venv* ,./glances/outputs,* .svg -L hart,bu,te,statics -w
124
+ $(venv_dev ) /codespell -S .git,./docs/_build,./Glances.egg-info,./venv* ,./glances/outputs,* .svg -L hart,bu,te,statics -w
121
125
122
126
semgrep : # # Run semgrep to find bugs and enforce code standards
123
- $(VENV_DEV ) /semgrep scan --config=auto
127
+ $(venv_dev ) /semgrep scan --config=auto
124
128
125
129
profiling-gprof : # # Callgraph profiling (need "apt install graphviz")
126
130
@echo " Start Glances for 30 iterations (more or less 1 mins, please do not exit !)"
127
131
sleep 3
128
132
$(PYTHON ) -m cProfile -o ./glances.cprof ./run.py --stop-after 30
129
- $(VENV_DEV ) /gprof2dot -f pstats ./glances.cprof | dot -Tsvg -o ./docs/_static/glances-cgraph.svg
133
+ $(venv_dev ) /gprof2dot -f pstats ./glances.cprof | dot -Tsvg -o ./docs/_static/glances-cgraph.svg
130
134
rm -f ./glances.cprof
131
135
132
136
profiling-pyinstrument : # # PyInstrument profiling
@@ -138,7 +142,7 @@ profiling-pyinstrument: ## PyInstrument profiling
138
142
profiling-pyspy : # # Flame profiling (currently not compatible with Python 3.12)
139
143
@echo " Start Glances for 30 iterations (more or less 1 mins, please do not exit !)"
140
144
sleep 3
141
- $(VENV_DEV ) /py-spy record -o ./docs/_static/glances-flame.svg -d 60 -s -- $(PYTHON ) ./run.py --stop-after 30
145
+ $(venv_dev ) /py-spy record -o ./docs/_static/glances-flame.svg -d 60 -s -- $(PYTHON ) ./run.py --stop-after 30
142
146
143
147
profiling : profiling-gprof profiling-pyinstrument profiling-pyspy # # Profiling of the Glances software
144
148
@@ -153,12 +157,12 @@ memory-profiling: ## Profile memory usage
153
157
@echo " It's a very long test (~4 hours)..."
154
158
rm -f mprofile_* .dat
155
159
@echo " 1/2 - Start memory profiling with the history option enable"
156
- $(VENV_DEV ) /mprof run -T 1 -C run.py -C $(CONF ) --stop-after 2400 --quiet
157
- $(VENV_DEV ) /mprof plot --output ./docs/_static/glances-memory-profiling-with-history.png
160
+ $(venv_dev ) /mprof run -T 1 -C run.py -C $(CONF ) --stop-after 2400 --quiet
161
+ $(venv_dev ) /mprof plot --output ./docs/_static/glances-memory-profiling-with-history.png
158
162
rm -f mprofile_* .dat
159
163
@echo " 2/2 - Start memory profiling with the history option disable"
160
- $(VENV_DEV ) /mprof run -T 1 -C run.py -C $(CONF ) --disable-history --stop-after 2400 --quiet
161
- $(VENV_DEV ) /mprof plot --output ./docs/_static/glances-memory-profiling-without-history.png
164
+ $(venv_dev ) /mprof run -T 1 -C run.py -C $(CONF ) --disable-history --stop-after 2400 --quiet
165
+ $(venv_dev ) /mprof plot --output ./docs/_static/glances-memory-profiling-without-history.png
162
166
rm -f mprofile_* .dat
163
167
164
168
# Trivy installation: https://aquasecurity.github.io/trivy/latest/getting-started/installation/
@@ -256,13 +260,13 @@ run-local-conf-hide-public: ## Start Glances in console mode with the system con
256
260
$(PYTHON ) -m glances --hide-public-info
257
261
258
262
run-min : # # Start minimal Glances in console mode (also called standalone)
259
- $(VENV_MIN ) /python -m glances -C $(CONF )
263
+ $(venv_min ) /python -m glances -C $(CONF )
260
264
261
265
run-min-debug : # # Start minimal Glances in debug console mode (also called standalone)
262
- $(VENV_MIN ) /python -m glances -C $(CONF ) -d
266
+ $(venv_min ) /python -m glances -C $(CONF ) -d
263
267
264
268
run-min-local-conf : # # Start minimal Glances in console mode with the system conf file
265
- $(VENV_MIN ) /python -m glances
269
+ $(venv_min ) /python -m glances
266
270
267
271
$(DOCKER_RUNTIMES ) : run-docker-% :
268
272
$(DOCKER_RUN ) $(DOCKER_OPTS ) $(DOCKER_SOCKS ) -it glances:local-$*
0 commit comments