-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
93 lines (81 loc) · 2.24 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
##############################################################################
#
# Module: Makefile
#
# Purpose:
# Procedures for this directory
#
# Copyright notice and license:
# See LICENSE.md in this directory.
#
# Author:
# Terry Moore July 2024
#
##############################################################################
# figure out where Python virtual env executable artifacts live on this system
ifeq ($(OS),Windows_NT)
VENV_SCRIPTS=Scripts
else
VENV_SCRIPTS=bin
endif
# based on this, set the path to the bash activate script.
ACTIVATE=${VENV_SCRIPTS}/activate
# the default python
PYTHON=python3
# the python for VENVs
PYTHON_VENV=python
#
# Default target: print help.
#
help:
@printf "%s\n" \
"This Makefile contains the following targets" \
"" \
"* make help -- prints this message" \
"* make build -- builds the app (in dist)" \
"* make venv -- sets up the virtual env for development" \
"* make clean -- get rid of build artifacts" \
"* make distclean -- like clean, but also removes distribution directory" \
"" \
"On this system, virtual env scripts are in {envpath}/${VENV_SCRIPTS}"
#
# targets for building releases:
# .buildenv creates the first stage build environment (where we can install build)
# build actually creates release files.
#
.buildenv:
$(PYTHON) -m venv .buildenv
source .buildenv/$(ACTIVATE) && \
$(PYTHON_VENV) -m pip install build
build: .buildenv
source .buildenv/$(ACTIVATE) && $(PYTHON_VENV) -m build
@printf "%s\n" "distribution files are in the dist directory:" && ls dist
#
# targets for local development:
# .venv creates the virtual environment and installs requirements
# venv does the same, but tells you how to use the venv.
#
.venv:
$(PYTHON) -m venv .venv
source .venv/$(ACTIVATE) && $(PYTHON_VENV) -m pip install -r requirements.txt
venv: .venv
@printf "%s\n" \
"Virtual environment created in .venv." \
"" \
"To activate in bash, say:" \
" source .venv/${ACTIVATE}" \
""
@if [ "${PYTHON_VENV}" != "${PYTHON}" ]; then \
printf "%s\n" \
"Then be sure to run the app using ${PYTHON_VENV} (not ${PYTHON})" \
"" \
; \
fi
#
# maintenance targets
#
clean:
rm -rf .buildenv .venv *.egg-info */__pycache__
distclean: clean
rm -rf dist
#### end of file ####