-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
109 lines (92 loc) · 3.11 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
MAKEFLAGS += -s
.PHONY: help run debug freeze sort publish test lint format clean install dev-install build check all
default: run
help:
@echo "⚈ run ---> 🎮 Run project locally (default)."
@echo "⚈ debug ---> 🕵️ Debug project locally."
@echo "⚈ freeze ---> 🧊 Freeze requirements."
@echo "⚈ sort ---> ⬇️ Sort requirements and env files alphabetically."
@echo "⚈ publish ---> 🚀 Build and publish a new package version."
@echo "⚈ test ---> 🧪 Run tests."
@echo "⚈ lint ---> 🔍 Run linter."
@echo "⚈ format ---> 💅 Format code."
@echo "⚈ clean ---> 🧹 Remove build artifacts."
@echo "⚈ install ---> 📦 Install the package."
@echo "⚈ dev-install ---> 🛠️ Install the package in editable mode with dev dependencies."
@echo "⚈ build ---> 🏗️ Build the package."
@echo "⚈ check ---> ✅ Run tests and linter."
@echo "⚈ all ---> 🔄 Clean, install, test, lint, and format."
run:
@echo "\n> 🎮 Running the project locally... (default)\n"
debug:
@echo "\n> 🕵️ Debugging the project locally...\n"
freeze:
@echo "\n> 🧊 Freezing the requirements...\n"
@for file in requirements*.txt; do \
if [ -f $$file ]; then \
pip3 freeze -q -r $$file | sed '/freeze/,$$ d' > requirements-froze.txt && mv requirements-froze.txt $$file; \
echo "Froze requirements in $$file"; \
else \
echo "$$file not found, skipping..."; \
fi \
done
@python src/update_pyproject.py
sort:
@echo "\n> ⬇️ Sorting requirements and env files alphabetically...\n"
@for file in requirements*.txt; do \
if [ -f $$file ]; then \
sort --ignore-case -u -o $$file{,}; \
echo "Sorted $$file"; \
else \
echo "$$file not found, skipping..."; \
fi \
done
@for file in .env*; do \
if [ -f $$file ]; then \
sort --ignore-case -u -o $$file{,}; \
echo "Sorted $$file"; \
else \
echo "$$file not found, skipping..."; \
fi \
done
publish:
@echo "\n> 🚀 Building and publishing a new package version...\n"
@echo "\n> 📦 Installing build dependencies...\n"
pip install -r requirements-build.txt
@echo "\n> 🗑️ Erasing previous build...\n"
rm -rf src/dist
@echo "\n> ⬆️ Bumping package version...\n"
bump2version patch --verbose
@echo "\n> 🔨 Building package...\n"
python -m build src
@echo "\n> 🌐 Uploading package to Test PyPi...\n"
python -m twine upload --repository yatl-python src/dist/*
test:
@echo "\n> 🧪 Running tests...\n"
pytest tests/
lint:
@echo "\n> 🔍 Running linter...\n"
flake8 src/ tests/
mypy src/ tests/
format:
@echo "\n> 💅 Formatting code...\n"
black src/ tests/
isort src/ tests/
clean:
@echo "\n> 🧹 Removing build artifacts...\n"
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
find . -type d -name '__pycache__' -exec rm -rf {} +
find . -type f -name '*.pyc' -delete
install:
@echo "\n> 📦 Installing the package...\n"
pip install .
dev-install:
@echo "\n> 🛠️ Installing the package in editable mode with dev dependencies...\n"
pip install -e ".[dev]"
build:
@echo "\n> 🏗️ Building the package...\n"
python -m build
check: test lint
all: clean install test lint format