-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (64 loc) · 1.8 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
# Variables
PROJECT_NAME = clip-util
VENV_DIR = .venv
ifeq ($(OS),Windows_NT)
PYTHON = py
VENV_BIN = ./.venv/Scripts
else
PYTHON = python3
VENV_BIN = ./.venv/bin
endif
VENV_PYTHON = $(VENV_BIN)/python
# Settings
.DEFAULT_GOAL = help
.PHONY: help test build clean mostlyclean publish format format-update type
help:
@echo "---------------HELP---------------------------"
@echo "Manage $(PROJECT_NAME). Usage:"
@echo "make test - Test"
@echo "make mostlyclean - Clean temporary files, and caches"
@echo "make clean - Clean all"
@echo "make build - Build"
@echo "make publish - Publish to PyPi"
@echo ""
@echo "make format - Run formatters"
@echo "make format-update - Update formatters"
@echo "make type - Run type checkers"
@echo "----------------------------------------------"
venv: $(VENV_DIR)
$(VENV_DIR):
$(PYTHON) -m pip install --upgrade pip
$(PYTHON) -m pip install --upgrade virtualenv
$(PYTHON) -m virtualenv $(VENV_DIR)
$(VENV_PYTHON) -m pip install --upgrade pip
$(VENV_PYTHON) -m pip install --editable .[dev]
test: venv
@echo "Testing $(PROJECT_NAME)."
$(VENV_BIN)/tox
mostlyclean:
@echo "Removing temporary files and caches."
# Build Directories
rm -rf build/
rm -rf dist/
# Temporary Files and Caches
rm -rf **/__pycache__/
rm -rf **/*.egg-info/
rm -rf .mypy_cache
clean: mostlyclean
@echo "Removing temporary files and caches."
# Virtual Environment
rm -rf $(VENV_DIR)
build: venv
@echo "Building $(PROJECT_NAME)."
# Build
$(VENV_PYTHON) -m build
publish: build
@echo "Publishing $(PROJECT_NAME) to PyPi."
$(VENV_PYTHON) -m pip install --upgrade twine
$(VENV_PYTHON) -m twine upload dist/*
format: venv
$(VENV_BIN)/pre-commit run --all-files
format-update: venv
$(VENV_BIN)/pre-commit autoupdate
type: venv
$(VENV_BIN)/mypy ./src