From 143de5b0fcac01c43b8d9ec64f3abbb6760b847c Mon Sep 17 00:00:00 2001 From: bmaltais Date: Sat, 2 Mar 2024 14:51:09 -0500 Subject: [PATCH] Integrate cloning in linux setup script --- gui.sh | 3 +++ setup/setup_sd-scripts.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 setup/setup_sd-scripts.py diff --git a/gui.sh b/gui.sh index 022335125..4b8955924 100755 --- a/gui.sh +++ b/gui.sh @@ -50,6 +50,9 @@ if [[ -z "${LD_LIBRARY_PATH}" ]]; then echo -e " " fi +# Clone or checkout release branch if required: +python "$SCRIPT_DIR/setup/setup_sd-scripts.py" + # Determine the requirements file based on the system if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$(uname -m)" == "arm64" ]]; then diff --git a/setup/setup_sd-scripts.py b/setup/setup_sd-scripts.py new file mode 100644 index 000000000..37399e3fa --- /dev/null +++ b/setup/setup_sd-scripts.py @@ -0,0 +1,30 @@ +import os +import sys +import setup_common + +# Get the absolute path of the current file's directory (Kohua_SS project directory) +project_directory = os.path.dirname(os.path.abspath(__file__)) + +# Check if the "setup" directory is present in the project_directory +if "setup" in project_directory: + # If the "setup" directory is present, move one level up to the parent directory + project_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +# Add the project directory to the beginning of the Python search path +sys.path.insert(0, project_directory) + +from kohya_gui.custom_logging import setup_logging + +# Set up logging +log = setup_logging() + +def main(): + # Read the tag version from the file + tag_version = setup_common.read_tag_version_from_file(".\.sd-scripts-release") + + setup_common.clone_or_checkout( + "https://github.com/kohya-ss/sd-scripts.git", tag_version, "sd-scripts" + ) + +if __name__ == '__main__': + main()