From ddca722b08f1a74049d55c0215dc53314fa918f8 Mon Sep 17 00:00:00 2001 From: sharath <29162020+tnfssc@users.noreply.github.com> Date: Wed, 28 May 2025 10:56:46 +0000 Subject: [PATCH] fix(setup): updated setup to work on windows reliably --- setup.py | 43 ++++++++++++++++++++++++++++--------------- start.py | 10 +++++++--- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/setup.py b/setup.py index e3478398..c265d1d5 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,8 @@ import subprocess from getpass import getpass import re +IS_WINDOWS = platform.system() == 'Windows' + # ANSI colors for pretty output class Colors: HEADER = '\033[95m' @@ -81,7 +83,8 @@ def check_requirements(): [cmd_to_check, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, - check=True + check=True, + shell=IS_WINDOWS ) print_success(f"{cmd} is installed") except (subprocess.SubprocessError, FileNotFoundError): @@ -103,7 +106,8 @@ def check_docker_running(): ['docker', 'info'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, - check=True + check=True, + shell=IS_WINDOWS ) print_success("Docker is running") return True @@ -550,7 +554,8 @@ def setup_supabase(): ['supabase', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, - check=True + check=True, + shell=IS_WINDOWS ) except (subprocess.SubprocessError, FileNotFoundError): print_error("Supabase CLI is not installed.") @@ -592,19 +597,25 @@ def setup_supabase(): try: # Login to Supabase CLI (interactive) print_info("Logging into Supabase CLI...") - subprocess.run(['supabase', 'login'], check=True) + subprocess.run(['supabase', 'login'], check=True, shell=IS_WINDOWS) # Link to project print_info(f"Linking to Supabase project {project_ref}...") subprocess.run( ['supabase', 'link', '--project-ref', project_ref], cwd=backend_dir, - check=True + check=True, + shell=IS_WINDOWS ) # Push database migrations print_info("Pushing database migrations...") - subprocess.run(['supabase', 'db', 'push'], cwd=backend_dir, check=True) + subprocess.run( + ['supabase', 'db', 'push'], + cwd=backend_dir, + check=True, + shell=IS_WINDOWS + ) print_success("Supabase database setup completed") @@ -628,7 +639,8 @@ def install_dependencies(): subprocess.run( ['npm', 'install'], cwd='frontend', - check=True + check=True, + shell=IS_WINDOWS ) print_success("Frontend dependencies installed successfully") @@ -637,14 +649,16 @@ def install_dependencies(): subprocess.run( ['poetry', 'lock'], cwd='backend', - check=True + check=True, + shell=IS_WINDOWS ) # Install backend dependencies print_info("Installing backend dependencies...") subprocess.run( ['poetry', 'install'], cwd='backend', - check=True + check=True, + shell=IS_WINDOWS ) print_success("Backend dependencies installed successfully") @@ -715,7 +729,7 @@ def start_suna(): # subprocess.run(['docker', 'compose', 'up', '-d'], check=True) print_info("Building images locally...") - subprocess.run(['docker', 'compose', 'up', '-d'], check=True) + subprocess.run(['docker', 'compose', 'up', '-d'], check=True, shell=IS_WINDOWS) # Wait for services to be ready print_info("Waiting for services to start...") @@ -723,11 +737,10 @@ def start_suna(): # Check if services are running result = subprocess.run( - ['docker', 'compose', 'ps'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - check=True, - text=True + ['docker', 'compose', 'ps', '-q'], + capture_output=True, + text=True, + shell=IS_WINDOWS ) if "backend" in result.stdout and "frontend" in result.stdout: diff --git a/start.py b/start.py index a8c76fee..d6d62d26 100644 --- a/start.py +++ b/start.py @@ -2,12 +2,16 @@ import subprocess import sys +import platform + +IS_WINDOWS = platform.system() == 'Windows' def check_docker_compose_up(): result = subprocess.run( ["docker", "compose", "ps", "-q"], capture_output=True, - text=True + text=True, + shell=IS_WINDOWS ) return len(result.stdout.strip()) > 0 @@ -47,9 +51,9 @@ def main(): return if action == "stop": - subprocess.run(["docker", "compose", "down"]) + subprocess.run(["docker", "compose", "down"], shell=IS_WINDOWS) else: - subprocess.run(["docker", "compose", "up", "-d"]) + subprocess.run(["docker", "compose", "up", "-d"], shell=IS_WINDOWS) if __name__ == "__main__": main()