forked from deanishe/alfred-repos
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
99 lines (79 loc) · 2.1 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
# must use system python
PYTHON := /usr/bin/python3
# get the version number
WF_VERSION := $(shell $(PYTHON) src/__version__.py)
# plist values
WF_NAME := alfred-git-repos
WF_CREATEDBY := deanishe
WF_BUNDLEID := com.${WF_CREATEDBY}.${WF_NAME}
WF_DISABLED := false
WF_WEBADDRESS := github.com/${WF_CREATEDBY}
WF_README := README.md
WF_DESCRIPTION := ""
# resulting workflow to build/install
WF_OUTPUT := ${WF_NAME}-${WF_VERSION}.alfredworkflow
# src/build dirs
SRC_DIR := src
BUILD_DIR := build
.PHONY: build
.PHONY: src-build
all: clean install
# install src/.site-packages
src: requirements.txt
src: PACKAGES=-r requirements.txt
src: src-build
# install bin/.site-packages
bin: PACKAGES=pip-tools==7.3.0
bin: bin/.site-packages
pip-compile: bin
# compile the requirements dir
requirements.txt: pip-compile requirements.in
PYTHONPATH=./bin/.site-packages:${PYTHONPATH} \
./bin/.site-packages/bin/pip-compile \
requirements.in
%/.site-packages:
# must use the system python
$(PYTHON) -m pip install \
--prefer-binary \
--upgrade \
--target=$@ \
${PACKAGES}
src-build:
# must use the system python
$(PYTHON) -m pip install \
--upgrade \
--target="$(BUILD_DIR)" \
${PACKAGES}
rm -rf ./build/*.egg-info ./build/*.dist-info
build: $(WF_OUTPUT)
${WF_NAME}%.alfredworkflow: src
rsync --archive --verbose \
--filter '- *.pyc' \
--filter '- *.egg-info' \
--filter '- *.dist-info' \
--filter '- __pycache__' \
"$(SRC_DIR)/" "$(BUILD_DIR)/"
./bin/workflow-build \
--force --verbose \
--name="${WF_NAME}" \
--version="${WF_VERSION}" \
--createdby="${WF_CREATEDBY}" \
--bundleid="${WF_BUNDLEID}" \
--disabled="${WF_DISABLED}" \
--webaddress="${WF_WEBADDRESS}" \
--readme="${WF_README}" \
--description="${WF_DESCRIPTION}" \
"$(BUILD_DIR)"
echo "done"
install: $(WF_OUTPUT)
open $(WF_OUTPUT)
clean:
rm -rf \
requirements.txt \
./build/ \
.mypy_cache/ \
./bin/.site-packages/ \
*.alfredworkflow
EXECUTABLES = $(PYTHON) plutil open rsync ./bin/workflow-build
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))