#!/usr/bin/env python3 """ OverCode Shell Setup Script Automated installation with shortcuts and dependencies """ import os import sys import subprocess import shutil import winreg from pathlib import Path def create_desktop_shortcut(target_path, shortcut_name, description="", icon_path=""): """Create a desktop shortcut""" try: import win32com.client desktop = Path.home() / "Desktop" shortcut_path = desktop / f"{shortcut_name}.lnk" shell = win32com.client.Dispatch("WScript.Shell") shortcut = shell.CreateShortCut(str(shortcut_path)) shortcut.Targetpath = str(target_path) shortcut.WorkingDirectory = str(target_path.parent) shortcut.Description = description if icon_path: shortcut.IconLocation = icon_path shortcut.save() return True except ImportError: print("Warning: Could not create desktop shortcut (pywin32 not available)") return False except Exception as e: print(f"Warning: Failed to create desktop shortcut: {e}") return False def create_start_menu_shortcut(target_path, shortcut_name, description=""): """Create Start Menu shortcut""" try: import win32com.client start_menu = Path.home() / "AppData/Roaming/Microsoft/Windows/Start Menu/Programs" overcode_folder = start_menu / "OverCode" overcode_folder.mkdir(exist_ok=True) shortcut_path = overcode_folder / f"{shortcut_name}.lnk" shell = win32com.client.Dispatch("WScript.Shell") shortcut = shell.CreateShortCut(str(shortcut_path)) shortcut.Targetpath = str(target_path) shortcut.WorkingDirectory = str(target_path.parent) shortcut.Description = description shortcut.save() return True except Exception as e: print(f"Warning: Failed to create Start Menu shortcut: {e}") return False def install_dependencies(): """Install Python dependencies""" print("Installing dependencies...") try: subprocess.run([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"], check=True, cwd=Path(__file__).parent) print("✓ Dependencies installed successfully!") return True except subprocess.CalledProcessError as e: print(f"✗ Failed to install dependencies: {e}") return False def add_to_path(): """Add OverCode to Windows PATH""" try: current_dir = str(Path(__file__).parent.absolute()) with winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Environment", 0, winreg.KEY_ALL_ACCESS) as key: try: current_path, _ = winreg.QueryValueEx(key, "PATH") except FileNotFoundError: current_path = "" if current_dir not in current_path: new_path = f"{current_path};{current_dir}" if current_path else current_dir winreg.SetValueEx(key, "PATH", 0, winreg.REG_EXPAND_SZ, new_path) print("✓ Added OverCode to PATH") return True else: print("✓ OverCode already in PATH") return True except Exception as e: print(f"Warning: Could not add to PATH: {e}") return False def main(): """Main setup function""" print("=" * 60) print(" OverCode Shell Setup & Installation") print("=" * 60) setup_dir = Path(__file__).parent os.chdir(setup_dir) # Check Python version if sys.version_info < (3, 8): print("✗ Error: Python 3.8 or higher is required!") input("Press Enter to exit...") return False print(f"✓ Python {sys.version.split()[0]} detected") # Install dependencies if not install_dependencies(): input("Press Enter to exit...") return False # Try to install pywin32 for shortcuts try: subprocess.run([sys.executable, "-m", "pip", "install", "pywin32"], check=True) print("✓ Shortcut support installed") except subprocess.CalledProcessError: print("Warning: Could not install shortcut support") # Create shortcuts batch_launcher = setup_dir / "launch_overcode.bat" ps_launcher = setup_dir / "launch_overcode.ps1" shortcuts_created = 0 if batch_launcher.exists(): if create_desktop_shortcut(batch_launcher, "OverCode Shell", "Enhanced Polyglot Programming Environment"): shortcuts_created += 1 print("✓ Desktop shortcut created") if create_start_menu_shortcut(batch_launcher, "OverCode Shell", "Enhanced Polyglot Programming Environment"): shortcuts_created += 1 print("✓ Start Menu shortcut created") # Add to PATH add_to_path() print("\\n" + "=" * 60) print(" 🎉 INSTALLATION COMPLETE! 🎉") print("=" * 60) print("\\nOverCode Shell has been successfully installed!") print("\\nTo launch OverCode Shell:") print(" • Use the desktop shortcut") print(" • Use the Start Menu shortcut") print(" • Run 'launch_overcode.bat' from this folder") print(" • Or run 'python overshell.py' directly") if shortcuts_created > 0: print(f"\\n✓ {shortcuts_created} shortcuts created") print("\\nPress Enter to launch OverCode Shell now...") input() # Launch OverCode Shell try: subprocess.run([sys.executable, "overshell.py"]) except KeyboardInterrupt: print("\\nGoodbye! 👋") if __name__ == "__main__": main()