|
| 1 | +#!/usr/bin/env bash |
| 2 | +# /qompassai/python/scripts/setup.sh |
| 3 | +# Copyright (C) 2025 Qompass AI, All rights reserved |
| 4 | +# ------------------------------------- |
| 5 | +set -euo pipefail |
| 6 | + |
| 7 | +echo "Creating Python environment directories..." |
| 8 | +mkdir -p "$HOME/.cache/black" |
| 9 | +mkdir -p "$HOME/.cache/huggingface" |
| 10 | +mkdir -p "$HOME/.cache/mypy" |
| 11 | +mkdir -p "$HOME/.cache/numba" |
| 12 | +mkdir -p "$HOME/.cache/poetry" |
| 13 | +mkdir -p "$HOME/.cache/pre-commit" |
| 14 | +mkdir -p "$HOME/.cache/pytest" |
| 15 | +mkdir -p "$HOME/.cache/torch" |
| 16 | +mkdir -p "$HOME/.config/ipython" |
| 17 | +mkdir -p "$HOME/.config/jupyter" |
| 18 | +mkdir -p "$HOME/.config/matplotlib" |
| 19 | +mkdir -p "$HOME/.config" # For pythonrc.py |
| 20 | +mkdir -p "$HOME/.local/share/poetry" |
| 21 | +mkdir -p "$HOME/.virtualenvs" |
| 22 | +PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') |
| 23 | +mkdir -p "$HOME/.local/lib/python${PYTHON_VERSION}/site-packages" |
| 24 | +chmod 755 "$HOME/.cache" "$HOME/.config" "$HOME/.local" "$HOME/.virtualenvs" 2>/dev/null || true |
| 25 | +chmod -R 755 "$HOME/.cache"/* "$HOME/.config"/* "$HOME/.local"/* 2>/dev/null || true |
| 26 | +if [[ ! -f "$HOME/.config/pythonrc.py" ]]; then |
| 27 | + cat > "$HOME/.config/pythonrc.py" << 'EOF' |
| 28 | +# Python startup configuration |
| 29 | +import sys |
| 30 | +import os |
| 31 | +try: |
| 32 | + import readline |
| 33 | + import rlcompleter |
| 34 | + readline.parse_and_bind("tab: complete") |
| 35 | +except ImportError: |
| 36 | + pass |
| 37 | +
|
| 38 | +# Add current directory to path if not already there |
| 39 | +if '.' not in sys.path: |
| 40 | + sys.path.insert(0, '.') |
| 41 | +
|
| 42 | +print(f"Python {sys.version} on {sys.platform}") |
| 43 | +print(f"PYTHONPATH: {os.environ.get('PYTHONPATH', 'Not set')}") |
| 44 | +EOF |
| 45 | + echo "Created $HOME/.config/pythonrc.py" |
| 46 | +fi |
| 47 | +echo "✅ All Python environment directories created successfully!" |
| 48 | +echo "✅ Python startup file created at $HOME/.config/pythonrc.py" |
| 49 | +echo "" |
| 50 | +echo "Created directories:" |
| 51 | +echo " 📁 Cache: ~/.cache/{black,huggingface,mypy,numba,poetry,pre-commit,pytest,torch}" |
| 52 | +echo " 📁 Config: ~/.config/{ipython,jupyter,matplotlib}" |
| 53 | +echo " 📁 Local: ~/.local/share/poetry" |
| 54 | +echo " 📁 Python: ~/.local/lib/python${PYTHON_VERSION}/site-packages" |
| 55 | +echo " 📁 Virtual envs: ~/.virtualenvs" |
0 commit comments