-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (56 loc) · 1.86 KB
/
Makefile
File metadata and controls
66 lines (56 loc) · 1.86 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
# --- Portable Settings ---
VENV_DIR = .venv
KERNEL_NAME = your_notebook
NOTEBOOK_DIR = notebooks
SRC_DIR = src
# Detect operating system
ifeq ($(OS),Windows_NT)
# Windows (including PowerShell)
PYTHON = $(VENV_DIR)/Scripts/python.exe
PIP = $(VENV_DIR)/Scripts/pip.exe
RM_RF = if exist "$1" rmdir /s /q "$1"
MKDIR = if not exist "$1" mkdir "$1"
SHELL = cmd
else
# Unix-like systems (Linux, macOS, WSL)
PYTHON = $(VENV_DIR)/bin/python
PIP = $(VENV_DIR)/bin/pip
RM_RF = rm -rf $1
MKDIR = mkdir -p $1
endif
.PHONY: help init install reset-kernel clean test format
help:
@echo Available targets:
@echo " make init Create virtual environment and install dependencies"
@echo " make install Install project and dev tools"
@echo " make format Format code with black"
@echo " make test Run tests"
@echo " make clean Remove __pycache__ and checkpoints"
init:
python -m venv $(VENV_DIR)
$(PYTHON) -m pip install --upgrade pip
$(MAKE) install
install:
$(PIP) install -e
init-dev:
python -m venv $(VENV_DIR)
$(PYTHON) -m pip install --upgrade pip
$(PIP) install -e .[dev]
reset-kernel:
$(PYTHON) -m ipykernel install --user --name=$(KERNEL_NAME) --display-name="$(KERNEL_NAME)"
format: init-dev
$(PYTHON) -m black $(SRC_DIR)
$(PYTHON) -m black $(NOTEBOOK_DIR) --ipynb
test:
$(PYTHON) -m pytest tests/ -v
clean:
@echo Cleaning __pycache__ and .ipynb_checkpoints...
ifeq ($(OS),Windows_NT)
@for /d /r . %%d in (__pycache__) do @if exist "%%d" rmdir /s /q "%%d" 2>nul || echo.
@for /d /r . %%d in (.ipynb_checkpoints) do @if exist "%%d" rmdir /s /q "%%d" 2>nul || echo.
@del /s /q *.pyc 2>nul || echo.
else
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".ipynb_checkpoints" -exec rm -rf {} + 2>/dev/null || true
@find . -name "*.pyc" -delete 2>/dev/null || true
endif