Suggestion for update For Immediate Instantiation into useable interface

Hello again, I am not sure if this is the correct place to post this; however I had previously suggested a download button be added to script prompt generation and I see that it has been added, however from Downloading a file to immediate Instantiation into a useable interface is not entirely there. While having to request a GUI(Graphical User Interface), as a specific detail (which any random person, not knowing of code terminology is unlikely to specify) leads to a result that is further confusing; is the first problem. The second is being unfamiliar with command line, how to install dependencies etc.. this means that when Ai supplies a working base, the user is likely to receive “what appears to be broken” they do not know powershell, they do not know command prompt.. thus we need to avoid the necessity of it. To do this we need to bootstrap inistantiate the result. by process of “write dependencies to requirements.txt → install requirements.txt → double window instantiate” the user also may be unfamiliar with the reality that these files need to exist within a specific directory, thus “%~d0” is used. I have a working bootloader for model dependency inject → install → self-reboot; while you may need to modify the code specifics relative to the design you are working on, you must keep “from future import annotations” at the top of import for this to work. Here is the code that I would like to share as a ‘Universal Boot System’ “=== bootloader.py === Version: 4.1 === | Last Updated: 07-11-25 === 23:59:00 |

“”"
Author: Jeremiah Lucio
──────────────────────────────────────────────────────────────────────
Universal Bootloader – Handles dependency injection + self-rebooting
──────────────────────────────────────────────────────────────────────
• Intercepts --boot flag from any module
• Writes missing imports to requirements.txt in calling directory
• Marks module for reboot using # REBOOT: <ModuleName>
• Installs all dependencies then restarts the module
• Works regardless of current bootloader location (uses %~d0 or sys.path)
• Supports double-window instantiation
• Automatically loops back on itself for second-phase install and module reboot

Compatible with: All Python modules wanting universal auto-injection.
“”"

from future import annotations

import os
import sys
import subprocess
import traceback
import re
from pathlib import Path

#=== CONFIGURATION ===

BOOTLOADER_PATH = Path(file).resolve()
CALLED_MODULE = Path(sys.argv[0]).resolve()
CALLED_DIR = CALLED_MODULE.parent
REQUIREMENTS_PATH = CALLED_DIR / “requirements.txt”

#=== STEP 1: DETECT FIRST PASS ===

def is_first_pass():
return not REQUIREMENTS_PATH.exists()

#=== STEP 2: PARSE MISSING MODULE NAME ===

def get_missing_module_from_error(output):
match = re.search(r"ModuleNotFoundError: No module named ‘(.*?)’", output)
return match.group(1) if match else None

#=== STEP 3: CREATE REQUIREMENTS.TXT ===

def write_requirements(module_name):
with REQUIREMENTS_PATH.open(“w”, encoding=“utf-8”) as f:
f.write(“numpy\n”) # Always include numpy
f.write(f"{module_name}\n")
f.write(f"# REBOOT: {CALLED_MODULE.name}\n")
print(f"[BOOTLOADER] requirements.txt written for: {module_name}")

#=== STEP 4: INSTALL MODULES ===

def install_requirements():
subprocess.call([sys.executable, “-m”, “pip”, “install”, “-r”, str(REQUIREMENTS_PATH)])

#=== STEP 5: GET REBOOT TARGET ===

def get_reboot_target():
with REQUIREMENTS_PATH.open(“r”, encoding=“utf-8”) as f:
for line in f:
if line.startswith("# REBOOT: “):
return line.strip().split(”: ")[1]
return None

#=== STEP 6: DOUBLE-WINDOW INSTANTIATION ===

def open_second_window(target_path):
if os.name == “nt”: # Windows
subprocess.Popen([“start”, “”, sys.executable, str(target_path)], shell=True)
else:
subprocess.Popen([sys.executable, str(target_path)])

#=== STEP 7: MAIN LOGIC ===

def main():
if is_first_pass():
print(“[BOOTLOADER] First pass – capturing missing module…”)
try:
subprocess.run([sys.executable, str(CALLED_MODULE)], check=True, capture_output=True, text=True)
except subprocess.CalledProcessError as e:
missing = get_missing_module_from_error(e.stderr)
if missing:
write_requirements(missing)
print(“[BOOTLOADER] Relaunching bootloader to install dependencies…”)
subprocess.run([sys.executable, str(BOOTLOADER_PATH)], check=True)
sys.exit()
else:
print(“[BOOTLOADER] No missing module detected.”)
print(e.stderr)
sys.exit(1)
else:
print(“[BOOTLOADER] Second pass – installing and rebooting…”)
install_requirements()
target = get_reboot_target()
if target:
print(f"[BOOTLOADER] Rebooting {target}…")
open_second_window(CALLED_DIR / target)

if name == “main”:
from future import annotations
main()

#=== END OF SCRIPT === | MODULE OF: universal boot system |” P.S If this isn’t the correct place for this post, be a good administrator and simple push it to where it needs to be instead of flagging it and telling it is the wrong place. :slight_smile: <3 : edit.. I do not know how to drop in code logic properly, you will need to correct indentations sorry.