forked from Simatwa/python-tgpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (105 loc) · 3.35 KB
/
Makefile
File metadata and controls
126 lines (105 loc) · 3.35 KB
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
# Define targets
.PHONY: install install-minimal test test-tgpt test-api test-utils build build-deb build-minimal-deb clean
# Define variables
PYTHON := python3
PI := $(PYTHON) -m pip
PYINSTALLER := $(PYTHON) -m PyInstaller
DEB := $(shell pwd)/assets/deb
DEBLIB := $(DEB)/usr/lib
# Default target
default: install test build
# Target to install dependencies
install: clean
$(PI) install -U pip
$(PI) install -r requirements.txt
$(PI) install -e .
$(PI) install --upgrade g4f[all]
# Target to install minimal dependencies
install-minimal: clean
$(PI) install -U pip
$(PI) install -r requirements.txt
$(PI) install -e .
# Target to run tests
test:
$(PYTHON) -m unittest discover -s tests -p 'test_*.py' -f -v
# Target to run tgpt providers test
test-tgpt:
$(PYTHON) -m unittest discover -s tests -p 'test_*_tgpt.py' -f -v
# Target to run REST-api test
test-api:
$(PYTHON) -m unittest discover -s tests -p 'test_api.py' -f -v
# Target to run pytgpt utils test
test-utils:
$(PYTHON) -m unittest discover -s tests -p 'test_utils.py' -f -v
# Target to create an executable using PyInstaller
build: install
$(PI) install --upgrade pyinstaller
$(PYINSTALLER) main.py \
--onefile \
--exclude pandas \
--paths $(shell pwd) \
--distpath dist/$(shell uname) \
--workpath build/$(shell uname) \
--log-level INFO \
--exclude numpy \
--exclude matplotlib \
--exclude PyQt5 \
--exclude PyQt6 \
--exclude share \
--icon assets/logo.png \
--noconfirm
# Target to create .deb file
build-deb: install
$(PI) install --upgrade pyinstaller
$(PYINSTALLER) main.py \
--onedir \
--exclude pandas \
--paths $(shell pwd) \
--distpath $(DEBLIB) \
--workpath build/$(shell uname) \
--log-level INFO \
--exclude numpy \
--exclude matplotlib \
--exclude PyQt5 \
--exclude PyQt6 \
--exclude share \
--name pytgpt \
--contents-directory . \
--noconfirm
echo "Version: $(shell pytgpt --version | grep -oP 'version \K[\d.]+')" >> $(DEB)/DEBIAN/control
echo "Version=$(shell pytgpt --version | grep -oP 'version \K[\d.]+')" >> $(DEB)/usr/share/applications/pytgpt.desktop
echo "/usr/lib/pytgpt\n"\
"/usr/bin/pytgpt\n"\
"/usr/share/applications/icons/pytgpt.png\n"\
"/usr/share/applications/pytgpt.desktop" > $(DEBLIB)/pytgpt/entries.txt
echo "Installed-Size: $(shell du -sh -B KB $(DEB) | awk '{print $$1}')" >> $(DEB)/DEBIAN/control
dpkg-deb --build -Zxz $(DEB) pytgpt.deb
# Target to build minimal deb
build-minimal-deb: install-minimal
$(PI) install --upgrade pyinstaller
$(PYINSTALLER) main.py \
--onedir \
--exclude pandas \
--paths $(shell pwd) \
--distpath $(DEBLIB) \
--workpath build/$(shell uname) \
--log-level INFO \
--exclude numpy \
--exclude matplotlib \
--exclude PyQt5 \
--exclude PyQt6 \
--exclude share \
--name pytgpt \
--contents-directory . \
--noconfirm
echo "Version: $(shell pytgpt --version | grep -oP 'version \K[\d.]+')" >> $(DEB)/DEBIAN/control
echo "Version=$(shell pytgpt --version | grep -oP 'version \K[\d.]+')" >> $(DEB)/usr/share/applications/pytgpt.desktop
echo "/usr/lib/pytgpt\n"\
"/usr/bin/pytgpt\n"\
"/usr/share/applications/icons/pytgpt.png\n"\
"/usr/share/applications/pytgpt.desktop" > $(DEBLIB)/pytgpt/entries.txt
echo "Installed-Size: $(shell du -sh -B KB $(DEB) | awk '{print $$1}')" >> $(DEB)/DEBIAN/control
dpkg-deb --build -Zxz $(DEB) pytgpt.deb
# Target to clean up build artifacts
clean:
rm -rf build/ dist/ *.spec *.deb