-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (69 loc) · 2.27 KB
/
Copy pathMakefile
File metadata and controls
85 lines (69 loc) · 2.27 KB
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
.PHONY: venv install-dev build check-dist upload test lint lint-fix format typecheck bump clean-build clean-venv clean
PYTHON := python3
VENV := .venv
VENV_PYTHON := $(VENV)/bin/python3
VENV_PIP := $(VENV)/bin/pip
REQUIREMENTS := requirements-dev.txt
SETUP_CFG := setup.cfg
INSTALL_TIMESTAMP := $(VENV)/.install-timestamp
# Create virtual environment
venv:
@if [ ! -d "$(VENV)" ]; then \
echo "Creating virtual environment..."; \
$(PYTHON) -m venv $(VENV); \
echo "Virtual environment created at $(VENV)"; \
else \
echo "Virtual environment already exists at $(VENV)"; \
fi
# Install development dependencies (only when needed)
$(INSTALL_TIMESTAMP): $(REQUIREMENTS) $(SETUP_CFG) | venv
@echo "Installing development dependencies..."
$(VENV_PIP) install --upgrade pip
$(VENV_PIP) install -r $(REQUIREMENTS)
$(VENV_PIP) install -e .
@touch $(INSTALL_TIMESTAMP)
@echo "Development environment ready!"
# Force reinstall of development dependencies
install-dev:
@rm -f $(INSTALL_TIMESTAMP)
@$(MAKE) $(INSTALL_TIMESTAMP)
build: $(INSTALL_TIMESTAMP)
$(VENV_PYTHON) -m build
check-dist:
$(VENV)/bin/twine check dist/*
upload:
$(VENV)/bin/twine upload dist/*
test: $(INSTALL_TIMESTAMP)
$(VENV)/bin/pytest
lint: $(INSTALL_TIMESTAMP)
$(VENV)/bin/ruff check dsmtpd/ tests/ scripts/
$(VENV)/bin/ruff format --check dsmtpd/ tests/ scripts/
lint-fix: $(INSTALL_TIMESTAMP)
$(VENV)/bin/ruff check --fix dsmtpd/ tests/ scripts/
$(VENV)/bin/ruff format dsmtpd/ tests/ scripts/
format: $(INSTALL_TIMESTAMP)
$(VENV)/bin/ruff format dsmtpd/ tests/ scripts/
typecheck: $(INSTALL_TIMESTAMP)
$(VENV)/bin/mypy dsmtpd/ scripts/
# Bump version and promote CHANGES.rst's Unreleased section.
# Usage: make bump PART=patch (or minor / major)
# Stdlib only — no dependency on the venv.
bump:
@$(PYTHON) scripts/release.py $(PART)
# Clean build artifacts
clean-build:
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
rm -rf dsmtpd.egg-info/
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name '*.pyc' -delete
find . -type f -name '*.pyo' -delete
@echo "Build artifacts removed"
# Clean virtual environment
clean-venv:
rm -rf $(VENV)
@echo "Virtual environment removed"
# Clean everything (build artifacts + virtual environment)
clean: clean-build clean-venv
@echo "All cleaned!"