Repository navigation
Expand file tree
/
Copy path.dev_common.mk
More file actions
142 lines (131 loc) · 5 KB
/
Copy path.dev_common.mk
File metadata and controls
142 lines (131 loc) · 5 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
# =============================================================================
# .dev_common.mk — Deep cleanup and Python env helpers (local copy per project)
# =============================================================================
# Include from the project Makefile:
# include .dev_common.mk (git repos — file lives in repo root)
# include ../make/.dev_common.mk (non-git folders under dev/)
#
# Optional overrides in the project Makefile:
# VENV_DIR — virtualenv directory name (default: .venv)
# PYTHON — Python interpreter (default: python3)
# =============================================================================
PYTHON ?= python3
VENV_DIR ?= .venv
.PHONY: _dev_cleanall _dev_cleanall_caches _dev_cleanall_node \
_dev_cleanall_venvs _dev_cleanall_build _dev_cleanall_misc _dev_env
# ---------------------------------------------------------------------------
# cleanall — deep cleanup
# ---------------------------------------------------------------------------
_dev_cleanall: _dev_cleanall_caches _dev_cleanall_node _dev_cleanall_venvs \
_dev_cleanall_build _dev_cleanall_misc
@echo "✓ Deep cleanup finished in $(notdir $(CURDIR))"
_dev_cleanall_caches:
@echo "→ Python / Jupyter / linter caches…"
@find . \
\( -path './.git' -o -path './.git/*' \) -prune -o \
-type d \( \
-name '__pycache__' -o \
-name '.ipynb_checkpoints' -o \
-name '.pytest_cache' -o \
-name '.mypy_cache' -o \
-name '.ruff_cache' -o \
-name '.hypothesis' -o \
-name '.tox' \
\) -print 2>/dev/null \
| while IFS= read -r d; do [ -n "$$d" ] && rm -rf "$$d"; done || true
@find . \
\( -path './.git' -o -path './.git/*' \) -prune -o \
-type f \( \
-name '*.py[cod]' -o \
-name '*$$py.class' -o \
-name '.DS_Store' -o \
-name 'Thumbs.db' -o \
-name '*.swp' -o \
-name '*~' -o \
-name '#*#' \
\) -print -delete 2>/dev/null || true
_dev_cleanall_node:
@echo "→ Node.js / npm artifacts…"
@find . \
\( -path './.git' -o -path './.git/*' \) -prune -o \
-type d \( \
-name 'node_modules' -o \
-name '.next' -o \
-name '.nuxt' -o \
-name '.turbo' -o \
-name '.parcel-cache' -o \
-name '.svelte-kit' \
\) -print 2>/dev/null \
| while IFS= read -r d; do [ -n "$$d" ] && rm -rf "$$d"; done || true
@find . \
\( -path './.git' -o -path './.git/*' \) -prune -o \
-type d -name 'out' -path '*/apps/*' -print 2>/dev/null \
| while IFS= read -r d; do [ -n "$$d" ] && rm -rf "$$d"; done || true
@find . \
\( -path './.git' -o -path './.git/*' \) -prune -o \
-type f \( -name 'npm-debug.log*' -o -name 'yarn-error.log' -o -name '.eslintcache' \) \
-print -delete 2>/dev/null || true
_dev_cleanall_venvs:
@echo "→ Python virtual environments…"
@for d in .venv venv env .devenv .tox; do \
if [ -d "$$d" ]; then \
echo " rm -rf $$d"; \
rm -rf "$$d" || true; \
fi; \
done; \
find . -maxdepth 3 \
\( -path './.git' -o -path './.git/*' \) -prune -o \
-type d -name 'bin' -print 2>/dev/null \
| while IFS= read -r bindir; do \
venv="$$(dirname "$$bindir")"; \
if [ -f "$$bindir/activate" ] || [ -f "$$venv/pyvenv.cfg" ]; then \
case "$$venv" in \
./.venv|./venv|./env|./.devenv|./.tox) continue ;; \
esac; \
echo " rm -rf $$venv"; \
rm -rf "$$venv" || true; \
fi; \
done; \
true
_dev_cleanall_build:
@echo "→ Python build artifacts…"
@find . \
\( -path './.git' -o -path './.git/*' \) -prune -o \
-type d \( \
-name 'build' -o \
-name 'dist' -o \
-name '*.egg-info' -o \
-name 'htmlcov' -o \
-name '.eggs' \
\) -print 2>/dev/null \
| while IFS= read -r d; do [ -n "$$d" ] && rm -rf "$$d"; done || true
@find . \
\( -path './.git' -o -path './.git/*' \) -prune -o \
-type f \( -name '.coverage' -o -name 'coverage.xml' \) \
-print -delete 2>/dev/null || true
_dev_cleanall_misc:
@echo "→ Misc temporary files…"
@find . \
\( -path './.git' -o -path './.git/*' \) -prune -o \
-type d \( -name '.cache' -o -name '.sass-cache' \) -print 2>/dev/null \
| while IFS= read -r d; do [ -n "$$d" ] && rm -rf "$$d"; done || true
# ---------------------------------------------------------------------------
# env — create Python virtual environment
# ---------------------------------------------------------------------------
_dev_env:
@echo "→ Creating virtual environment in $(VENV_DIR)…"
@test -d $(VENV_DIR) || $(PYTHON) -m venv $(VENV_DIR)
@. $(VENV_DIR)/bin/activate && pip install --upgrade pip
@if [ -f requirements.txt ]; then \
echo "→ Installing requirements.txt…"; \
. $(VENV_DIR)/bin/activate && pip install -r requirements.txt; \
fi
@if [ -f requirements-dev.txt ]; then \
echo "→ Installing requirements-dev.txt…"; \
. $(VENV_DIR)/bin/activate && pip install -r requirements-dev.txt; \
fi
@if [ -f setup.py ] || [ -f pyproject.toml ]; then \
echo "→ Installing package in editable mode…"; \
. $(VENV_DIR)/bin/activate && pip install -e .; \
fi
@echo "✓ Environment ready. Activate with: source $(VENV_DIR)/bin/activate"