File: Makefile

package info (click to toggle)
treelib 1.8.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 488 kB
  • sloc: python: 3,679; makefile: 85; sh: 37
file content (87 lines) | stat: -rw-r--r-- 3,260 bytes parent folder | download
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
.PHONY: help install install-dev test test-coverage lint autofix autofix-imports autofix-pep8 autofix-unused format format-check clean build docs
.DEFAULT_GOAL := help

# Variables
PYTHON := python3
POETRY := poetry
DIRS := examples treelib tests

help: ## Show this help message
	@echo "Available commands:"
	@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "  \033[36m%-20s\033[0m %s\n", $$1, $$2}'

install: ## Install production dependencies
	$(POETRY) install --only main

install-dev: ## Install development dependencies
	$(POETRY) install

test: install-dev ## Run tests with pytest
	$(POETRY) run pytest

run-examples: install ## Run all example scripts to verify they work correctly
	@echo "Running all example scripts..."
	@echo "๐Ÿš€ Running getting_started.py..."
	@$(POETRY) run python examples/getting_started.py > /dev/null
	@echo "โœ… getting_started.py completed successfully"
	@echo "๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Running family_tree.py..."
	@$(POETRY) run python examples/family_tree.py > /dev/null
	@echo "โœ… family_tree.py completed successfully"
	@echo "๐Ÿ’พ Running save_tree2file.py..."
	@$(POETRY) run python examples/save_tree2file.py > /dev/null
	@echo "โœ… save_tree2file.py completed successfully"
	@echo "๐Ÿ“ Running folder_tree.py..."
	@$(POETRY) run python examples/folder_tree.py --demo > /dev/null
	@echo "โœ… folder_tree.py completed successfully"
	@echo "๐Ÿ“„ Running json_trees.py..."
	@$(POETRY) run python examples/json_trees.py > /dev/null
	@echo "โœ… json_trees.py completed successfully"
	@echo "๐ŸŒณ Running recursive_dirtree.py..."
	@$(POETRY) run python examples/recursive_dirtree.py > /dev/null
	@echo "โœ… recursive_dirtree.py completed successfully"
	@echo "๐Ÿงฎ Running tree_algorithms.py..."
	@$(POETRY) run python examples/tree_algorithms.py > /dev/null
	@echo "โœ… tree_algorithms.py completed successfully"
	@echo "๐ŸŽ‰ All examples completed successfully!"

lint: install-dev ## Run linting checks (flake8)
	$(POETRY) run flake8 $(DIRS) --count --select=E9,F63,F7,F82 --ignore=E231 --max-line-length=120 --show-source --statistics

autofix-unused: install-dev ## Remove unused imports and variables
	$(POETRY) run autoflake --remove-all-unused-imports --remove-unused-variables --in-place --recursive $(DIRS)

autofix-imports: install-dev ## Sort and organize imports
	$(POETRY) run isort $(DIRS) --profile black

autofix-pep8: install-dev ## Fix PEP 8 style issues
	$(POETRY) run autopep8 --in-place --recursive --aggressive --aggressive $(DIRS)

autofix: autofix-unused autofix-imports autofix-pep8 format

format: install-dev ## Format code with black
	$(POETRY) run black $(DIRS)

format-check: install-dev ## Check code formatting with black
	$(POETRY) run black --check $(DIRS)

check: lint format-check ## Run all checks (lint + format check)

clean: ## Clean build artifacts and cache
	rm -rf build/
	rm -rf dist/
	rm -rf *.egg-info/
	rm -rf .pytest_cache/
	rm -rf .coverage
	rm -rf htmlcov/
	find . -type d -name __pycache__ -delete
	find . -type f -name "*.pyc" -delete

build: ## Build the package
	$(POETRY) build

docs: ## Build documentation
	@if [ -d "docs" ]; then \
		cd docs && make html; \
	else \
		echo "No docs directory found"; \
	fi