From 658c3563a71c9dd46e9867264b0980e8e4144100 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Wed, 17 May 2023 15:42:39 +0200 Subject: Improve Makefile to split minimal, full and dev virtualenv --- Makefile | 124 +++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 77 insertions(+), 47 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f41f1007..4ffc82b9 100644 --- a/Makefile +++ b/Makefile @@ -8,39 +8,55 @@ LASTTAG = $(shell git describe --tags --abbrev=0) help: ## List all make commands available @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}' -install: ## Open a Web Browser to the installation procedure - sensible-browser "https://github.com/nicolargo/glances#installation" +# =================================================================== +# Virtualenv +# =================================================================== -venv-python: ## Install Python 3 venv - virtualenv -p /usr/bin/python3 venv +venv-python: venv-full-python venv-min-python venv-dev-python ## Install all Python 3 venv -venv-dev: venv-python ## Install Python 3 dev dependencies - ./venv/bin/pip install -r dev-requirements.txt - ./venv/bin/pip install -r doc-requirements.txt +venv: venv-full venv-min venv-dev ## Install all Python 3 dependencies -venv-dev-upgrade: ## Upgrade Python 3 dev dependencies - ./venv/bin/pip install --upgrade pip - ./venv/bin/pip install --upgrade -r dev-requirements.txt - ./venv/bin/pip install --upgrade -r doc-requirements.txt +venv-upgrade: venv-full-upgrade venv-min-upgrade venv-dev-upgrade ## Upgrade all Python 3 dependencies -venv: venv-python ## Install Python 3 run-time dependencies +# For full installation (with optional dependencies) + +venv-full-python: ## Install Python 3 venv + virtualenv -p /usr/bin/python3 venv + +venv-full: venv-python ## Install Python 3 run-time dependencies ./venv/bin/pip install -r requirements.txt ./venv/bin/pip install -r optional-requirements.txt -venv-upgrade: ## Upgrade Python 3 run-time dependencies +venv-full-upgrade: ## Upgrade Python 3 run-time dependencies + ./venv/bin/pip install --upgrade pip ./venv/bin/pip install --upgrade -r requirements.txt ./venv/bin/pip install --upgrade -r optional-requirements.txt # For minimal installation (without optional dependencies) -venv-min-python: ## Install Python 3 venv +venv-min-python: ## Install Python 3 venv minimal virtualenv -p /usr/bin/python3 venv-min -venv-min: venv-min-python ## Install Python 3 run-time dependencies - ./venv/bin/pip install -r requirements.txt +venv-min: venv-min-python ## Install Python 3 minimal run-time dependencies + ./venv-min/bin/pip install -r requirements.txt -venv-min-upgrade: ## Upgrade Python 3 run-time dependencies - ./venv/bin/pip install --upgrade -r requirements.txt +venv-min-upgrade: ## Upgrade Python 3 minimal run-time dependencies + ./venv-min/bin/pip install --upgrade pip + ./venv-min/bin/pip install --upgrade -r requirements.txt + +# For development + +venv-dev-python: ## Install Python 3 venv + virtualenv -p /usr/bin/python3 venv-dev + +venv-dev: venv-python ## Install Python 3 dev dependencies + ./venv-dev/bin/pip install -r dev-requirements.txt + ./venv-dev/bin/pip install -r doc-requirements.txt + +venv-dev-upgrade: ## Upgrade Python 3 dev dependencies + ./venv-dev/bin/pip install --upgrade pip + ./venv-dev/bin/pip install --upgrade -r dev-requirements.txt + ./venv-dev/bin/pip install --upgrade -r doc-requirements.txt # =================================================================== # Tests @@ -51,38 +67,42 @@ test: ## Run unit tests ./venv/bin/python ./unitest-restful.py ./venv/bin/python ./unitest-xmlrpc.py ./venv/bin/python -m black ./glances --check --exclude outputs/static -# ./venv/bin/pyright glances -test-with-upgrade: venv-upgrade venv-dev-upgrade ## Run unit tests +test-with-upgrade: venv-upgrade venv-dev-upgrade ## Upgrade deps and run unit tests ./venv/bin/python ./unitest.py ./venv/bin/python ./unitest-restful.py ./venv/bin/python ./unitest-xmlrpc.py ./venv/bin/python -m black ./glances --check --exclude outputs/static -# ./venv/bin/pyright glances + +test-min: ## Run unit tests in minimal environment + ./venv-min/bin/python ./unitest.py + +test-min-with-upgrade: venv-min-upgrade ## Upgrade deps and run unit tests in minimal environment + ./venv-min/bin/python ./unitest.py # =================================================================== # Linters and profilers # =================================================================== -format: venv-dev-upgrade ## Format the code - @git ls-files '*.py' | xargs ./venv/bin/python -m autopep8 --in-place --jobs 0 --global-config=.flake8 - @git ls-files '*.py' | xargs ./venv/bin/python -m autoflake --in-place --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys --exclude="compat.py,globals.py" - ./venv/bin/python -m black ./glances --exclude outputs/static +format: ## Format the code + @git ls-files 'glances/*.py' | xargs ./venv-dev/bin/python -m autopep8 --in-place --jobs 0 --global-config=.flake8 + @git ls-files 'glances/*.py' | xargs ./venv-dev/bin/python -m autoflake --in-place --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys --exclude="compat.py,globals.py" + ./venv-dev/bin/python -m black ./glances --exclude outputs/static -flake8: venv-dev-upgrade ## Run flake8 linter. - @git ls-files '*.py' | xargs ./venv/bin/python -m flake8 --config=.flake8 +flake8: ## Run flake8 linter. + @git ls-files 'glances/ *.py' | xargs ./venv-dev/bin/python -m flake8 --config=.flake8 -ruff: venv-dev-upgrade ## Run Ruff (fastest) linter. - ./venv/bin/python -m ruff check . --config=./pyproject.toml +ruff: ## Run Ruff (fastest) linter. + ./venv-dev/bin/python -m ruff check . --config=./pyproject.toml -codespell: venv-dev-upgrade ## Run codespell to fix common misspellings in text files - ./venv/bin/codespell -S .git,./docs/_build,./Glances.egg-info,./venv,./glances/outputs,*.svg -L hart,bu,te,statics +codespell: ## Run codespell to fix common misspellings in text files + ./venv-dev/bin/codespell -S .git,./docs/_build,./Glances.egg-info,./venv*,./glances/outputs,*.svg -L hart,bu,te,statics -semgrep: venv-dev-upgrade ## Run semgrep to find bugs and enforce code standards - ./venv/bin/semgrep --config=auto --lang python --use-git-ignore ./glances +semgrep: ## Run semgrep to find bugs and enforce code standards + ./venv-dev/bin/semgrep --config=auto --lang python --use-git-ignore ./glances profiling: ## How to start the profiling of the Glances software - @echo "Please complete and run: sudo ./venv/bin/py-spy record -o ./docs/_static/glances-flame.svg -d 60 -s --pid " + @echo "Please complete and run: sudo ./venv-dev/bin/py-spy record -o ./docs/_static/glances-flame.svg -d 60 -s --pid " trace-malloc: ## Trace the malloc() calls @echo "Malloc test is running, please wait ~30 secondes..." @@ -95,19 +115,19 @@ memory-profiling: ## Profile memory usage @echo "It's a very long test (~4 hours)..." rm -f mprofile_*.dat @echo "1/2 - Start memory profiling with the history option enable" - ./venv/bin/mprof run -T 1 -C run.py -C ./conf/glances.conf --stop-after 2400 --quiet - ./venv/bin/mprof plot --output ./docs/_static/glances-memory-profiling-with-history.png + ./venv-dev/bin/mprof run -T 1 -C run.py -C ./conf/glances.conf --stop-after 2400 --quiet + ./venv-dev/bin/mprof plot --output ./docs/_static/glances-memory-profiling-with-history.png rm -f mprofile_*.dat @echo "2/2 - Start memory profiling with the history option disable" - ./venv/bin/mprof run -T 1 -C run.py -C ./conf/glances.conf --disable-history --stop-after 2400 --quiet - ./venv/bin/mprof plot --output ./docs/_static/glances-memory-profiling-without-history.png + ./venv-dev/bin/mprof run -T 1 -C run.py -C ./conf/glances.conf --disable-history --stop-after 2400 --quiet + ./venv-dev/bin/mprof plot --output ./docs/_static/glances-memory-profiling-without-history.png rm -f mprofile_*.dat # =================================================================== # Docs # =================================================================== -docs: venv-dev-upgrade ## Create the documentation +docs: ## Create the documentation ./venv/bin/python -m glances -C ./conf/glances.conf --api-doc > ./docs/api.rst cd docs && ./build.sh && cd .. @@ -120,17 +140,21 @@ release-note: ## Generate release note @echo "\n" git --no-pager shortlog -s -n $(LASTTAG)..HEAD +install: ## Open a Web Browser to the installation procedure + sensible-browser "https://github.com/nicolargo/glances#installation" + # =================================================================== # WebUI +# Follow ./glances/outputs/static/README.md for more information # =================================================================== -webui: venv-dev-upgrade ## Build the Web UI +webui: ## Build the Web UI cd glances/outputs/static/ && npm ci && npm run build -webui-audit: venv-dev-upgrade ## Audit the Web UI +webui-audit: ## Audit the Web UI cd glances/outputs/static/ && npm audit -webui-audit-fix: venv-dev-upgrade ## Fix audit the Web UI +webui-audit-fix: ## Fix audit the Web UI cd glances/outputs/static/ && npm audit fix && npm ci && npm run build # =================================================================== @@ -147,7 +171,7 @@ flatpak: venv-dev-upgrade ## Generate FlatPack JSON file # Docker # =================================================================== -docker: docker-alpine docker-ubuntu## Generate local docker images +docker: docker-alpine docker-ubuntu ## Generate local docker images docker-alpine: ## Generate local docker images (Alpine) docker build --target full -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-full . @@ -172,6 +196,15 @@ run-debug: ## Start Glances in debug console mode (also called standalone) run-local-conf: ## Start Glances in console mode with the system conf file ./venv/bin/python -m glances +run-min: ## Start minimal Glances in console mode (also called standalone) + ./venv-min/bin/python -m glances -C ./conf/glances.conf + +run-min-debug: ## Start minimal Glances in debug console mode (also called standalone) + ./venv-min/bin/python -m glances -C ./conf/glances.conf -d + +run-min-local-conf: ## Start minimal Glances in console mode with the system conf file + ./venv-min/bin/python -m glances + run-docker-alpine-minimal: ## Start Glances Alpine Docker minimal in console mode 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 @@ -211,7 +244,4 @@ run-issue: ## Start Glances in issue mode show-version: ## Show Glances version number ./venv/bin/python -m glances -C ./conf/glances.conf -V -show-issue: ## Generate output for a new issue - ./venv/bin/python -m glances -C ./conf/glances.conf --issue - -.PHONY: test docs docs-server venv +.PHONY: test docs docs-server venv venv-min venv-dev -- cgit v1.2.3