()
| 136 | |
| 137 | |
| 138 | def _bootstrap_dependencies(): |
| 139 | required_modules = [ |
| 140 | ("flask", "flask"), |
| 141 | ("requests", "requests"), |
| 142 | ("phonenumbers", "phonenumbers"), |
| 143 | ("dns", "dnspython"), |
| 144 | ("telethon", "telethon"), |
| 145 | ("bs4", "bs4"), |
| 146 | ("whois", "python-whois"), |
| 147 | ("pycountry", "pycountry"), |
| 148 | ("fpdf", "fpdf2"), |
| 149 | ("numpy", "numpy"), |
| 150 | ("exifread", "exifread"), |
| 151 | ("imageio_ffmpeg", "imageio-ffmpeg"), |
| 152 | ("cryptography", "cryptography"), |
| 153 | ("keyring", "keyring"), |
| 154 | ] |
| 155 | optional_modules = [ |
| 156 | ("playwright", "playwright"), |
| 157 | ("greenlet", "greenlet"), |
| 158 | ("insightface", "insightface"), |
| 159 | ] |
| 160 | ok = True |
| 161 | installed_any = False |
| 162 | optional_ok = True |
| 163 | for module_name, package_name in required_modules: |
| 164 | try: |
| 165 | importlib.import_module(module_name) |
| 166 | except ModuleNotFoundError: |
| 167 | print(f"[*] Modulo mancante: {module_name} -> installo {package_name}...") |
| 168 | if not _install_python_package(package_name): |
| 169 | print(f"[!] Errore installazione {package_name}") |
| 170 | ok = False |
| 171 | continue |
| 172 | installed_any = True |
| 173 | importlib.invalidate_caches() |
| 174 | try: |
| 175 | importlib.import_module(module_name) |
| 176 | except Exception as e: |
| 177 | print(f"[!] Installato {package_name} ma import ancora fallito per {module_name}: {e}") |
| 178 | ok = False |
| 179 | continue |
| 180 | except Exception as e: |
| 181 | if module_name == "playwright" and "_greenlet" in str(e): |
| 182 | print("[*] Errore su playwright/_greenlet, provo reinstallazione greenlet...") |
| 183 | _install_python_package("greenlet") |
| 184 | if module_name == "greenlet" and "_greenlet" in str(e): |
| 185 | print("[*] Errore critico su greenlet, provo reinstallazione...") |
| 186 | _install_python_package("greenlet") |
| 187 | try: |
| 188 | importlib.import_module(module_name) |
| 189 | except Exception as e2: |
| 190 | print(f"[!] Import errore per {module_name} dopo reinstall: {e2}") |
| 191 | ok = False |
| 192 | continue |
| 193 | for module_name, package_name in optional_modules: |
| 194 | try: |
| 195 | importlib.import_module(module_name) |
no test coverage detected