-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
140 lines (115 loc) · 4.78 KB
/
Makefile
File metadata and controls
140 lines (115 loc) · 4.78 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Rosettes Makefile
# Wraps uv commands to ensure Python 3.14t is used
PYTHON_VERSION ?= 3.14t
VENV_DIR ?= .venv
.PHONY: all help setup install install-docs test test-cov bench lint lint-fix format ty clean shell docs docs-serve build publish release gh-release
all: help
help:
@echo "Rosettes Development CLI"
@echo "========================"
@echo "Python Version: $(PYTHON_VERSION)"
@echo ""
@echo "Available commands:"
@echo " make setup - Create virtual environment with Python $(PYTHON_VERSION)"
@echo " make install - Install dependencies in development mode"
@echo " make install-docs - Install docs dependencies (Bengal from local path)"
@echo " make test - Run the test suite"
@echo " make test-cov - Run tests with coverage report"
@echo " make bench - Run benchmarks"
@echo " make lint - Run ruff linter"
@echo " make lint-fix - Run ruff linter with auto-fix"
@echo " make format - Run ruff formatter"
@echo " make ty - Run ty type checker (fast, Rust-based)"
@echo " make docs - Build documentation site (requires bengal)"
@echo " make docs-serve - Start dev server for docs (requires bengal)"
@echo " make build - Build distribution packages"
@echo " make publish - Publish to PyPI (uses .env for token)"
@echo " make release - Build and publish in one step"
@echo " make gh-release - Create GitHub release (triggers PyPI via workflow), uses site release notes"
@echo " make clean - Remove venv, build artifacts, and caches"
@echo " make shell - Start a shell with the environment activated"
setup:
@echo "Creating virtual environment with Python $(PYTHON_VERSION)..."
uv venv --python $(PYTHON_VERSION) $(VENV_DIR)
install:
@echo "Installing dependencies..."
@if [ ! -d "$(VENV_DIR)" ]; then \
echo "Error: $(VENV_DIR) not found. Run 'make setup' first."; \
exit 1; \
fi
@bash -c 'source "$(VENV_DIR)/bin/activate" && uv sync --active --group dev --frozen'
install-docs:
@echo "Installing docs dependencies (Bengal from local path)..."
uv sync --group docs
test:
uv run pytest
test-cov:
uv run pytest --cov=src/rosettes --cov-report=term-missing
bench:
@echo "Running benchmarks..."
uv run python -m benchmarks
lint:
@echo "Running ruff linter..."
uv run ruff check src/ tests/
lint-fix:
@echo "Running ruff linter with auto-fix..."
uv run ruff check src/ tests/ --fix
format:
@echo "Running ruff formatter..."
uv run ruff format src/ tests/
ty:
@echo "Running ty type checker (Astral, Rust-based)..."
uv run ty check src/rosettes/
docs: install-docs
@echo "Building documentation site..."
cd site && uv run bengal build
docs-serve: install-docs
@echo "Starting documentation dev server..."
cd site && uv run bengal serve
# =============================================================================
# Build & Release
# =============================================================================
build:
@echo "Building distribution packages..."
rm -rf dist/
uv build
@echo "✓ Built:"
@ls -la dist/
publish:
@echo "Publishing to PyPI..."
@if [ -f .env ]; then \
export $$(cat .env | xargs) && uv publish; \
else \
echo "Warning: No .env file found, trying without token..."; \
uv publish; \
fi
release: build publish
@echo "✓ Release complete"
# Create GitHub release from site release notes; triggers python-publish workflow → PyPI
# Strips YAML frontmatter (--- ... ---) from notes before passing to gh
gh-release:
@VERSION=$$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/'); \
PROJECT=$$(grep '^name = ' pyproject.toml | sed 's/name = "\(.*\)"/\1/'); \
NOTES="site/content/releases/$$VERSION.md"; \
if [ ! -f "$$NOTES" ]; then echo "Error: $$NOTES not found"; exit 1; fi; \
echo "Creating release v$$VERSION for $$PROJECT..."; \
git push origin main 2>/dev/null || true; \
git push origin v$$VERSION 2>/dev/null || true; \
awk '/^---$$/{c++;next}c>=2' "$$NOTES" | gh release create v$$VERSION \
--title "$$PROJECT $$VERSION" \
-F -; \
echo "✓ GitHub release v$$VERSION created (PyPI publish will run via workflow)"
# =============================================================================
# Cleanup
# =============================================================================
clean:
rm -rf $(VENV_DIR)
rm -rf build/ dist/ *.egg-info src/*.egg-info
rm -rf site/public
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".ty_cache" -exec rm -rf {} + 2>/dev/null || true
shell:
@echo "Activating environment with GIL disabled..."
@bash -c 'source $(VENV_DIR)/bin/activate && export PYTHON_GIL=0 && echo "✓ venv active, GIL disabled" && exec bash'