forked from octorock/the-little-hat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (53 loc) · 1.69 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
# https://mplicka.cz/en/blog/compiling-ui-and-resource-files-with-pyqt
# Directory with ui and resource files
RESOURCE_DIR = resources
# Directory for compiled resources
COMPILED_DIR = tlh/ui
# UI files to compile
UI_FILES = $(notdir $(wildcard $(RESOURCE_DIR)/*.ui))
# Qt resource files to compile
RESOURCES = $(notdir $(wildcard $(RESOURCE_DIR)/*.qrc))
ifeq ($(OS),Windows_NT)
PYUIC = python venv/Scripts/pyside6-uic.exe
PYRCC = python venv/Scripts/pyside6-rcc.exe
else
PYUIC = python venv/bin/pyside6-uic
PYRCC = python venv/bin/pyside6-rcc
endif
COMPILED_UI = $(UI_FILES:%.ui=$(COMPILED_DIR)/ui_%.py)
COMPILED_RESOURCES = $(RESOURCES:%.qrc=$(COMPILED_DIR)/%_rc.py)
all: init resources ui
resources: $(COMPILED_RESOURCES)
ui: $(COMPILED_UI)
$(COMPILED_DIR)/ui_%.py: $(RESOURCE_DIR)/%.ui
$(PYUIC) --from-imports $< -o $@
$(COMPILED_DIR)/%_rc.py: $(RESOURCE_DIR)/%.qrc
$(PYRCC) $< -o $@
clean: tidy
rm -rf venv
tidy:
$(RM) $(COMPILED_UI) $(COMPILED_RESOURCES) $(COMPILED_UI:.py=.pyc) $(COMPILED_RESOURCES:.py=.pyc)
# https://stackoverflow.com/a/46188210
init: venv/touchfile
venv/touchfile: requirements.txt
test -d venv || python -m venv venv
ifeq ($(OS),Windows_NT)
venv/Scripts/activate; pip install -Ur requirements.txt
else
. venv/bin/activate; pip install -Ur requirements.txt
endif
touch venv/touchfile
run: all
ifeq ($(OS),Windows_NT)
venv/Scripts/activate; python main.py
else
. venv/bin/activate; python main.py
endif
test:
# for issues see https://docs.pytest.org/en/stable/goodpractices.html#tests-outside-application-code
ifeq ($(OS),Windows_NT)
venv/Scripts/activate; python -m pytest
else
. venv/bin/activate; python -m pytest
endif
.PHONY: init clean tidy run test