forked from firka/student-legacy
automagically install packages that are needed
This commit is contained in:
parent
7d6d659933
commit
49b98e8b10
35
tools.py
35
tools.py
@ -1,3 +1,37 @@
|
||||
import importlib.util
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def install(package):
|
||||
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
||||
|
||||
# List of required packages
|
||||
required_packages = [
|
||||
"console-menu",
|
||||
"bottombar"
|
||||
]
|
||||
|
||||
# Check for missing packages
|
||||
missing_packages = []
|
||||
for package in required_packages:
|
||||
spec = importlib.util.find_spec(package)
|
||||
if spec is None:
|
||||
missing_packages.append(package)
|
||||
|
||||
# If missing packages are found, ask the user whether to install them
|
||||
if missing_packages:
|
||||
print("The following packages are required but not installed:")
|
||||
for package in missing_packages:
|
||||
print(f"- {package}")
|
||||
install_input = input("Do you want to install them? (yes/no): ").strip().lower()
|
||||
if install_input == "yes" or install_input == "y":
|
||||
for package in missing_packages:
|
||||
print(f"Installing '{package}'...")
|
||||
install(package)
|
||||
else:
|
||||
print("Missing packages were not installed. Exiting...")
|
||||
sys.exit()
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import threading
|
||||
@ -9,6 +43,7 @@ import bottombar as bb
|
||||
from datetime import datetime
|
||||
import random
|
||||
|
||||
|
||||
logo = """
|
||||
|
||||
\033[1m\033[94m _____ \033[0m_\033[94m _\033[0m sssssssssssssssssssssssssssssssssss
|
||||
|
Loading…
x
Reference in New Issue
Block a user