cua-computer 0.4.6__tar.gz → 0.4.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {cua_computer-0.4.6 → cua_computer-0.4.7}/PKG-INFO +1 -1
  2. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/computer.py +51 -25
  3. {cua_computer-0.4.6 → cua_computer-0.4.7}/pyproject.toml +3 -3
  4. {cua_computer-0.4.6 → cua_computer-0.4.7}/README.md +0 -0
  5. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/__init__.py +0 -0
  6. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/diorama_computer.py +0 -0
  7. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/helpers.py +0 -0
  8. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/interface/__init__.py +0 -0
  9. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/interface/base.py +0 -0
  10. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/interface/factory.py +0 -0
  11. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/interface/generic.py +0 -0
  12. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/interface/linux.py +0 -0
  13. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/interface/macos.py +0 -0
  14. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/interface/models.py +0 -0
  15. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/interface/windows.py +0 -0
  16. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/logger.py +0 -0
  17. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/models.py +0 -0
  18. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/__init__.py +0 -0
  19. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/base.py +0 -0
  20. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/cloud/__init__.py +0 -0
  21. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/cloud/provider.py +0 -0
  22. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/docker/__init__.py +0 -0
  23. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/docker/provider.py +0 -0
  24. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/factory.py +0 -0
  25. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/lume/__init__.py +0 -0
  26. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/lume/provider.py +0 -0
  27. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/lume_api.py +0 -0
  28. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/lumier/__init__.py +0 -0
  29. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/lumier/provider.py +0 -0
  30. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/winsandbox/__init__.py +0 -0
  31. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/winsandbox/provider.py +0 -0
  32. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/providers/winsandbox/setup_script.ps1 +0 -0
  33. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/ui/__init__.py +0 -0
  34. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/ui/__main__.py +0 -0
  35. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/ui/gradio/__init__.py +0 -0
  36. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/ui/gradio/app.py +0 -0
  37. {cua_computer-0.4.6 → cua_computer-0.4.7}/computer/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cua-computer
3
- Version: 0.4.6
3
+ Version: 0.4.7
4
4
  Summary: Computer-Use Interface (CUI) framework powering Cua
5
5
  Author-Email: TryCua <gh@trycua.com>
6
6
  Requires-Python: >=3.11
@@ -794,19 +794,33 @@ class Computer:
794
794
  Tuple of (stdout, stderr) from the installation command
795
795
  """
796
796
  requirements = requirements or []
797
-
798
- # Create virtual environment if it doesn't exist
799
- venv_path = f"~/.venvs/{venv_name}"
800
- create_cmd = f"mkdir -p ~/.venvs && python3 -m venv {venv_path}"
801
-
802
- # Check if venv exists, if not create it
803
- check_cmd = f"test -d {venv_path} || ({create_cmd})"
804
- _ = await self.interface.run_command(check_cmd)
805
-
806
- # Install packages
807
- requirements_str = " ".join(requirements)
808
- install_cmd = f". {venv_path}/bin/activate && pip install {requirements_str}"
809
- return await self.interface.run_command(install_cmd)
797
+ # Windows vs POSIX handling
798
+ if self.os_type == "windows":
799
+ # Use %USERPROFILE% for home directory and cmd.exe semantics
800
+ venv_path = f"%USERPROFILE%\\.venvs\\{venv_name}"
801
+ ensure_dir_cmd = "if not exist \"%USERPROFILE%\\.venvs\" mkdir \"%USERPROFILE%\\.venvs\""
802
+ create_cmd = f"if not exist \"{venv_path}\" python -m venv \"{venv_path}\""
803
+ requirements_str = " ".join(requirements)
804
+ # Activate via activate.bat and install
805
+ install_cmd = f"call \"{venv_path}\\Scripts\\activate.bat\" && pip install {requirements_str}" if requirements_str else f"echo No requirements to install"
806
+ await self.interface.run_command(ensure_dir_cmd)
807
+ await self.interface.run_command(create_cmd)
808
+ return await self.interface.run_command(install_cmd)
809
+ else:
810
+ # POSIX (macOS/Linux)
811
+ venv_path = f"$HOME/.venvs/{venv_name}"
812
+ create_cmd = f"mkdir -p \"$HOME/.venvs\" && python3 -m venv \"{venv_path}\""
813
+ # Check if venv exists, if not create it
814
+ check_cmd = f"test -d \"{venv_path}\" || ({create_cmd})"
815
+ _ = await self.interface.run_command(check_cmd)
816
+ # Install packages
817
+ requirements_str = " ".join(requirements)
818
+ install_cmd = (
819
+ f". \"{venv_path}/bin/activate\" && pip install {requirements_str}"
820
+ if requirements_str
821
+ else "echo No requirements to install"
822
+ )
823
+ return await self.interface.run_command(install_cmd)
810
824
 
811
825
  async def venv_cmd(self, venv_name: str, command: str):
812
826
  """Execute a shell command in a virtual environment.
@@ -818,18 +832,30 @@ class Computer:
818
832
  Returns:
819
833
  Tuple of (stdout, stderr) from the command execution
820
834
  """
821
- venv_path = f"~/.venvs/{venv_name}"
822
-
823
- # Check if virtual environment exists
824
- check_cmd = f"test -d {venv_path}"
825
- result = await self.interface.run_command(check_cmd)
826
-
827
- if result.stderr or "test:" in result.stdout: # venv doesn't exist
828
- return "", f"Virtual environment '{venv_name}' does not exist. Create it first using venv_install."
829
-
830
- # Activate virtual environment and run command
831
- full_command = f". {venv_path}/bin/activate && {command}"
832
- return await self.interface.run_command(full_command)
835
+ if self.os_type == "windows":
836
+ # Windows (cmd.exe)
837
+ venv_path = f"%USERPROFILE%\\.venvs\\{venv_name}"
838
+ # Check existence and signal if missing
839
+ check_cmd = f"if not exist \"{venv_path}\" (echo VENV_NOT_FOUND) else (echo VENV_FOUND)"
840
+ result = await self.interface.run_command(check_cmd)
841
+ if "VENV_NOT_FOUND" in getattr(result, "stdout", ""):
842
+ # Auto-create the venv with no requirements
843
+ await self.venv_install(venv_name, [])
844
+ # Activate and run the command
845
+ full_command = f"call \"{venv_path}\\Scripts\\activate.bat\" && {command}"
846
+ return await self.interface.run_command(full_command)
847
+ else:
848
+ # POSIX (macOS/Linux)
849
+ venv_path = f"$HOME/.venvs/{venv_name}"
850
+ # Check if virtual environment exists
851
+ check_cmd = f"test -d \"{venv_path}\""
852
+ result = await self.interface.run_command(check_cmd)
853
+ if result.stderr or "test:" in result.stdout: # venv doesn't exist
854
+ # Auto-create the venv with no requirements
855
+ await self.venv_install(venv_name, [])
856
+ # Activate virtual environment and run command
857
+ full_command = f". \"{venv_path}/bin/activate\" && {command}"
858
+ return await self.interface.run_command(full_command)
833
859
 
834
860
  async def venv_exec(self, venv_name: str, python_func, *args, **kwargs):
835
861
  """Execute Python function in a virtual environment using source code extraction.
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "cua-computer"
9
- version = "0.4.6"
9
+ version = "0.4.7"
10
10
  description = "Computer-Use Interface (CUI) framework powering Cua"
11
11
  readme = "README.md"
12
12
  authors = [
@@ -57,7 +57,7 @@ target-version = [
57
57
 
58
58
  [tool.ruff]
59
59
  line-length = 100
60
- target-version = "0.4.6"
60
+ target-version = "0.4.7"
61
61
  select = [
62
62
  "E",
63
63
  "F",
@@ -71,7 +71,7 @@ docstring-code-format = true
71
71
 
72
72
  [tool.mypy]
73
73
  strict = true
74
- python_version = "0.4.6"
74
+ python_version = "0.4.7"
75
75
  ignore_missing_imports = true
76
76
  disallow_untyped_defs = true
77
77
  check_untyped_defs = true
File without changes