-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
74 lines (60 loc) · 2.03 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
SHELL:=/bin/bash
VIRTUAL_ENV=.venv
PYTHON=${VIRTUAL_ENV}/bin/python3
PROJECT=gemma_template
DEFAULT_GOAL: help
.PHONY: help all install lint readme docs test tox
# Colors for echos
bold = \033[0;32m\033[1m***
end_bold = *** \033[0m\033[0;0m
all: ##@target >> Run all.
@make install
@make lint
@make readme
@make test
# And add help text after each target name starting with '\#\#'
# A category can be added with @category
HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-\$\(]+)\s*:.*\#\#(?:@([a-zA-Z\-\)]+))?\s(.*)$$/ }; \
print "Usage: make [target]\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; }
help: ##@target >> Show this help.
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
@echo ""
@echo "Note: to activate the environment in your local shell type:"
@echo " $$ source $(VIRTUAL_ENV)/bin/activate"
install: ##@target >> Setup virtualenv and Install dependencies.
@echo -e "$(bold) Setup virtualenv and install Dependencies $(end_bold)"
@$(PYTHON) -m pip install --upgrade pip
@$(PYTHON) -m pip install -r requirements-dev.txt
lint: ##@target >> Run Lint.
@echo -e "$(bold) Run Lint $(end_bold)"
@echo -e "$(bold) Black $(end_bold)"
@$(PYTHON) -m black $(PROJECT)
@echo -e "$(bold) iSort $(end_bold)"
@$(PYTHON) -m isort $(PROJECT)
@echo -e "$(bold) Flake8 $(end_bold)"
@$(PYTHON) -m flake8 $(PROJECT)
test:
python -m pytest tests
tox:
tox -p
rm -rf *.egg-info
readme:
python setup.py check --restructuredtext --strict && ([ $$? -eq 0 ] && echo "README.md and CHANGELOG.md ok") || echo "Invalid markup in README.md or CHANGELOG.md!"
docs:
mkdocs serve
publish:
rm -rf build dist .egg gemma_template.egg-info
python -m pip install -r requirements-dev.txt
python -m pip install 'twine>=6.0.1'
python setup.py sdist bdist_wheel
twine upload --skip-existing dist/*
rm -rf build dist .egg gemma_template.egg-info