From eab65c74b543ab717d7d942235435c8bfa39f56d Mon Sep 17 00:00:00 2001 From: Bernd Worsch Date: Mon, 22 Sep 2025 00:18:24 +0200 Subject: [PATCH] build: Enhance venv-status to detect shell activation state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add venv-status target to check current shell activation - Detect if venv exists but not activated vs actively running - Handle different venv active vs project venv scenarios - Use realpath for robust path comparison across symlinks - Clean output with --no-print-directory flag - Integrate status check into help target 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- Makefile | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 941d7b6f..cb9f7d44 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,21 @@ # MarkiTect - Advanced Markdown Engine # Makefile for common development tasks -.PHONY: help setup install test build clean update status dev lint format check-deps +.PHONY: help setup install test build clean update status dev lint format check-deps venv-status # Default target help: @echo "MarkiTect Development Commands" @echo "==============================" @echo "" + @echo "Environment Status:" + @$(MAKE) --no-print-directory venv-status + @echo "" @echo "Setup & Installation:" @echo " setup - Initial project setup (venv + install)" @echo " install - Install package in development mode" @echo " dev - Install with development dependencies" + @echo " venv-status - Check if venv is active" @echo "" @echo "Development:" @echo " test - Run all tests" @@ -31,6 +35,23 @@ VENV := .venv VENV_PYTHON := $(VENV)/bin/python VENV_PIP := $(VENV)/bin/pip +# Check virtual environment status (read-only) +venv-status: + @if [ -f $(VENV)/bin/activate ] && [ -f $(VENV)/bin/python ]; then \ + if [ -n "$$VIRTUAL_ENV" ] && [ "$$VIRTUAL_ENV" = "$$(realpath $(VENV))" ]; then \ + echo " ✅ Virtual environment: Active in current shell"; \ + elif [ -n "$$VIRTUAL_ENV" ]; then \ + echo " ⚠️ Virtual environment: Different venv active ($$VIRTUAL_ENV)"; \ + echo " Run 'deactivate' then 'source $(VENV)/bin/activate'"; \ + else \ + echo " 📁 Virtual environment: Ready but not activated"; \ + echo " Run 'source $(VENV)/bin/activate' to activate"; \ + fi; \ + else \ + echo " ❌ Virtual environment: Not found"; \ + echo " Run 'make setup' to create and configure"; \ + fi + # Setup virtual environment and install package setup: $(VENV)/bin/activate install @echo "✅ Project setup complete!" @@ -133,4 +154,4 @@ check-deps: $(VENV)/bin/activate $(VENV_PIP) list @echo "" @echo "Project dependencies:" - $(VENV_PIP) check \ No newline at end of file + $(VENV_PIP) check