-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
110 lines (92 loc) · 2.88 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
# Define targets
.PHONY: install install-minimal test 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 -r requirements.txt
$(PI) install .
$(PI) install --upgrade g4f[all]
# Target to install minimal dependencies
install-minimal: clean
$(PI) install -r requirements.txt
$(PI) install .
# Target to run tests
test:
$(PYTHON) -m unittest discover -s tests -p 'test_*.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
$(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
$(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