Repository navigation
Expand file tree
/
Copy pathmakefile
More file actions
132 lines (112 loc) · 4.81 KB
/
Copy pathmakefile
File metadata and controls
132 lines (112 loc) · 4.81 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
# Define the package name, module name, environment name, and Python version
PACKAGE_NAME = rasters
MODULE_NAME = $(subst -,_,$(PACKAGE_NAME))
ENVIRONMENT_NAME = $(PACKAGE_NAME)
PYTHON_VERSION = $(if $(PYTHON),$(PYTHON),3.13)
# Allow passing extra flags via command line: make <target> ARGS="-k test_name"
ARGS ?=
# Include a Makefile.local to override things, if found
-include Makefile.local
.DEFAULT_GOAL := help
.PHONY: help clean test build wheel sdist twine-upload dist \
install uninstall reinstall environment remove-environment \
repomix generate-history show-issues
help: ## Show available targets
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-28s\033[0m %s\n", $$1, $$2}'
##@ Cleanup & Environment
clean: ## Remove build artifacts, caches, coverage files, and logs
rm -rf *.o *.out *.log
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
rm -rf .pytest_cache
rm -rf htmlcov/ .coverage
rm -rf $(PACKAGE_NAME)-repomix.xml repomix-output.xml release_diffs.patch
find . -type d -name "__pycache__" -exec rm -rf {} +
find . -type f -name "*.py[co]" -delete
environment: ## Create a new Conda/Mamba environment (override with PYTHON=3.12)
mamba create -y -n $(ENVIRONMENT_NAME) -c conda-forge python=$(PYTHON_VERSION) jupyter
remove-environment: ## Remove the Conda/Mamba environment
mamba env remove -y -n $(ENVIRONMENT_NAME)
install: ## Install the package in editable mode with development dependencies
pip install -e .[dev]
uninstall: ## Uninstall the package
pip uninstall -y $(PACKAGE_NAME)
reinstall: ## Reinstall the package (uninstall and then install)
$(MAKE) uninstall
$(MAKE) install
##@ Testing & Verification
test: ## Run Python unit tests using pytest
pytest -vv $(ARGS)
##@ Packaging & Release
wheel: ## Build the Python wheel
python -m build --wheel
sdist: ## Build the Python source distribution
python -m build --sdist
build: ## Build the Python wheel and source distribution
python -m build
twine-upload: ## Upload the built package to PyPI using Twine
twine upload dist/*
dist: ## Clean, build, and upload the package to PyPI
$(MAKE) clean
$(MAKE) build
$(MAKE) twine-upload
##@ Utilities
repomix: ## Pack repository context for LLM review
npx repomix -o $(PACKAGE_NAME)-repomix.xml --ignore "**/*.tif,**/*.tiff,**/*.png,**/*.jpg,**/*.jpeg,**/*.aux.xml,**/*.csv,**/*.pdf,**/*.svg,**/*.ipynb,*-repomix*.xml,repomix-output.xml,release_diffs.patch" --copy
generate-history: ## Generate release commit history patch
fish -c ' \
git fetch --tags --quiet; \
set first_commit (git rev-list --max-parents=0 HEAD | head -n 1); \
set releases (gh release list --limit 1000 --json tagName,createdAt --jq "sort_by(.createdAt) | .[].tagName"); \
begin; \
echo "========================================"; \
echo "REPOSITORY RELEASE TIMELINE"; \
echo "========================================"; \
gh release list --limit 1000; \
echo ""; \
if test (count $$releases) -ge 1; \
set first_rel $$releases[1]; \
echo "========================================"; \
echo "INITIAL COMMIT ($$first_commit) -> FIRST RELEASE ($$first_rel)"; \
echo "========================================"; \
git log --reverse --stat -p $$first_rel -- "*.py" "pyproject.toml"; \
echo ""; \
end; \
if test (count $$releases) -ge 2; \
for i in (seq 2 (count $$releases)); \
set prev_idx (math $$i - 1); \
set prev $$releases[$$prev_idx]; \
set curr $$releases[$$i]; \
echo "========================================"; \
echo "RELEASE COMMIT HISTORY: $$prev -> $$curr"; \
echo "========================================"; \
git log --reverse --stat -p $$prev..$$curr -- "*.py" "pyproject.toml"; \
echo ""; \
end; \
end; \
if test (count $$releases) -ge 1; \
set latest_rel $$releases[-1]; \
echo "========================================"; \
echo "LATEST RELEASE ($$latest_rel) -> CURRENT WORKING TREE (HEAD + UNCOMMITTED)"; \
echo "========================================"; \
git log --reverse --stat -p $$latest_rel..HEAD -- "*.py" "pyproject.toml"; \
echo ""; \
git status -s -- "*.py" "pyproject.toml"; \
echo ""; \
git diff HEAD -- "*.py" "pyproject.toml"; \
else; \
echo "========================================"; \
echo "INITIAL COMMIT ($$first_commit) -> CURRENT WORKING TREE"; \
echo "========================================"; \
git log --reverse --stat -p -- "*.py" "pyproject.toml"; \
echo ""; \
git status -s -- "*.py" "pyproject.toml"; \
echo ""; \
git diff HEAD -- "*.py" "pyproject.toml"; \
end; \
end > release_diffs.patch; \
'
show-issues: ## List open GitHub issues
gh issue list --state open --json number,title,body --template '{{range .}}## #{{.number}}: {{.title}}{{"\n\n"}}{{.body}}{{"\n\n---\n\n"}}{{end}}'