Update Makefile and requirements.txt for build and clean ui files

This commit is contained in:
2023-01-04 22:26:47 +01:00
parent 2ac1477441
commit 7f9111b5b0
5 changed files with 3450 additions and 3391 deletions

View File

@@ -1,38 +1,91 @@
SHELL := bash
SHELL := bash
MAKEFLAGS = --no-print-directory --no-builtin-rules
.DEFAULT_GOAL = all
# Variables
PACKAGE = revpicommander
# If virtualenv exists, use it. If not, use PATH to find
SYSTEM_PYTHON = $(or $(shell which python3), $(shell which python))
PYTHON = $(or $(wildcard venv/bin/python), $(SYSTEM_PYTHON))
SYSTEM_PYUIC5 = $(shell which pyuic5)
PYUIC5 = $(or $(wildcard venv/bin/pyuic5), $(SYSTEM_PYUIC5))
SYSTEM_PYRCC5 = $(shell which pyrcc5)
PYRCC5 = $(or $(wildcard venv/bin/pyrcc5), $(SYSTEM_PYRCC5))
SYSTEM_PYLUP5 = $(shell which pylupdate5)
PYLUP5 = $(or $(wildcard venv/bin/pylupdate5), $(SYSTEM_PYLUP5))
all: build_ui build_rc build
.PHONY: all
## Compile Qt UI files to python code
build_ui:
cd ui_dev && for ui_file in *.ui; do \
file_name=$${ui_file%.ui}; \
pyuic5 $${ui_file} -o ../src/revpicommander/ui/$${file_name}_ui.py -x --from-imports; \
$(PYUIC5) $${ui_file} -o ../src/$(PACKAGE)/ui/$${file_name}_ui.py -x --from-imports; \
echo $${file_name}; \
done
build_rc:
cd ui_dev && for rc_file in *.qrc; do \
file_name=$${rc_file%.qrc}; \
pyrcc5 $${rc_file} -o ../src/revpicommander/ui/$${file_name}_rc.py; \
$(PYRCC5) $${rc_file} -o ../src/$(PACKAGE)/ui/$${file_name}_rc.py; \
echo $${file_name}; \
done
update_translation:
pylupdate5 translate.pro
$(PYLUP5) translate.pro
installer_mac:
pyinstaller -n "RevPi Commander" \
--add-data="src/revpicommander/locale:locale" \
--add-data="data/revpicommander.icns:." \
--icon=data/revpicommander.icns \
.PHONY: build_ui build_rc update_translation
## Environment
venv:
rm -rf venv
$(SYSTEM_PYTHON) -m venv venv
deps:
$(PYTHON) -m pip install --upgrade pip -r requirements.txt
.PHONY: venv deps
## Build, install
build:
$(PYTHON) -m setup sdist
$(PYTHON) -m setup bdist_wheel
install:
$(PYTHON) -m pip install dist/$(PACKAGE)-*.whl
.PHONY: build install
## PyInstaller
installer_mac: all
$(PYTHON) -m PyInstaller -n "RevPi Commander" \
--add-data="src/$(PACKAGE)/locale:locale" \
--add-data="data/$(PACKAGE).icns:." \
--icon=data/$(PACKAGE).icns \
--noconfirm \
--clean \
--onedir \
--windowed \
src/revpicommander/__main__.py
src/$(PACKAGE)/__main__.py
installer_win:
pyinstaller -n "RevPi Commander" \
--add-data="src\\revpicommander\\locale;.\\locale" \
--add-data="data\\revpicommander.ico;." \
--icon=data\\revpicommander.ico \
installer_win: all
$(PYTHON) -m PyInstaller -n "RevPi Commander" \
--add-data="src\\$(PACKAGE)\\locale;.\\locale" \
--add-data="data\\$(PACKAGE).ico;." \
--icon=data\\$(PACKAGE).ico \
--noconfirm \
--clean \
--onedir \
--windowed \
src/revpicommander\__main__.py
src/$(PACKAGE)\__main__.py
.PHONY: installer_mac installer_win
## Clean
clean:
rm -rf build dist src/*.egg-info src/$(PACKAGE)/ui/[^__]*.py *.spec
.PHONY: clean