forked from RMPR/atbswp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (55 loc) · 2.09 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
.PHONY: help prepare-dev test run venv clean-build build clean-pyc
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >
VENV=./bin
PYTHON=${VENV}/python
PYINSTALLER=$(VENV)/pyinstaller
WORKDIR=./atbswp
WX_PATH:=$(shell pip show wxPython | awk ' $$1=="Location:" {print $$2} ')/wx
VENV_SITE_PACKAGES:=$(shell $(PYTHON) -c "import site; print(site.getsitepackages()[0])")
.DEFAULT: help
help: ## Display this help section
> @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36m%-38s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help
prepare-dev: ## Prepare the development environment
> @python -m venv .
> @$(PYTHON) -m pip install --upgrade pip
> @${PYTHON} -m pip install pyautogui pynput
> cp -r $(WX_PATH) $(VENV_SITE_PACKAGES)
> @echo
test: $(VENV)/activate ## Run all tests
> ${PYTHON} -m pytest
clean-pyc: $(VENV) ## Clean all the pyc files
> find . -name '*.pyc' -exec rm --force {} +
> find . -name '*.pyo' -exec rm --force {} +
clean-build: $(VENV)/activate ## Clean previous build
> @rm --force --recursive build/
> @rm --force --recursive dist/
> @rm --force --recursive *.egg-info
build: export PYTHONOPTIMIZE = 1
build: $(VENV)/activate ## Build the project for the current platform
> @sed 's/DEV = True/DEV = False/' $(WORKDIR)/control.py -i
> $(PYINSTALLER) --icon=$(WORKDIR)/img/icon.png --clean --windowed --onefile \
--add-data $(WORKDIR)/img:img \
--add-data $(WORKDIR)/lang:lang \
$(WORKDIR)/atbswp.py
run: $(VENV)/activate ## Launch the project
> $(PYTHON) $(WORKDIR)/atbswp.py
show-venv: $(VENV)/activate ## Show venv parameters
> @$(VENV)/python -c "import sys; print('Python ' + sys.version.replace('\n',''))"
> @echo
> @$(VENV)/pip --version
> @echo
clean-venv: ## Remove virtual environment
> @rm --force --recursive bin/
> @rm --force --recursive include/
> @rm --force --recursive lib/
> @rm --force lib64
> @rm --force pyvenv.cfg