Skip to content

Commit b5cc486

Browse files
committed
chore: Makefile init/clean improvements; sync CONTRIBUTING
1 parent f73a2c4 commit b5cc486

2 files changed

Lines changed: 57 additions & 41 deletions

File tree

CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ This project adheres to the [Contributor Covenant Code of Conduct](https://www.c
3939
1. Fork the repository on GitHub, then clone your fork and go into the project directory:
4040

4141
```bash
42-
git clone https://github.com/YOUR_USERNAME/timerun.git
42+
git clone https://github.com/HH-MWB/timerun.git
4343
cd timerun
4444
```
4545

46-
2. Run `make init`. This creates a `.venv`, installs the package in editable mode with dev and docs dependencies (Zensical), and installs pre-commit hooks.
46+
2. Run `make init`. You will be prompted to choose a Python interpreter (press Enter for `python3`, or type e.g. `python3.10`). To skip the prompt, run `make init PYTHON=python3.10` (or another 3.10+ interpreter). This creates a `.venv`, installs the package in editable mode with dev and docs dependencies (Zensical), and installs pre-commit hooks.
4747

4848
3. Optionally activate the venv for interactive use: `source .venv/bin/activate` (Windows: `.venv\Scripts\activate`). You can run `make test` and `make lint` without activating.
4949

@@ -57,13 +57,13 @@ This project adheres to the [Contributor Covenant Code of Conduct](https://www.c
5757
Use the Makefile for common tasks. Run `make help` for the full list.
5858

5959
- **`make help`** — Show all targets and descriptions
60-
- **`make init`** — Set up venv, install package and dev + docs deps (Zensical), install pre-commit hooks
60+
- **`make init`** — Prompts for Python interpreter (default: `python3`); set `PYTHON` to skip (e.g. `make init PYTHON=python3.10`). Sets up venv, installs package and dev + docs deps (Zensical), installs pre-commit hooks.
61+
- **`make clean`** — Remove all files and directories listed in `.gitignore` (inverse of init)
6162
- **`make test`** — Run BDD tests with coverage (summary output)
6263
- **`make test-verbose`** — Run BDD tests with full scenario/step output (for debugging)
63-
- **`make lint`** — Run pre-commit (format and lint) on all files
6464
- **`make docs`** — Serve the docs locally (http://127.0.0.1:8000)
6565
- **`make docs-build`** — Build the docs site (output in `site/`; config: `zensical.toml`)
66-
- **`make clean`**Remove venv, caches, build artifacts, and `site/`
66+
- **`make lint`**Run pre-commit (format and lint) on all files
6767

6868
## Testing
6969

@@ -119,7 +119,7 @@ timerun/
119119
├── zensical.toml # Docs site config (Zensical)
120120
├── docs/ # Docs source (Markdown)
121121
├── timerun.py # Library (single-file by design)
122-
├── Makefile # Commands: init, check-venv, test, lint, docs, docs-build, clean, help
122+
├── Makefile # Commands: init, test, test-verbose, lint, docs, docs-build, clean, help
123123
├── README.md
124124
├── CODE_OF_CONDUCT.md
125125
├── CONTRIBUTING.md

Makefile

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
# TimeRun - Makefile
22
#
3-
# This Makefile provides convenient commands for development environment setup,
4-
# testing, linting, and project management. Requirements: Python 3.10+, pip.
3+
# Commands for development setup, testing, linting, and docs.
4+
# Requires Python 3.10+ and pip.
55
#
6-
# Usage:
7-
# make [target]
8-
# make help # Display available targets and descriptions
6+
#Usage: make [target] (run "make help" for all targets)
97

108
# ============================================================================
119
# Configuration (edit only the "Editable" block if needed)
1210
# ============================================================================
1311

14-
# Editable: change these to match your environment
12+
# ---- Editable ----
13+
# PYTHON: Interpreter for "make init". Empty = prompt; set to skip.
14+
PYTHON ?=
15+
# VENV_DIR: Virtualenv directory (e.g. .venv or venv).
1516
VENV_DIR := .venv
16-
PYTHON := python3
1717

18-
# Derived: do not edit (computed from above or project layout)
19-
VENV_BIN := $(VENV_DIR)/bin
20-
CLEAN_RM := $(VENV_DIR) .mypy_cache .ruff_cache .coverage htmlcov site
21-
CLEAN_GLOB := *.egg-info
18+
# ---- Do Not Edit ----
2219
COVERAGE_SOURCE := timerun
20+
VENV_BIN := $(VENV_DIR)/bin
21+
GITIGNORE_PATHS := \
22+
.gitignore \
23+
$(VENV_DIR) \
24+
.mypy_cache \
25+
.ruff_cache \
26+
.coverage \
27+
htmlcov \
28+
site
29+
GITIGNORE_GLOBS := \
30+
*.pyc \
31+
*.egg-info \
32+
__pycache__
2333

2434
# Default target when no target is specified
2535
.DEFAULT_GOAL := help
@@ -50,15 +60,37 @@ help: ## Display this help message with all available targets
5060
##@ Environment
5161

5262
.PHONY: init
53-
init: ## Set up Python development environment (dev + docs deps) and pre-commit hooks
54-
@echo "Setting up TimeRun development environment..."
55-
@test -d "$(VENV_DIR)" || $(PYTHON) -m venv "$(VENV_DIR)" >/dev/null 2>&1
56-
@$(VENV_BIN)/pip install -e ".[dev,docs]" >/dev/null 2>&1
57-
@$(VENV_BIN)/pip install pre-commit >/dev/null 2>&1
58-
@$(VENV_BIN)/pre-commit install >/dev/null 2>&1
63+
init: ## Set up dev env. Prompts for Python, or: make init PYTHON=python3.10
64+
@set -f; \
65+
printf '%s\n' $(GITIGNORE_PATHS) $(GITIGNORE_GLOBS) > .gitignore; \
66+
set +f;
67+
@if [ -n "$(PYTHON)" ]; then \
68+
py="$(PYTHON)"; \
69+
elif [ -t 0 ]; then \
70+
read -p "Which Python interpreter? [python3]: " py; \
71+
py=$${py:-python3}; \
72+
else \
73+
py=python3; \
74+
fi; \
75+
if [ ! -d "$(VENV_DIR)" ]; then $$py -m venv "$(VENV_DIR)" >/dev/null; fi
76+
@$(VENV_BIN)/pip install --upgrade pip >/dev/null
77+
@$(VENV_BIN)/pip install -e ".[dev,docs]" >/dev/null
78+
@$(VENV_BIN)/pip install pre-commit >/dev/null
79+
@$(VENV_BIN)/pre-commit install >/dev/null
5980

81+
.PHONY: clean
82+
clean: ## Remove all files/dirs listed in .gitignore (inverse of init)
83+
@rm -rf $(GITIGNORE_PATHS)
84+
@set -f; \
85+
for p in $(GITIGNORE_GLOBS); do \
86+
find . -not -path './.git/*' -name "$$p" \
87+
-exec rm -rf {} + 2>/dev/null || true; \
88+
done; \
89+
set +f
90+
91+
# Internal: used by test, docs, lint; not shown in help
6092
.PHONY: check-venv
61-
check-venv: ## Ensure virtual environment exists and timerun is installed (internal)
93+
check-venv:
6294
@if [ ! -d "$(VENV_DIR)" ]; then \
6395
echo "Error: $(VENV_DIR) not found!"; \
6496
echo "Please run 'make init' to create the development environment."; \
@@ -76,15 +108,11 @@ check-venv: ## Ensure virtual environment exists and timerun is installed (inter
76108

77109
##@ Testing
78110

79-
# BEHAVE_ARGS set per target: -f null for quiet, empty for verbose
80111
.PHONY: test
81112
test: BEHAVE_ARGS := -f null
82-
test: check-venv ## Run BDD tests (summary + coverage; failures show which scenario failed)
83-
@$(VENV_BIN)/coverage run --source=$(COVERAGE_SOURCE) -m behave $(BEHAVE_ARGS)
84-
@$(VENV_BIN)/coverage report --show-missing
113+
test: test-verbose ## Run BDD tests (summary + coverage; failures show which scenario failed)
85114

86115
.PHONY: test-verbose
87-
test-verbose: BEHAVE_ARGS :=
88116
test-verbose: check-venv ## Run BDD tests with full scenario/step output (for debugging failures)
89117
@$(VENV_BIN)/coverage run --source=$(COVERAGE_SOURCE) -m behave $(BEHAVE_ARGS)
90118
@$(VENV_BIN)/coverage report --show-missing
@@ -112,15 +140,3 @@ docs-build: check-venv ## Build the docs site (output in site/); ensures site/.g
112140
.PHONY: lint
113141
lint: check-venv ## Run pre-commit (lint and format checks) on all files
114142
@$(VENV_BIN)/pre-commit run --all-files
115-
116-
# ============================================================================
117-
# Cleanup Targets
118-
# ============================================================================
119-
120-
##@ Cleanup
121-
122-
.PHONY: clean
123-
clean: ## Remove temporary files, caches, and virtual environment
124-
@rm -rf $(CLEAN_RM) $(CLEAN_GLOB)
125-
@find . -name "*.pyc" -delete 2>/dev/null || true
126-
@find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true

0 commit comments

Comments
 (0)