Skip to content

Commit a854455

Browse files
committed
fixed venv syntax
1 parent 93ea62a commit a854455

1 file changed

Lines changed: 33 additions & 56 deletions

File tree

agentstack/cli/cli.py

Lines changed: 33 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def init_project_builder(
164164
To set up manually:
165165
deactivate # Leave current environment
166166
cd {project_details['name']}
167-
uv venv --name agentstackvenv_{project_details['name']}
167+
uv venv agentstackvenv_{project_details['name']}
168168
source agentstackvenv_{project_details['name']}/bin/activate
169169
uv lock
170170
uv sync
@@ -174,7 +174,7 @@ def init_project_builder(
174174
os.chdir(project_details['name'])
175175
try:
176176
venv_name = f"agentstackvenv_{project_details['name']}"
177-
subprocess.run(["uv", "venv", "--name", venv_name], check=True)
177+
subprocess.run(["uv", "venv", venv_name], check=True)
178178
subprocess.run(["uv", "lock"], check=True)
179179
subprocess.run(["uv", "sync"], check=True)
180180
os.chdir('..')
@@ -619,59 +619,36 @@ def export_template(output_filename: str):
619619
sys.exit(1)
620620

621621

622-
def handle_virtual_environment(project_name: str) -> bool:
623-
"""
624-
Handles virtual environment setup automatically via CLI commands.
625-
Returns True if successful, False otherwise.
626-
"""
622+
def handle_virtual_environment(project_name: str) -> None:
623+
"""Handle virtual environment setup for the project."""
624+
print("\nI'll help you set up a new environment automatically! Here's what I'll do:\n")
625+
print("1. Deactivate your current virtual environment")
626+
print("2. Create a new environment named 'agentstackvenv_" + project_name + "'")
627+
print("3. Activate the new environment")
628+
print("4. Install all dependencies\n")
629+
630+
print("Running commands:")
631+
print(" deactivate")
632+
print(" cd " + project_name)
633+
print(" uv venv agentstackvenv_" + project_name)
634+
print(" source agentstackvenv_" + project_name + "/bin/activate")
635+
print(" uv lock")
636+
print(" uv sync\n")
637+
627638
try:
628-
venv_name = f"agentstackvenv_{project_name}"
629-
630-
print(f"""
631-
I'll help you set up a new environment automatically! Here's what I'll do:
632-
633-
1. Deactivate your current virtual environment
634-
2. Create a new environment named '{venv_name}'
635-
3. Activate the new environment
636-
4. Install all dependencies
637-
638-
Running commands:
639-
deactivate
640-
cd {project_name}
641-
uv venv --name {venv_name}
642-
source {venv_name}/bin/activate
643-
uv lock
644-
uv sync
645-
""")
646-
647-
# Run the commands
648-
subprocess.run(["deactivate"], shell=True)
639+
# Try to run the commands
640+
subprocess.run(['deactivate'], shell=True, check=True)
649641
os.chdir(project_name)
650-
subprocess.run(["uv", "venv", "--name", venv_name], check=True)
651-
subprocess.run(["source", f"{venv_name}/bin/activate"], shell=True)
652-
subprocess.run(["uv", "lock"], check=True)
653-
subprocess.run(["uv", "sync"], check=True)
654-
655-
print(f"""
656-
Success! Your new environment is ready:
657-
- Previous environment was deactivated
658-
- New environment '{venv_name}' is active
659-
- All dependencies are installed
660-
661-
You can now start using your AgentStack project!
662-
""")
663-
return True
664-
665-
except Exception as e:
666-
print(f"""
667-
Something went wrong: {str(e)}
668-
669-
You can set up the environment manually with these commands:
670-
deactivate # Leave current environment
671-
cd {project_name}
672-
uv venv --name {venv_name}
673-
source {venv_name}/bin/activate
674-
uv lock
675-
uv sync
676-
""")
677-
return False
642+
subprocess.run(['uv', 'venv', f'agentstackvenv_{project_name}'], check=True)
643+
subprocess.run(['source', f'agentstackvenv_{project_name}/bin/activate'], shell=True, check=True)
644+
subprocess.run(['uv', 'lock'], check=True)
645+
subprocess.run(['uv', 'sync'], check=True)
646+
except subprocess.CalledProcessError as e:
647+
print("\nSomething went wrong:", str(e))
648+
print("\nYou can set up the environment manually with these commands:")
649+
print(" deactivate # Leave current environment")
650+
print(" cd " + project_name)
651+
print(" uv venv agentstackvenv_" + project_name)
652+
print(" source agentstackvenv_" + project_name + "/bin/activate")
653+
print(" uv lock")
654+
print(" uv sync\n")

0 commit comments

Comments
 (0)