-
Notifications
You must be signed in to change notification settings - Fork 2
/
makefile
123 lines (104 loc) · 3.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
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
# This ensures that we can call `make <target>` even if `<target>` exists as a file or
# directory.
.PHONY: notebook docs
# Exports all variables defined in the makefile available to scripts
.EXPORT_ALL_VARIABLES:
# Includes environment variables from the .env file
include .env
install-poetry:
@echo "Installing poetry..."
@curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3.10 -
@$(eval include ${HOME}/.poetry/env)
uninstall-poetry:
@echo "Uninstalling poetry..."
@curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3.10 - --uninstall
install:
@echo "Installing..."
@if [ "$(shell which poetry)" = "" ]; then \
$(MAKE) install-poetry; \
fi
@if [ "$(shell which gpg)" = "" ]; then \
echo "GPG not installed, so an error will occur. Install GPG on MacOS with "\
"`brew install gnupg` or on Ubuntu with `apt install gnupg` and run "\
"`make install` again."; \
fi
@$(MAKE) setup-poetry
@$(MAKE) setup-environment-variables
@$(MAKE) setup-git
setup-poetry:
@poetry env use python3.10 && poetry install
setup-environment-variables:
@poetry run python3.10 -m src.scripts.fix_dot_env_file
setup-git:
@git init
@git config --local user.name ${GIT_NAME}
@git config --local user.email ${GIT_EMAIL}
@if [ ${GPG_KEY_ID} = "" ]; then \
echo "No GPG key ID specified. Skipping GPG signing."; \
git config --local commit.gpgsign false; \
else \
echo "Signing with GPG key ID ${GPG_KEY_ID}..."; \
echo 'If you get the "failed to sign the data" error when committing, try running `export GPG_TTY=$$(tty)`.'; \
git config --local commit.gpgsign true; \
git config --local user.signingkey ${GPG_KEY_ID}; \
fi
@poetry run pre-commit install
docs:
@poetry run pdoc --docformat google src/alexandra_ai -o docs
@echo "Saved documentation."
view-docs:
@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/alexandra_ai.html
bump-major:
@poetry run python -m src.scripts.versioning --major
@echo "Bumped major version!"
bump-minor:
@poetry run python -m src.scripts.versioning --minor
@echo "Bumped minor version!"
bump-patch:
@poetry run python -m src.scripts.versioning --patch
@echo "Bumped patch version!"
publish:
@if [ ${PYPI_API_TOKEN} = "" ]; then \
echo "No PyPI API token specified in the '.env' file, so cannot publish."; \
else \
echo "Publishing to PyPI..."; \
poetry publish --build --username "__token__" --password ${PYPI_API_TOKEN}; \
fi
@echo "Published!"
publish-major: bump-major publish
publish-minor: bump-minor publish
publish-patch: bump-patch publish
test:
@poetry run pytest && readme-cov
tree:
@tree -a \
-I .git \
-I .mypy_cache . \
-I .env \
-I .venv \
-I poetry.lock \
-I .ipynb_checkpoints \
-I dist \
-I .gitkeep \
-I docs \
-I .pytest_cache \
-I outputs \
-I .DS_Store \
-I .cache \
-I *.parquet \
-I *.csv \
-I *.txt \
-I checkpoint-* \
-I .coverage* \
-I .alexandra_ai_cache \
-I alexandra_ai_evaluation_results.json \
-I __pycache__ \
-I flagged