-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
163 lines (140 loc) · 3.99 KB
/
Makefile
File metadata and controls
163 lines (140 loc) · 3.99 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# ================================================
# Common commands
# ================================================
# Run all tests: make test
# Check coverage: make coverage
# Test minimum versions: make test-min-versions
# Build package: make build
# Install dev dependencies: make install-dev
# Publish to TestPyPI: make publish-test
# Clean and rebuild: make rebuild-venv
# ================================================
# Configuration
PYTHON := python3
DOCTEST_FILES := $(wildcard curo/daycount/*.py curo/calculator.py docs/tests/*.py)
VENV_DIR := .venv
UV := uv
# Dependency versions (must match pyproject.toml [project.dependencies])
NUMPY_VERSION := 2.4.0
PANDAS_VERSION := 2.3.3
SCIPY_VERSION := 1.16.3
DATEUTIL_VERSION := 2.9.0.post0
# Default target
.PHONY: all
all: test coverage
# Run all tests (pytest + doctest)
.PHONY: test
test: test-pytest test-doctest
# Run pytest
.PHONY: test-pytest
test-pytest:
$(UV) run pytest tests/ -v -s
# Run doctests
.PHONY: test-doctest
test-doctest:
$(UV) run $(PYTHON) -m doctest $(DOCTEST_FILES) -v
# Run tests with minimum dependency versions
.PHONY: test-min-versions
test-min-versions:
rm -rf $(VENV_DIR)-min
$(UV) venv --python $(PYTHON) $(VENV_DIR)-min
. $(VENV_DIR)-min/bin/activate && \
$(UV) pip install \
"numpy==$(NUMPY_VERSION)" \
"pandas==$(PANDAS_VERSION)" \
"scipy==$(SCIPY_VERSION)" \
"python-dateutil==$(DATEUTIL_VERSION)" \
.[dev] \
-e . && \
$(UV) run pytest tests/ -v -s && \
$(UV) run $(PYTHON) -m doctest $(DOCTEST_FILES) -v
rm -rf $(VENV_DIR)-min
# Code coverage
.PHONY: coverage
coverage:
$(UV) run pytest --cov=curo --cov-report=term-missing --cov-report=html tests/ -v
# Install runtime dependencies dynamically
.PHONY: install
install:
$(UV) pip install .
# Install development dependencies dynamically
.PHONY: install-dev
install-dev:
$(UV) pip install ".[dev]"
# Build distribution (wheel and sdist)
.PHONY: build
build: build-prompt
$(UV) build
# Check project version has been bumped
.PHONY: build-prompt
build-prompt:
@echo "-------------------------------------------------------"
@echo "Has the project version been updated in pyproject.toml?"
@echo "-------------------------------------------------------"
@echo "1 - Yes"
@echo "2 - No"
@read -p "" response; \
if [ "$$response" != "1" ]; then \
echo "Build aborted."; \
exit 1; \
else \
echo "Build started."; \
fi
# Test local installation in a temporary virtual environment using uv
.PHONY: build-test-install
build-test-install: build
@echo "Testing local wheel installation with uv..."
@rm -rf .test-env
@$(UV) venv .test-env
@. .test-env/bin/activate && \
$(UV) pip install --quiet dist/curo-*.whl && \
python -c "\
from curo import Calculator, Actual360, __version__; \
print(f'Local install test: Success! Imported curo v{__version__}'); \
calc = Calculator(); \
print(' → Calculator instance created:', calc)" && \
echo "Local install test passed."
@rm -rf .test-env
# Publish to PyPI (requires twine and credentials)
.PHONY: publish
publish: build
$(UV) run twine upload dist/*
# Publish to TestPyPI
.PHONY: publish-test
publish-test: build
$(UV) run twine upload --repository testpypi dist/* --verbose
# Update uv.lock
.PHONY: lock
lock:
$(UV) lock
# Clean project
.PHONY: clean
clean: clean-cache clean-venv clean-build
@echo "Cleaned project"
# Clean cache files
.PHONY: clean-cache
clean-cache:
find . -type d -name "__pycache__" -exec rm -rf {} + || true
find . -type f -name "*.pyc" -delete || true
find . -type d -name "*.egg-info" -exec rm -rf {} + || true
# Clean virtual environment
.PHONY: clean-venv
clean-venv:
rm -rf $(VENV_DIR) uv.lock
# Clean build artifacts
.PHONY: clean-build
clean-build:
rm -rf build/ coverage_html/ dist/ site/
# Rebuild virtual environment
.PHONY: rebuild-venv
rebuild-venv: clean
$(UV) venv --python $(PYTHON)
$(UV) pip install ".[dev]" -e .
$(UV) lock
.PHONY: mkdocs-serve
mkdocs-serve:
$(UV) run mkdocs serve
# Deploy docs to GitHub pages
.PHONY: mkdocs-deploy
mkdocs-deploy:
$(UV) run mkdocs gh-deploy