This repository has been archived by the owner on Jun 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
154 lines (116 loc) · 3.68 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# Copyright 2018 Ross Jacobs All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Philosophy on Makefile: Syntax is annoying, so get it to work and then
# proxy to scripts in other languages if possible.
.PHONY: help run lint test configure build clean clean_all all
.PHONY: package install docs publish
VENV_NAME = venv/bin/activate
PYTHONFILES := merlink.py merlink/
ROOTDIR := "$(shell pwd)"
UNAME_S := "$(shell uname -s)"
ifeq (UNAME_S, "Linux")
WHICH = shell which
else ifeq (UNAME_S, "Darwin")
WHICH = shell which
else
WHICH = shell get-command 2> $null
endif
PYTHON := $(WHICH) python3
WHICH_PIP := $(WHICH) pip
#############
### USING ###
#############
help:
@echo "USING"
@echo " help: Execute this message"
@echo " run: Run the program for this project"
@echo " lint: Run pylint, flake8, radon, & dodgy for clean code"
@echo " test: Run the tests to generate coverage (in development)"
@echo "CONFIGURING"
@echo " configure: Download and install all dependencies with pip"
@echo " venv: Create a virtualenv for this project"
@echo " clean: Remove the build artifacts"
@echo " clean_all: Remove the virtualenv and build artifacts"
@echo "PACKAGING"
@echo " install: Install locally to dist/merlink/"
@echo " package: Create an exe/dmg/deb+rpm for this OS in build/"
@echo " archive Compress merlink into tar (POSIX systems) or zip"
@echo " docs: Compile documentation using sphinx with `make html`"
@echo " publish: Upload to PyPy"
.DEFAULT: help
run: venv
$(PYTHON) merlink.py
# Linting with pylint, flake8, radon.
lint: $(PYTHONFILES) venv
$(PYTHON) -m pylint $(PYTHONFILES)
$(PYTHON) -m flake8 $(ROOTDIR)
radon cc -nc $(PYTHONFILES)
radon mi -nc $(PYTHONFILES)
# https://wiki.python.org/moin/PyQt/GUI_Testing
# $(PYTHON) -m nose ./test
test:
@echo "Feature in progress..."
################
### BUILDING ###
################
configure:
# If python3 isn't installed, quit.
ifeq ("$(PYTHON)","")
@echo "python3 is not installed and is required. Exiting..."
exit 1
endif
# If pip is missing, install it.
ifeq ("$(WHICH_PIP)","")
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py;
python get-pip.py
endif
$(PYTHON) -m pip install -U pip
$(PYTHON) -m pip install virtualenv
venv: venv/bin/activate configure
PYTHON = venv/bin/python3
ifeq ("$(UNAME_S)", "Linux")
VENV_ACTIVATE = $(shell source $(VENV_NAME))
else ifeq ("$(UNAME_S)", "Darwin")
VENV_ACTIVATE = $(shell source $(VENV_NAME))
else
VENV_ACTIVATE = $(shell $(VENV_NAME))
endif
venv/bin/activate: setup.py
virtualenv -p python3 venv
ifeq ("$(UNAME_S)", "Darwin")
$(PYTHON) -m pip install dmgbuild
endif
$(PYTHON) -m pip install -e .
$(PYTHON) -m pip install -Ur requirements.txt
$(VENV_ACTIVATE)
clean:
$(RM) -r ./build ./dist
clean_all: clean
$(RM) -r ./venv
exit
#################
### PACKAGING ###
#################
all: install
install: venv
$(PYTHON) -m PyInstaller -y merlink.spec
package: install
$(PYTHON) pkg/make_packages.py
archive: setup.py
$(PYTHON) setup.py sdist
# Trigger Sphinx's makefile `make html`
docs:
cd docs; make html;
# When this gets on PyPy
publish: