-
Notifications
You must be signed in to change notification settings - Fork 40
/
Makefile
136 lines (123 loc) · 4.07 KB
/
Makefile
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
.PHONY: all update venv venvupdate docker cleanpy cleanvenv cleanall
# run one shell only
.ONESHELL: all update venv venvupdate docker cleanpy cleanvenv cleanall
# disable running of targets in parallel
.NOTPARALLEL: all update venv venvupdate docker cleanpy cleanvenv cleanall
# predefined variables
CURRDIRECTORY := "$(notdir $(CURDIR))"
DOCKERTAG := "$(shell python -c "print('$(CURRDIRECTORY)'.lower())"):latest"
# check if os is windows or linux/mac
ifeq ($(OS),Windows_NT)
# windows
# set python executable path for python virtualenv
PYTHONVENV := .venv/Scripts/
PYTHONVENVEXE := .venv/Scripts/python.exe
else
# linux or mac
# set python executable path for python virtualenv
PYTHONVENV := .venv/bin/
PYTHONVENVEXE := .venv/bin/python
endif
# default target
all: cleanpy update venv
@echo
@echo "******************* all FINISHED *******************"
@echo
# local update of pip/virtualenv
update:
@echo "+++++++++++++++++++ update START +++++++++++++++++++"
@echo
python -m pip install --upgrade pip setuptools wheel poetry virtualenv uv ruff
@echo
@echo "******************* update FINISHED *******************"
@echo
# target for bulding the python venv
venv:
@echo "+++++++++++++++++++ virtualenv venv START +++++++++++++++++++"
@echo
@echo "Local Python Version..."
python --version
which python
@echo
@echo "Make Virtual Environment..."
# python -m venv .venv --clear --upgrade-deps
python -m uv venv --seed
@echo
@echo "Check Virtual Environment Python Version..."
$(PYTHONVENVEXE) --version
$(PYTHONVENVEXE) -c "import sys; print(sys.executable)"
@echo
@echo "Install/Update venv dependencies..."
# $(PYTHONVENVEXE) -m pip install --upgrade pip setuptools wheel poetry
uv pip install --upgrade pip setuptools wheel poetry jupyter
@echo
@echo "Install project dependencies..."
# $(PYTHONVENVEXE) -m pip install --upgrade -r requirements.txt
uv pip install --upgrade --requirement requirements.txt
@echo
@echo "Check for outdated dependencies and just list them..."
$(PYTHONVENVEXE) -m pip list --outdated
@echo
@echo "******************* virtualenv venv FINISHED *******************"
@echo
# target for upgrading venv
venvupdate:
@echo "+++++++++++++++++++ venvupdate START +++++++++++++++++++"
@echo
@echo "Check Virtual Environment Python Version..."
$(PYTHONVENVEXE) --version
$(PYTHONVENVEXE) -c "import sys; print(sys.executable)"
@echo
@echo "Update venv dependencies..."
# $(PYTHONVENVEXE) -m pip install --upgrade pip setuptools wheel poetry
uv pip install --upgrade pip setuptools wheel poetry jupyter
@echo
@echo "Update project dependencies..."
# $(PYTHONVENVEXE) -m pip install --upgrade -r requirements.txt
uv pip install --upgrade --requirement requirements.txt
@echo
@echo "Check for outdated dependencies and just list them..."
$(PYTHONVENVEXE) -m pip list --outdated
@echo
@echo "******************* venvupdate FINISHED *******************"
@echo
# build docker image
docker:
@echo "+++++++++++++++++++ docker START +++++++++++++++++++"
@echo
@echo "Build docker image with TAG: $(DOCKERTAG)"
@echo
docker build --pull --progress=plain --tag $(DOCKERTAG) .
@echo
@echo "******************* docker FINISHED *******************"
@echo
# remove cache files
cleanpy:
@echo "+++++++++++++++++++ cleanpy START +++++++++++++++++++"
@echo
rm -rf __pycache__
@echo
@echo "******************* cleanpy FINISHED *******************"
@echo
# remove venv
cleanvenv:
@echo "+++++++++++++++++++ cleanvenv START +++++++++++++++++++"
@echo
rm -rf .venv
@echo
@echo "******************* cleanvenv FINISHED *******************"
@echo
# remove docker image and dangling layers
cleandocker:
@echo "+++++++++++++++++++ cleandocker START +++++++++++++++++++"
@echo
docker image rm -f $(DOCKERTAG)
docker builder prune -a -f
@echo
@echo "******************* cleandocker FINISHED *******************"
@echo
# clean all
cleanall: cleanpy cleanvenv
@echo
@echo "******************* cleanall FINISHED *******************"
@echo