Spaces:
Runtime error
Runtime error
import subprocess | |
import gradio as gr | |
def install_pygit2(): | |
"""Installs pygit2 with a specific version (if necessary). | |
This function attempts to install pygit2 using pip. If installation | |
fails, it provides guidance on potential solutions. | |
""" | |
try: | |
subprocess.run(["pip", "install", "pygit2==1.12.2"], check=True) | |
print("pygit2 version 1.12.2 installed successfully.") | |
except subprocess.CalledProcessError: | |
print("Error installing pygit2. You might need to install it manually.") | |
print("For instructions, refer to the pygit2 documentation:") | |
print("https://www.pygit2.org/install.html") | |
def clone_and_run_fooocus(): | |
"""Clones the Fooocus repository and executes the entry_with_update.py script. | |
This function assumes the script is located in the project's root directory. | |
It provides informative messages throughout the process. | |
""" | |
print("Cloning the Fooocus repository...") | |
try: | |
subprocess.run(["git", "clone", "https://github.com/MoonRide303/Fooocus-MRE.git"], check=True) | |
print("Fooocus repository cloned successfully.") | |
print("Changing directory to Fooocus...") | |
# Use os.chdir() to change directories within Python | |
import os | |
os.chdir("Fooocus-MRE") | |
print("Executing entry_with_update.py...") | |
subprocess.run(["python", "entry_with_update.py", "--share", "--always-high-vram"], check=True) | |
print("Fooocus script execution complete.") | |
except subprocess.CalledProcessError as e: | |
print("An error occurred: {e}") | |
print("Please ensure you have Git and Python installed correctly.") | |
if __name__ == "__main__": | |
install_pygit2() | |
clone_and_run_fooocus() |