-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
94 lines (73 loc) · 2.44 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
# A quick installation script for painless discord bots.
# v2.0.0
# Copyright (c) 2019 0x5c
# Released under the terms of the MIT license.
# Part of:
# https://github.com/0x5c/quick-bot-no-pain
.DEFAULT_GOAL := help
### Variables ###
# Those are the defaults; they can be over-ridden if specified
# at en environment level or as 'make' arguments.
BOTENV ?= botenv
PYTHON_BIN ?= python3.11
PIP_OUTPUT ?= -q
### Support targets ###
.PHONY: help
help:
@echo ""
@echo "\033[97m>>>>>> Default dummy target <<<<<<"
@echo "\033[37mYou might want to specify a target:"
@echo "\033[32m --> make install"
@echo "\033[94m --> make clean"
@echo "\033[0m"
### Actual install/setup targets ###
# Main install target
.PHONY: install
install: $(BOTENV)/req_done data/options.py data/keys.py data/plugins
# Virual environment setup
$(BOTENV)/success:
ifneq ("$(wildcard ./$(BOTENV).)",)
@echo "\033[94m--> Creating the virtual environment...\033[0m"
@$(PYTHON_BIN) -m venv $(BOTENV)
@touch $(BOTENV)/success
endif
# Installing requirements
$(BOTENV)/req_done: requirements.txt $(BOTENV)/success
@echo "\033[34;1m--> Installing the dependencies...\033[0m"
@. $(BOTENV)/bin/activate; \
pip install ${PIP_OUTPUT} -U pip setuptools wheel; \
pip install ${PIP_OUTPUT} -U -r requirements.txt
@touch $(BOTENV)/req_done
# Creating the ./data subdirectory
data:
@echo "\033[34;1m--> Creating ./data ...\033[0m"
@mkdir -p data
# Creating the ./data/plugins subdirectory
data/plugins: ./data
@echo "\033[34;1m--> Creating ./data/plugins ...\033[0m"
@mkdir -p data/plugins
# Copying templates
data/options.py data/keys.py: ./data
@echo "\033[34;1m--> Copying template for ./$@ ...\033[0m"
@cp -nv ./templates/$@ ./$@
@touch ./$@
# Deletes the python cache and the virtual environment
.PHONY: clean
clean:
@echo "\033[34;1m--> Removing python cache files...\033[0m"
rm -rf __pycache__
@echo "\033[34;1m--> Removing the virtual environment...\033[0m"
rm -rf $(BOTENV)
### Dev targets ###
.PHONY: dev-install
dev-install: $(BOTENV)/dev_req_done data/options.py data/keys.py data/plugins
# Installing dev requirements
$(BOTENV)/dev_req_done: dev-requirements.txt $(BOTENV)/success
@echo "\033[34;1m--> Installing the dependencies...\033[0m"
@. $(BOTENV)/bin/activate; \
pip install ${PIP_OUTPUT} -U pip setuptools wheel; \
pip install ${PIP_OUTPUT} -U -r dev-requirements.txt
@touch $(BOTENV)/dev_req_done
### Special targets ###
.PHONY: onlyenv
onlyenv: $(BOTENV)/success