diff --git a/Makefile b/Makefile index 521206ce..5df7d1d1 100644 --- a/Makefile +++ b/Makefile @@ -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