-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathMakefile
75 lines (61 loc) · 1.94 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
ifneq (,$(wildcard ./.env))
include .env
export
endif
SHELL := $(shell which bash)
MICROMAMBA := $(PWD)/.micromamba
MAMBA := $(MICROMAMBA)/micromamba
VENV := $(PWD)/.venv
DEPS := $(VENV)/.deps
PROJECT := streetview
PROJECT_DIR = $(PWD)/$(PROJECT)
TEST_DIR = $(PWD)/tests
PYTHON_VERSION ?= 3.11
PYTHON_CMD := PYTHONPATH=$(PWD) $(VENV)/bin/python
COVERAGE := 90 # Required code coverage
ifndef VERBOSE
.SILENT:
endif
.PHONY: help deps python clean check format test build
help:
grep -E '[0-9a-zA-Z_-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
$(MAMBA):
echo "Installing Mamba..."
$(SHELL) ./install-micromamba.sh "$(MICROMAMBA)"
$(DEPS): environment.yml $(MAMBA)
echo "Installing dependencies..."
rm -rf $(VENV)
$(MAMBA) create --quiet --yes -p $(VENV)
$(MAMBA) install --quiet --yes --log-level 4 -p $(VENV) python=$(PYTHON_VERSION) -c conda-forge
$(MAMBA) install --quiet --yes --log-level 4 -p $(VENV) -f environment.yml
cp environment.yml $(DEPS)
deps: $(DEPS) ## Install project dependencies
python: $(DEPS) ## Drop into a Python REPL
$(PYTHON_CMD)
clean: ## Delete unnecessary files from the project
rm -rf $(MICROMAMBA)
rm -rf $(VENV)
rm -rf output.txt
rm -rf .pytest_cache
rm -rf .coverage
rm -rf .mypy_cache
rm -rf dist
rm -rf streetview.egg-info
find . -name __pycache__ | xargs rm -rf
check: $(DEPS) ## Code style checks (isort, flake8 and mypy)
- $(PYTHON_CMD) -m isort . --diff
- $(PYTHON_CMD) -m flake8 $(PROJECT_DIR) $(TEST_DIR)
- $(PYTHON_CMD) -m black . --diff
- $(PYTHON_CMD) -m mypy -p $(PROJECT)
format: $(DEPS) ## Run auto linting
$(PYTHON_CMD) -m isort .
$(PYTHON_CMD) -m black .
test: $(DEPS) ## Run tests
- $(PYTHON_CMD) -m pytest \
--cov=$(PROJECT) \
--no-cov-on-fail \
--cov-fail-under=$(COVERAGE) \
--cov-report term-missing
build: $(DEPS) ## Build the package
$(PYTHON_CMD) -m build
$(PYTHON_CMD) -m twine check --strict dist/*