-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
147 lines (122 loc) · 4.2 KB
/
Copy pathMakefile
File metadata and controls
147 lines (122 loc) · 4.2 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
PYTHON=$(shell which python3 )
VERSION=`cat cronzimus/VERSION`
# Check for UV installation
UV=$(shell which uv 2>/dev/null)
USE_UV=$(if $(UV),true,false)
ifeq (, $(PYTHON))
$(error "PYTHON=$(PYTHON) not found in $(PATH)")
endif
PYTHON_VERSION_MIN=3.10
PYTHON_VERSION_OK=$(shell $(PYTHON) -c 'from sys import version_info as v; v_min=int("".join("$(PYTHON_VERSION_MIN)".split("."))); print(0) if int(str(v.major)+str(v.minor)) >= v_min else print(1)')
PYTHON_VERSION=$(shell $(PYTHON) -c 'import sys; print("%d.%d"% sys.version_info[0:2])' )
PIP=$(PYTHON) -m pip
PYDOC=pydoc3
ifeq ($(PYTHON_VERSION_OK),1)
$(error "Requires Python >= $(PYTHON_VERSION_MIN) - Installed: $(PYTHON_VERSION)")
endif
help: ## Print help for each target
$(info Cronzimus - Task Scheduler and Job Manager)
$(info ==========================================)
$(info )
$(info Available commands:)
$(info )
@grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \
| sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'
$(info )
$(info UV Support: $(USE_UV))
@if [ "$(USE_UV)" = "true" ]; then \
echo "UV is installed. Use 'make uv-install' for faster dependency installation."; \
else \
echo "UV not found. Install with: curl -LsSf https://astral.sh/uv/install.sh | sh"; \
fi
.PHONY: install
install: ## Installs dependencies (uses UV if available).
@if [ "$(USE_UV)" = "true" ]; then \
echo "Installing dependencies with UV..."; \
$(UV) pip install -r requirements.txt; \
else \
echo "Installing dependencies with pip..."; \
$(PIP) install -r requirements.txt; \
fi
.PHONY: uv-install
uv-install: ## Install dependencies using UV (fast).
@if [ "$(USE_UV)" = "true" ]; then \
$(UV) pip install -r requirements.txt; \
else \
echo "UV not found. Install with: curl -LsSf https://astral.sh/uv/install.sh | sh"; \
exit 1; \
fi
.PHONY: uv-sync
uv-sync: ## Sync dependencies from pyproject.toml using UV.
@if [ "$(USE_UV)" = "true" ]; then \
$(UV) pip sync pyproject.toml; \
else \
echo "UV not found. Install with: curl -LsSf https://astral.sh/uv/install.sh | sh"; \
exit 1; \
fi
.PHONY: uv-venv
uv-venv: ## Create virtual environment using UV.
@if [ "$(USE_UV)" = "true" ]; then \
$(UV) venv; \
echo "Virtual environment created. Activate with: source .venv/bin/activate"; \
else \
echo "UV not found. Install with: curl -LsSf https://astral.sh/uv/install.sh | sh"; \
exit 1; \
fi
.PHONY: run
run: ## Run the cronzimus for all vehicles.
PYTHONPATH="." $(PYTHON) cronzimus/app.py
.PHONY: clean
clean: ## Remove the python binary files.
find . | grep -E "(__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf
rm -rf build dist *.egg-info .pytest_cache cov_html .coverage htmlcov
.PHONY: lint
lint: ## Lint the code
flake8
.PHONY: test
test: dev-install pytest code-analysis
.PHONY: dev-install
dev-install: ## Install testing in development mode.
@if [ "$(USE_UV)" = "true" ]; then \
echo "Installing dev dependencies with UV..."; \
$(UV) pip install -e ".[dev]"; \
else \
echo "Installing dev dependencies with pip..."; \
$(PIP) install -r requirements.txt; \
fi
.PHONY: pytest
pytest: ## Tests the code base and creates code coverage report.
$(PYTHON) -m pytest tests
.PHONY: check-black
check-black: ## Formats and checks code quality standards.
$(PYTHON) -m black --check cronzimus/
$(PYTHON) -m black --check tests/
PHONY: check-isort
check-isort:
$(PYTHON) -m isort --profile black cronzimus --check-only
$(PYTHON) -m isort --profile black tests --check-only
.PHONY: code-analysis
code-analysis: check-black check-isort
doc: ## Document the code
@$(PYDOC) cronzimus
.PHONY: format
format: ## Format code with black and isort
$(PYTHON) -m black cronzimus/ tests/
$(PYTHON) -m isort --profile black cronzimus tests
.PHONY: security
security: ## Run security checks with bandit
$(PYTHON) -m bandit -r cronzimus -ll
.PHONY: build
build: ## Build the package
@if [ "$(USE_UV)" = "true" ]; then \
echo "Building with UV..."; \
$(UV) build; \
else \
echo "Building with pip..."; \
$(PIP) install build; \
$(PYTHON) -m build; \
fi
.PHONY: install-uv
install-uv: ## Install UV package manager
@curl -LsSf https://astral.sh/uv/install.sh | sh
@echo "UV installed. Please restart your shell or run: source ~/.bashrc"