| 1 |
ifneq ($(OS),Windows_NT) |
| 2 |
# On Unix-based systems, use ANSI codes |
| 3 |
BLUE = \033[36m |
| 4 |
BOLD_BLUE = \033[1;36m |
| 5 |
BOLD_GREEN = \033[1;32m |
| 6 |
RED = \033[31m |
| 7 |
YELLOW = \033[33m |
| 8 |
BOLD = \033[1m |
| 9 |
NC = \033[0m |
| 10 |
endif |
| 11 |
|
| 12 |
escape = $(subst $$,\$$,$(subst ",\",$(subst ',\',$(1)))) |
| 13 |
|
| 14 |
define exec |
| 15 |
@echo "$(BOLD_BLUE)$(call escape,$(1))$(NC)" |
| 16 |
@$(1) |
| 17 |
endef |
| 18 |
|
| 19 |
help: |
| 20 |
@echo "$(BOLD_GREEN)Available targets:$(NC)" |
| 21 |
@grep -E '^[a-zA-Z_-].+:.*?# .*$$' $(MAKEFILE_LIST) | \ |
| 22 |
awk 'BEGIN {FS = ":.*?# "}; \ |
| 23 |
{printf " $(BOLD_BLUE)%-20s$(NC) %s\n", $$1, $$2}' |
| 24 |
|
| 25 |
PACKAGE_NAME:=labelme |
| 26 |
|
| 27 |
setup: # Setup the development environment |
| 28 |
$(call exec,uv sync --dev) |
| 29 |
|
| 30 |
format: # Format code |
| 31 |
$(call exec,uv run ruff format) |
| 32 |
$(call exec,uv run ruff check --fix) |
| 33 |
|
| 34 |
lint: |
| 35 |
$(call exec,uv run ruff format --check) |
| 36 |
$(call exec,uv run ruff check) |
| 37 |
|
| 38 |
mypy: |
| 39 |
$(call exec,uv run mypy --package $(PACKAGE_NAME)) |
| 40 |
|
| 41 |
check: lint mypy # Run checks |
| 42 |
|
| 43 |
test: # Run tests |
| 44 |
$(call exec,uv run pytest -v tests/) |
| 45 |
|
| 46 |
build: # Build the package |
| 47 |
$(call exec,uv build) |