-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
112 lines (91 loc) · 3.5 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
# This ensures that we can call `make <target>` even if `<target>` exists as a file or
# directory.
.PHONY: docs help
# Exports all variables defined in the makefile available to scripts
.EXPORT_ALL_VARIABLES:
# Create .env file if it does not already exist
ifeq (,$(wildcard .env))
$(shell touch .env)
endif
# Create poetry env file if it does not already exist
ifeq (,$(wildcard ${HOME}/.poetry/env))
$(shell mkdir ${HOME}/.poetry)
$(shell touch ${HOME}/.poetry/env)
endif
# Includes environment variables from the .env file
include .env
# Set gRPC environment variables, which prevents some errors with the `grpcio` package
export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1
# Ensure that `pipx` and `poetry` will be able to run, since `pip` and `brew` put these
# in the following folders on Unix systems
export PATH := ${HOME}/.local/bin:/opt/homebrew/bin:$(PATH)
# Prevent DBusErrorResponse during `poetry install`
# (see https://stackoverflow.com/a/75098703 for more information)
export PYTHON_KEYRING_BACKEND := keyring.backends.null.Keyring
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
install: ## Install dependencies
@echo "Installing the 'tts_text' project..."
@$(MAKE) --quiet install-brew
@$(MAKE) --quiet install-pipx
@$(MAKE) --quiet install-poetry
@$(MAKE) --quiet setup-poetry
@$(MAKE) --quiet setup-environment-variables
@$(MAKE) --quiet setup-git
@echo "Installed the 'tts_text' project."
install-brew:
@if [ $$(uname) = "Darwin" ] && [ "$(shell which brew)" = "" ]; then \
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
echo "Installed Homebrew."; \
fi
install-pipx:
@if [ "$(shell which pipx)" = "" ]; then \
uname=$$(uname); \
case $${uname} in \
(*Darwin*) installCmd='brew install pipx'; ;; \
(*CYGWIN*) installCmd='py -3 -m pip install --upgrade --user pipx'; ;; \
(*) installCmd='python3 -m pip install --upgrade --user pipx'; ;; \
esac; \
$${installCmd}; \
pipx ensurepath --force; \
echo "Installed pipx."; \
fi
install-poetry:
@if [ ! "$(shell poetry --version)" = "Poetry (version 1.8.2)" ]; then \
python3 -m pip uninstall -y poetry poetry-core poetry-plugin-export; \
pipx install --force poetry==1.8.2; \
echo "Installed Poetry."; \
fi
setup-poetry:
@poetry env use python3.11 && poetry install
setup-environment-variables:
@poetry run python src/scripts/fix_dot_env_file.py
setup-environment-variables-non-interactive:
@poetry run python src/scripts/fix_dot_env_file.py --non-interactive
setup-git:
@git config --global init.defaultBranch main
@git init
@git config --local user.name ${GIT_NAME}
@git config --local user.email ${GIT_EMAIL}
@poetry run pre-commit install
docs: ## Generate documentation
@poetry run pdoc --docformat google src/tts_text -o docs
@echo "Saved documentation."
view-docs: ## View documentation
@echo "Viewing API documentation..."
@uname=$$(uname); \
case $${uname} in \
(*Linux*) openCmd='xdg-open'; ;; \
(*Darwin*) openCmd='open'; ;; \
(*CYGWIN*) openCmd='cygstart'; ;; \
(*) echo 'Error: Unsupported platform: $${uname}'; exit 2; ;; \
esac; \
"$${openCmd}" docs/tts_text.html
test: ## Run tests
@poetry run pytest && poetry run readme-cov
docker: ## Build Docker image and run container
@docker build -t tts_text .
@docker run -it --rm -v ./data:/project/data tts_text
tree: ## Print directory tree
@tree -a --gitignore -I .git .