-
-
Notifications
You must be signed in to change notification settings - Fork 251
/
Copy pathpython.mak
75 lines (63 loc) · 2.68 KB
/
python.mak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Python default launcher
python_launcher ?= python3.11
python_requirements_file ?= .config/python/dev/requirements.txt
python_requirements_dev_file ?= .config/python/dev/requirements.txt
## —— Python —————————————————————————————————————————————————————————————————————————————————————
.PHONY: python-bootstrap
python-bootstrap: ## Bootstrap python
$(MAKE) python-venv-init
$(MAKE) python-venv-upgrade
$(MAKE) python-venv-requirements
.PHONY: python-bootstrap-dev
python-bootstrap-dev: ## Bootstrap python for dev env
$(MAKE) python-venv-requirements-dev
$(MAKE) python-venv-linters-install
# ===============================================================================================
# .venv
# ===============================================================================================
.PHONY: python-venv-init
python-venv-init: ## Create venv ".venv/" if not exist
if [[ ! -d .venv ]] ; then \
$(python_launcher) -m venv .venv; \
fi
.PHONY: python-venv-upgrade
python-venv-upgrade: ## Upgrade venv with pip, setuptools and wheel
. .venv/bin/activate; \
pip install --upgrade pip setuptools wheel
.PHONY: python-venv-requirements
python-venv-requirements: ## Install or upgrade from $(python_requirements_file)
. .venv/bin/activate; \
pip install --upgrade --requirement $(python_requirements_file)
.PHONY: python-venv-requirements-dev
python-venv-requirements-dev: ## Install or upgrade from $(python_requirements_dev_file)
. .venv/bin/activate; \
pip install --upgrade --requirement $(python_requirements_dev_file)
.PHONY: python-venv-linters-install
python-venv-linters-install: ## Install or upgrade linters
. .venv/bin/activate; \
pip install --upgrade flake8
.PHONY: python-venv-purge
python-venv-purge: ## Remove venv ".venv/" folder
rm -rf .venv
# ===============================================================================================
# Utils
# ===============================================================================================
.PHONY: python-purge-cache
python-purge-cache: ## Purge cache to avoid used cached files
if [ -d .venv ] ; then
. .venv/bin/activate; \
pip cache purge
fi
.PHONY: python-version
python-version: ## Displays the python version used for the .venv
. .venv/bin/activate; \
$(python_launcher) --version
.PHONY: python-flake8
python-flake8: ## Run flake8 linter for python
. .venv/bin/activate; \
flake8 --config .config/.flake8
.PHONY: python-pytest
python-pytest: ## Run pytest to test python scripts
. .venv/bin/activate; \
cd scripts/
$(python_launcher) -m pytest