(package, is_pip=False)
| 97 | # DEPENDENCIES |
| 98 | # ───────────────────────────────────────────── |
| 99 | def install_dependency(package, is_pip=False): |
| 100 | if is_pip: |
| 101 | cmd = [sys.executable, "-m", "pip", "install", package] |
| 102 | info(f"Installing Python package: {package}") |
| 103 | else: |
| 104 | cmd = ["pkg", "install", "-y", package] |
| 105 | info(f"Installing system package: {package}") |
| 106 | |
| 107 | try: |
| 108 | result = subprocess.run(cmd, capture_output=True, text=True) |
| 109 | if result.returncode == 0: |
| 110 | success(f"Installed {package}") |
| 111 | return True |
| 112 | error(result.stderr.strip() or f"Could not install {package}") |
| 113 | return False |
| 114 | except Exception as exc: |
| 115 | error(f"Installation error for {package}: {exc}") |
| 116 | return False |
| 117 | |
| 118 | |
| 119 |
no test coverage detected