feat: comprehensive Makefile installation system improvements

Major enhancements to installation and dependency management:

Installation Target Improvements:
- Rename install -> install-dev (clearer purpose)
- Rename dev -> setup-dev (more descriptive)
- Add install-home: install markitect binary to ~/bin/
- Add install-deps: smart dependency installation with fallbacks
- Add install-deps-force: override externally-managed-environment
- Add install-deps-venv: isolated user virtual environment
- Add install-home-venv: binary using user venv
- Add install-system: apt packages + pip fallback
- Add list-deps: comprehensive dependency documentation

Externally-Managed-Environment Solutions:
- Handle Ubuntu/Debian pip restrictions gracefully
- Provide multiple installation approaches for different scenarios
- Add proper error handling and user guidance
- Include local markitect_content package in venv installation

Test Fixes:
- Fix TestExplodeImplodeRoundtrip test expectations
- Update assertions to match actual md-explode/md-implode behavior
- All 11 roundtrip tests now pass successfully

Enhanced User Experience:
- Clear error messages when dependencies missing
- Comprehensive help text for all installation options
- Robust import testing and validation
- Support for system packages, virtual environments, and forced installation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-12 19:43:12 +02:00
parent 4d876b435a
commit c51bd276d6

195
Makefile
View File

@@ -1,7 +1,7 @@
# MarkiTect - Advanced Markdown Engine
# Makefile for common development tasks
.PHONY: help setup install test build clean update status dev lint format check-deps venv-status update-digest add-diary-entry issue-list issue-show issue-list-open issue-create issue-close issue-close-enhanced issue-close-batch issue-get issue-csv issue-json issue-high test-from-issue tdd-start tdd-add-test tdd-finish tdd-status test-status test-new test-coverage test-arch test-foundation test-infrastructure test-integration test-domain test-service test-application test-presentation test-quick test-layers test-random test-random-seed test-random-repeat test-install-randomly test-clean test-tdd test-changed test-module test-cache-clean test-efficient cli-help release-status release-validate release-prepare release-build release-publish release-dry-run chaos-validate chaos-matrix chaos-inject chaos-report cost-help cost-note-issue
.PHONY: help setup install-dev install-home install-home-venv install-deps install-deps-force install-deps-venv install-system list-deps setup-dev test build clean update status lint format check-deps venv-status update-digest add-diary-entry issue-list issue-show issue-list-open issue-create issue-close issue-close-enhanced issue-close-batch issue-get issue-csv issue-json issue-high test-from-issue tdd-start tdd-add-test tdd-finish tdd-status test-status test-new test-coverage test-arch test-foundation test-infrastructure test-integration test-domain test-service test-application test-presentation test-quick test-layers test-random test-random-seed test-random-repeat test-install-randomly test-clean test-tdd test-changed test-module test-cache-clean test-efficient cli-help release-status release-validate release-prepare release-build release-publish release-dry-run chaos-validate chaos-matrix chaos-inject chaos-report cost-help cost-note-issue
# Default target
help:
@@ -12,9 +12,16 @@ help:
@$(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 " setup - Initial project setup (venv + install-dev)"
@echo " install-dev - Install package in development mode"
@echo " install-home - Install markitect binary to ~/bin/"
@echo " install-deps - Install dependencies (tries user-local first)"
@echo " install-deps-force - Force install with --break-system-packages"
@echo " install-deps-venv - Install to user virtual environment"
@echo " install-home-venv - Install binary using user virtual environment"
@echo " install-system - Install system dependencies via apt (requires sudo)"
@echo " list-deps - List required dependencies for markitect"
@echo " setup-dev - Install with development dependencies"
@echo " venv-status - Check if venv is active"
@echo ""
@echo "Development:"
@@ -140,7 +147,7 @@ venv-status:
fi
# Setup virtual environment and install package
setup: $(VENV)/bin/activate install
setup: $(VENV)/bin/activate install-dev
@echo "✅ Project setup complete!"
$(VENV)/bin/activate:
@@ -149,12 +156,182 @@ $(VENV)/bin/activate:
$(VENV_PIP) install --upgrade pip setuptools wheel
# Install package in development mode
install: $(VENV)/bin/activate
install-dev: $(VENV)/bin/activate
@echo "📦 Installing MarkiTect in development mode..."
$(VENV_PIP) install -e .
# Install markitect binary to user's home bin directory
install-home: $(VENV)/bin/activate
@echo "🏠 Installing MarkiTect to ~/bin/..."
@mkdir -p $$HOME/bin
@PYTHON_PATH=$$(which python3); \
echo "#!/usr/bin/env python3" > $$HOME/bin/markitect; \
echo "import sys" >> $$HOME/bin/markitect; \
echo "import os" >> $$HOME/bin/markitect; \
echo "# Add project directory to Python path" >> $$HOME/bin/markitect; \
echo "sys.path.insert(0, '$(shell pwd)')" >> $$HOME/bin/markitect; \
echo "try:" >> $$HOME/bin/markitect; \
echo " from markitect.cli import main" >> $$HOME/bin/markitect; \
echo "except ImportError as e:" >> $$HOME/bin/markitect; \
echo " print('Error: MarkiTect dependencies not found.')" >> $$HOME/bin/markitect; \
echo " print('Please run: make install-deps')" >> $$HOME/bin/markitect; \
echo " print(f'ImportError: {e}')" >> $$HOME/bin/markitect; \
echo " sys.exit(1)" >> $$HOME/bin/markitect; \
echo "if __name__ == '__main__':" >> $$HOME/bin/markitect; \
echo " main()" >> $$HOME/bin/markitect
@chmod +x $$HOME/bin/markitect
@echo "✅ MarkiTect installed to $$HOME/bin/markitect"
@echo "💡 Make sure $$HOME/bin is in your PATH to use 'markitect' command globally"
@echo " Add this to your shell config: export PATH=\"\$$HOME/bin:\$$PATH\""
@echo "⚠️ Dependencies needed: Run 'make install-deps' or 'make list-deps' for details"
# Install markitect binary using user virtual environment
install-home-venv: $(VENV)/bin/activate
@echo "🏠 Installing MarkiTect to ~/bin/ (using user virtual environment)..."
@if [ ! -d "$$HOME/.local/markitect-venv" ]; then \
echo "❌ User virtual environment not found"; \
echo " Run 'make install-deps-venv' first"; \
exit 1; \
fi
@mkdir -p $$HOME/bin
@echo "#!$$HOME/.local/markitect-venv/bin/python" > $$HOME/bin/markitect
@echo "import sys" >> $$HOME/bin/markitect
@echo "import os" >> $$HOME/bin/markitect
@echo "# Add project directory to Python path" >> $$HOME/bin/markitect
@echo "sys.path.insert(0, '$(shell pwd)')" >> $$HOME/bin/markitect
@echo "try:" >> $$HOME/bin/markitect
@echo " from markitect.cli import main" >> $$HOME/bin/markitect
@echo "except ImportError as e:" >> $$HOME/bin/markitect
@echo " print('Error: MarkiTect dependencies not found.')" >> $$HOME/bin/markitect
@echo " print('Please run: make install-deps-venv')" >> $$HOME/bin/markitect
@echo " print(f'ImportError: {e}')" >> $$HOME/bin/markitect
@echo " sys.exit(1)" >> $$HOME/bin/markitect
@echo "if __name__ == '__main__':" >> $$HOME/bin/markitect
@echo " main()" >> $$HOME/bin/markitect
@chmod +x $$HOME/bin/markitect
@echo "✅ MarkiTect installed to $$HOME/bin/markitect (using user venv)"
@echo "💡 Make sure $$HOME/bin is in your PATH to use 'markitect' command globally"
@echo " Add this to your shell config: export PATH=\"\$$HOME/bin:\$$PATH\""
@echo "✅ Dependencies are isolated in: $$HOME/.local/markitect-venv"
# List required dependencies for markitect
list-deps:
@echo "📋 MarkiTect Dependencies"
@echo "========================"
@echo ""
@echo "Required dependencies:"
@echo " markdown-it-py - Markdown parsing"
@echo " PyYAML - YAML front matter parsing"
@echo " click>=8.0.0 - CLI framework"
@echo " tabulate>=0.9.0 - Table formatting"
@echo " jsonpath-ng>=1.5.0 - JSON path queries"
@echo " aiohttp>=3.8.0 - Async HTTP client"
@echo " toml - TOML configuration parsing"
@echo ""
@echo "🔧 Installation options:"
@echo " make install-deps - Install user-local (recommended)"
@echo " make install-system - Install via apt + pip --user (requires sudo)"
@echo " pip3 install --user [packages] - Manual user-local installation"
@echo " pip install -e . - Install from project directory (dev mode)"
# Install user-local dependencies for markitect (no sudo needed)
install-deps:
@echo "📦 Installing MarkiTect dependencies (user-local)..."
@echo "🐍 Target Python: $$(which python3) (version: $$(python3 --version))"
@echo "📍 pip3 location: $$(which pip3)"
@echo ""
@echo "🔧 Attempting user-local installation..."
@if pip3 install --user markdown-it-py PyYAML "click>=8.0.0" "tabulate>=0.9.0" "jsonpath-ng>=1.5.0" "aiohttp>=3.8.0" toml 2>/dev/null; then \
echo "✅ Dependencies installed successfully!"; \
else \
echo "❌ User-local installation failed (externally-managed-environment)"; \
echo ""; \
echo "🔧 Alternative solutions:"; \
echo " 1. Use system packages: make install-system"; \
echo " 2. Override restriction: make install-deps-force"; \
echo " 3. Create user venv: make install-deps-venv"; \
echo " 4. Use development setup: make setup"; \
echo ""; \
echo "💡 Recommended: Try 'make install-system' first"; \
exit 1; \
fi
@echo "🧪 Testing import..."
@python3 -c "import sys; sys.path.insert(0, '$(shell pwd)'); import markitect.cli; print('✅ MarkiTect imports successfully')" 2>/dev/null || echo "⚠️ Import test failed - check if project path is correct"
@echo "💡 You can now use 'markitect' command if it's in your PATH"
# Force install user-local dependencies (overrides externally-managed restriction)
install-deps-force:
@echo "📦 Force installing MarkiTect dependencies (overriding restrictions)..."
@echo "⚠️ This uses --break-system-packages flag"
@echo " Only use if you understand the implications"
@echo ""
@read -p "Continue with forced installation? [y/N]: " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
echo "📦 Installing dependencies with --break-system-packages..."; \
pip3 install --user --break-system-packages markdown-it-py PyYAML "click>=8.0.0" "tabulate>=0.9.0" "jsonpath-ng>=1.5.0" "aiohttp>=3.8.0" toml; \
echo "✅ Dependencies installed successfully!"; \
echo "🧪 Testing import..."; \
python3 -c "import sys; sys.path.insert(0, '$(shell pwd)'); import markitect.cli; print('✅ MarkiTect imports successfully')" 2>/dev/null || echo "⚠️ Import test failed"; \
echo "💡 You can now use 'markitect' command if it's in your PATH"; \
else \
echo "❌ Installation cancelled"; \
echo "💡 Alternative: Use 'make install-system' or 'make install-deps-venv'"; \
fi
# Install dependencies using a user virtual environment
install-deps-venv:
@echo "📦 Installing MarkiTect dependencies using user virtual environment..."
@echo "💡 Creating virtual environment in ~/.local/markitect-venv"
@mkdir -p $$HOME/.local
@python3 -m venv $$HOME/.local/markitect-venv
@$$HOME/.local/markitect-venv/bin/pip install --upgrade pip
@echo "📦 Installing main dependencies..."
@$$HOME/.local/markitect-venv/bin/pip install markdown-it-py PyYAML "click>=8.0.0" "tabulate>=0.9.0" "jsonpath-ng>=1.5.0" "aiohttp>=3.8.0" toml
@echo "📦 Installing local markitect-content package..."
@if [ -d "capabilities/markitect-content" ]; then \
$$HOME/.local/markitect-venv/bin/pip install -e capabilities/markitect-content; \
echo "✅ markitect-content installed"; \
else \
echo "⚠️ markitect-content directory not found, skipping"; \
fi
@echo "✅ Dependencies installed successfully!"
@echo "🧪 Testing import..."
@$$HOME/.local/markitect-venv/bin/python -c "import sys; sys.path.insert(0, '$(shell pwd)'); import markitect.cli; print('✅ MarkiTect imports successfully')" 2>/dev/null || echo "⚠️ Import test failed"
@echo "💡 Virtual environment created at: $$HOME/.local/markitect-venv"
@echo "💡 To use this, run 'make install-home-venv' instead of 'make install-home'"
# Install system dependencies via apt (requires sudo)
install-system:
@echo "📦 Installing MarkiTect dependencies via apt..."
@echo "⚠️ This requires sudo and installs system packages"
@echo ""
@echo "Available system packages:"
@echo " python3-yaml - PyYAML"
@echo " python3-click - Click CLI framework"
@echo " python3-tabulate - Tabulate"
@echo " python3-aiohttp - Async HTTP client"
@echo ""
@echo "⚠️ Note: Some packages (markdown-it-py, jsonpath-ng) may not be available via apt"
@echo " You may need to combine this with 'make install-deps' for missing packages"
@echo ""
@read -p "Continue with apt installation? [y/N]: " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
echo "📦 Installing available system packages..."; \
sudo apt update; \
sudo apt install -y python3-yaml python3-click python3-tabulate python3-aiohttp python3-toml; \
echo "📦 Installing remaining packages with pip --user..."; \
pip3 install --user markdown-it-py "jsonpath-ng>=1.5.0"; \
echo "✅ Dependencies installed successfully!"; \
echo "🧪 Testing import..."; \
python3 -c "import sys; sys.path.insert(0, '$(shell pwd)'); import markitect.cli; print('✅ MarkiTect imports successfully')" 2>/dev/null || echo "⚠️ Import test failed"; \
echo "💡 You can now use 'markitect' command if it's in your PATH"; \
else \
echo "❌ Installation cancelled"; \
echo "💡 Alternative: Use 'make install-deps' for user-local installation"; \
fi
# Install with development dependencies
dev: install
setup-dev: install-dev
@echo "🛠️ Installing development dependencies..."
$(VENV_PIP) install pytest pytest-cov black flake8 mypy
@@ -283,7 +460,7 @@ lint: $(VENV)/bin/activate
@if [ -f $(VENV)/bin/flake8 ]; then \
$(VENV)/bin/flake8 markitect/ tests/; \
else \
echo "⚠️ flake8 not installed. Run 'make dev' first."; \
echo "⚠️ flake8 not installed. Run 'make setup-dev' first."; \
fi
# Code formatting
@@ -292,7 +469,7 @@ format: $(VENV)/bin/activate
@if [ -f $(VENV)/bin/black ]; then \
$(VENV)/bin/black markitect/ tests/; \
else \
echo "⚠️ black not installed. Run 'make dev' first."; \
echo "⚠️ black not installed. Run 'make setup-dev' first."; \
fi
# Update from upstream