-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
88 lines (66 loc) · 1.91 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
# Include variables
include config.mk
## install : Install the package
.PHONY: install
install :
@if [ ! -d "$(PRODUCTION_ENV)" ]; then $(PYTHON) -m venv $(PRODUCTION_ENV); fi
@. $(PRODUCTION_ENV)/bin/activate; \
pip install .
## develop : Install the package in development mode
.PHONY: develop
develop : env
## env : Prepare a virtual environment to run the package
.PHONY: env
env : $(ENV)/.touchfile
@echo "The environment ($(ENV)) is up to date."
# Create/update the virtual environment (based on `requirements.txt`, etc.)
# Uses touchfile as proxy for installed environment
$(ENV)/.touchfile : $(REQS) pyproject.toml
@echo "Installing/updating the environment ($(ENV))."
@if [ ! -d "$(ENV)" ]; then $(PYTHON) -m venv $(ENV); fi
@. $(ENV_ACTIVATE); \
pip install -r $(REQS) -e .
@touch $(ENV)/.touchfile
## test : Run tests
.PHONY: test
test : env
@. $(ENV_ACTIVATE); \
pytest $(COVERAGE_OPTIONS) \
--cov-report term \
--cov-report html
## format : Format the package source code
.PHONY: format
format : env
@. $(ENV_ACTIVATE); \
isort $(PYTHON_FORMAT_DIRS); \
black $(PYTHON_FORMAT_DIRS)
## format-diff : See the differences that will be produced by formatting
.PHONY: format-diff
format-diff : env
@. $(ENV_ACTIVATE); \
isort --diff --color $(PYTHON_FORMAT_DIRS); \
black --diff --color $(PYTHON_FORMAT_DIRS)
## package : Bundle the package for distribution
.PHONY: package
package : env
@. $(ENV_ACTIVATE); \
hatch build
## upload : Upload the package to PyPI
.PHONY: upload
upload : env
@. $(ENV_ACTIVATE); \
hatch publish
## clean : Clean all automatically generated files
.PHONY : clean
clean :
@find . -type f -name '*.pyc' -delete
@find . -type d -name '__pycache__' | xargs rm -rf
@rm -rf .pytest_cache/
@rm -rf $(PACKAGE_DIR)/_version.py
@rm -rf $(ENV)
@rm -rf htmlcov/
@rm -rf dist/ *egg-info/
@rm -rf instance/dev-monopyly.sqlite
.PHONY: help
help : Makefile
@sed -n 's/^##//p' $<