Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
152 lines (134 loc) · 4.59 KB
/
Copy pathMakefile
File metadata and controls
152 lines (134 loc) · 4.59 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
# makefile to manage project
# commands:
# - make setup-venv
# - make examples
# - make test-examples
# - make test-requirements
# - make test-coverage
# - make format
# - make format-check
# - make build-executable
# - make docs
# - make clean
# - make clean-light
# - make release-checklist
# - make release-changelog
# - make thirdpartycheck
# - make release-upload
# - make release
VENV_DIR := .venv
VENV_RECREATE := false
VENV_RELEASE := false
# Platform detection for virtual environment binary path
ifeq ($(OS),Windows_NT)
VENV_BIN := $(VENV_DIR)/Scripts
PLATFORM := windows
PATHSEP := ;
else
VENV_BIN := $(VENV_DIR)/bin
PLATFORM := unix
PATHSEP := :
endif
# Main setup-venv target - uses POSIX shell commands (works with Git Bash on Windows)
.PHONY: setup-venv
setup-venv:
@if [ -d "$(VENV_DIR)" ]; then \
echo "Virtual environment '$(VENV_DIR)' already exists. For recreation add 'VENV_RECREATE=true' to cli."; \
if [ "$(VENV_RECREATE)" = "true" ] || [ "$(VENV_RECREATE)" = "TRUE" ]; then \
echo "Removing existing virtual environment '$(VENV_DIR)'..."; \
rm -rf "$(VENV_DIR)"; \
else \
exit 0; \
fi; \
fi; \
echo "Creating virtual environment '$(VENV_DIR)'..."; \
python -m venv "$(VENV_DIR)" || { echo "Error: Failed to create virtual environment."; exit 1; }; \
echo "Installing project dependencies in virtual environment '$(VENV_DIR)'..."; \
\
# Check if .git exists to decide on versioning strategy for editable install \
if [ ! -d ".git" ]; then \
echo "NOTE: .git directory not found. Setting pretend version for installation."; \
if [ "$(VENV_RELEASE)" = "true" ] || [ "$(VENV_RELEASE)" = "TRUE" ]; then \
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MATI=0.0.1 "$(VENV_BIN)/pip" install -e ".[release]" || { echo "Error: Failed to install dependencies (no Git)."; exit 1; }; \
else \
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MATI=0.0.1 "$(VENV_BIN)/pip" install -e ".[dev]" || { echo "Error: Failed to install dependencies (no Git)."; exit 1; }; \
fi; \
else \
echo "NOTE: .git directory found. Using setuptools_scm for versioning."; \
if [ "$(VENV_RELEASE)" = "true" ] || [ "$(VENV_RELEASE)" = "TRUE" ]; then \
"$(VENV_BIN)/pip" install -e ".[release]" || { echo "Error: Failed to install dependencies (with Git)."; exit 1; }; \
else \
"$(VENV_BIN)/pip" install -e ".[dev]" || { echo "Error: Failed to install dependencies (with Git)."; exit 1; }; \
fi; \
fi
.PHONY: examples
examples: setup-venv
@echo "TODO: Implementation"
.PHONY: test-examples
test-examples: setup-venv
@echo "TODO: Implementation"
.PHONY: test-requirements
test-requirements: setup-venv
@echo "TODO: Implementation"
.PHONY: test-coverage
test-coverage: setup-venv
@echo "TODO: Implementation"
.PHONY: format
format: setup-venv
@"$(VENV_BIN)/ruff" format .
.PHONY: format-check
format-check: setup-venv
@"$(VENV_BIN)/ruff" format --check .
.PHONY: build-executable
build-executable: setup-venv
@echo "TODO: Implementation"
.PHONY: release-checklist
release-checklist:
@echo "TODO: Implementation"
.PHONY: release-changelog
release-changelog:
@echo "TODO: Implementation"
.PHONY: thirdpartycheck
thirdpartycheck: setup-venv
@echo ""
@echo "Running third-party dependency analysis..."
@"$(VENV_BIN)/python" scripts/analyze_dependencies.py --format json --generate-notice --check-compatibility
@echo "Third-party dependency check complete."
.PHONY: release-upload
release-upload:
@echo "TODO: Implementation"
.PHONY: release
release: release-checklist release-changelog thirdpartycheck build-executable release-upload
@echo "TODO: Implementation"
.PHONY: docs
docs: setup-venv
@echo "TODO: Implementation"
.PHONY: clean
clean:
@printf "WARNING: This will permanently delete all generated files, caches, and logs. Continue? [y/n] "; \
read -r REPLY; \
if [ "$$REPLY" = "y" ] || [ "$$REPLY" = "Y" ]; then \
echo "Cleaning project in mode full..."; \
$(MAKE) clean-light; \
rm -rf logs; \
rm -rf build; \
rm -rf dist; \
rm -rf examples/output; \
rm -rf docs/_build; \
echo "Project cleaned successfully in mode full."; \
else \
echo "Clean cancelled."; \
fi
.PHONY: clean-light
clean-light:
echo "Cleaning project in mode light..."; \
find . -type f -name "*.pyc" -delete; \
find . -type d -name "__pycache__" -exec rm -rf {} +; \
find . -type d -name "log" -exec rm -rf {} +; \
find . -type d -name ".pytest_cache" -exec rm -rf {} +; \
find . -type d -name ".ruff_cache" -exec rm -rf {} +; \
find . -type f -name "*.spec" -delete; \
rm -f .coverage .coverage.*; \
rm -rf htmlcov; \
$(MAKE) -C examples/sim_unit clean; \
echo "Project cleaned successfully in mode light."; \