hanzo 0.2.5__py3-none-any.whl → 0.2.6__py3-none-any.whl

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.

Potentially problematic release.


This version of hanzo might be problematic. Click here for more details.

hanzo/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Hanzo - Complete AI Infrastructure Platform with CLI, Router, MCP, and Agent Runtime."""
2
2
 
3
- __version__ = "0.2.5"
3
+ __version__ = "0.2.6"
4
4
  __all__ = ["main", "cli"]
5
5
 
6
6
  from .cli import main, cli
hanzo/cli.py CHANGED
@@ -12,7 +12,7 @@ from .interactive.repl import HanzoREPL
12
12
  from .utils.output import console
13
13
 
14
14
  # Version
15
- __version__ = "0.2.5"
15
+ __version__ = "0.2.6"
16
16
 
17
17
 
18
18
  @click.group(invoke_without_command=True)
@@ -104,78 +104,69 @@ async def start_compute_node(ctx, name: str = None, port: int = 52415,
104
104
  network: str = "mainnet", models: tuple = None,
105
105
  max_jobs: int = 10):
106
106
  """Start this instance as a compute node using hanzo/net."""
107
+ from .utils.net_check import check_net_installation, get_missing_dependencies
108
+
107
109
  console = ctx.obj.get("console", Console())
108
110
 
109
111
  console.print("[bold cyan]Starting Hanzo Net Compute Node[/bold cyan]")
110
112
  console.print(f"Network: {network}")
111
113
  console.print(f"Port: {port}")
112
114
 
115
+ # Check hanzo/net availability
116
+ is_available, net_path, python_exe = check_net_installation()
117
+
118
+ if not is_available:
119
+ console.print("[red]Error:[/red] hanzo/net is not properly configured")
120
+ if net_path:
121
+ console.print(f"Found hanzo/net at {net_path} but dependencies are missing")
122
+ missing = get_missing_dependencies(python_exe)
123
+ if missing:
124
+ console.print(f"Missing packages: {', '.join(missing)}")
125
+ console.print("\nTo fix, run:")
126
+ console.print(f" cd {net_path} && pip install -e .")
127
+ else:
128
+ console.print("\nTo install hanzo/net:")
129
+ console.print(" git clone https://github.com/hanzoai/net.git ~/work/hanzo/net")
130
+ console.print(" cd ~/work/hanzo/net && pip install -e .")
131
+ return
132
+
113
133
  try:
114
134
  import subprocess
115
135
  import sys
116
136
  import os
117
137
 
118
- # Check if hanzo/net is available
119
- net_path = "/Users/z/work/hanzo/net"
120
- if not os.path.exists(net_path):
121
- # Try to find net in the Python environment
122
- try:
123
- import net
124
- # net is installed as a package
125
- console.print("[green]✓[/green] Using installed hanzo/net")
126
-
127
- # Run net directly
128
- from net.main import run as net_run
129
-
130
- # Set up environment for net
131
- if models:
132
- os.environ["NET_MODELS"] = ",".join(models)
133
- if name:
134
- os.environ["NET_NODE_NAME"] = name
135
-
136
- console.print(f"\n[green][/green] Node initialized")
137
- console.print(f" Port: {port}")
138
- console.print(f" Models: {', '.join(models) if models else 'auto-detect'}")
139
- console.print("\n[bold green]Hanzo Net is running![/bold green]")
140
- console.print("WebUI: http://localhost:52415")
141
- console.print("API: http://localhost:52415/v1/chat/completions")
142
- console.print("\nPress Ctrl+C to stop\n")
143
-
144
- # Run net
145
- await net_run()
146
-
147
- except ImportError:
148
- # net not installed, try to run from source
149
- console.print("[yellow]hanzo/net not installed, checking for source...[/yellow]")
150
-
151
- if os.path.exists(net_path):
152
- console.print(f"[green]✓[/green] Found hanzo/net at {net_path}")
153
-
154
- # Add net to Python path
155
- sys.path.insert(0, os.path.join(net_path, "src"))
156
-
157
- # Import and run net
158
- from net.main import run as net_run
159
-
160
- console.print(f"\n[green]✓[/green] Starting net node")
161
- console.print(f" Port: {port}")
162
- console.print(f" Models: {', '.join(models) if models else 'auto-detect'}")
163
- console.print("\n[bold green]Hanzo Net is running![/bold green]")
164
- console.print("WebUI: http://localhost:52415")
165
- console.print("API: http://localhost:52415/v1/chat/completions")
166
- console.print("\nPress Ctrl+C to stop\n")
167
-
168
- # Run net
169
- await net_run()
170
- else:
171
- console.print("[red]Error:[/red] hanzo/net not found")
172
- console.print("\nInstall hanzo/net:")
173
- console.print(" git clone https://github.com/hanzoai/net.git")
174
- console.print(" cd net && pip install -e .")
175
- return
138
+ # Use the checked net_path and python_exe
139
+ if not net_path:
140
+ # net is installed as a package
141
+ console.print("[green]✓[/green] Using installed hanzo/net")
142
+
143
+ # Import and run net
144
+ sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.executable)), "lib", "python3.*/site-packages"))
145
+ from net.main import run as net_run
146
+
147
+ # Set up environment for net
148
+ if models:
149
+ os.environ["NET_MODELS"] = ",".join(models)
150
+ if name:
151
+ os.environ["NET_NODE_NAME"] = name
152
+
153
+ console.print(f"\n[green]✓[/green] Node initialized")
154
+ console.print(f" Port: {port}")
155
+ console.print(f" Models: {', '.join(models) if models else 'auto-detect'}")
156
+ console.print("\n[bold green]Hanzo Net is running![/bold green]")
157
+ console.print("WebUI: http://localhost:52415")
158
+ console.print("API: http://localhost:52415/v1/chat/completions")
159
+ console.print("\nPress Ctrl+C to stop\n")
160
+
161
+ # Run net
162
+ await net_run()
176
163
  else:
177
- # Run from source directory
164
+ # Run from source directory using the detected python_exe
178
165
  console.print(f"[green]✓[/green] Using hanzo/net from {net_path}")
166
+ if python_exe != sys.executable:
167
+ console.print(f"[green]✓[/green] Using hanzo/net venv")
168
+ else:
169
+ console.print("[yellow]⚠[/yellow] Using system Python")
179
170
 
180
171
  # Change to net directory and run
181
172
  original_cwd = os.getcwd()
@@ -188,6 +179,7 @@ async def start_compute_node(ctx, name: str = None, port: int = 52415,
188
179
  env["NET_MODELS"] = ",".join(models)
189
180
  if name:
190
181
  env["NET_NODE_NAME"] = name
182
+ env["PYTHONPATH"] = os.path.join(net_path, "src") + ":" + env.get("PYTHONPATH", "")
191
183
 
192
184
  console.print(f"\n[green]✓[/green] Starting net node")
193
185
  console.print(f" Port: {port}")
@@ -197,12 +189,9 @@ async def start_compute_node(ctx, name: str = None, port: int = 52415,
197
189
  console.print("API: http://localhost:52415/v1/chat/completions")
198
190
  console.print("\nPress Ctrl+C to stop\n")
199
191
 
200
- # Add src to path and run net
201
- env["PYTHONPATH"] = os.path.join(net_path, "src") + ":" + env.get("PYTHONPATH", "")
202
-
203
- # Run net command
192
+ # Run net command with detected python
204
193
  process = subprocess.run(
205
- [sys.executable, "-c", "from net.main import run; run()"],
194
+ [python_exe, "-c", "from net.main import run; run()"],
206
195
  env=env,
207
196
  check=False
208
197
  )
@@ -0,0 +1,107 @@
1
+ """Utilities for checking hanzo/net availability and dependencies."""
2
+
3
+ import os
4
+ import subprocess
5
+ import sys
6
+ from typing import Optional, Tuple
7
+ from pathlib import Path
8
+
9
+
10
+ def check_net_installation() -> Tuple[bool, Optional[str], Optional[str]]:
11
+ """Check if hanzo/net is available and properly configured.
12
+
13
+ Returns:
14
+ Tuple of (is_available, net_path, python_exe)
15
+ """
16
+ # Check for hanzo/net in standard location
17
+ net_path = Path.home() / "work" / "hanzo" / "net"
18
+ if not net_path.exists():
19
+ net_path = Path("/Users/z/work/hanzo/net")
20
+
21
+ if not net_path.exists():
22
+ # Try to import as package
23
+ try:
24
+ import net
25
+ return True, None, sys.executable
26
+ except ImportError:
27
+ return False, None, None
28
+
29
+ # Check for venv
30
+ venv_python = net_path / ".venv" / "bin" / "python"
31
+ if venv_python.exists():
32
+ # Check if venv has required packages
33
+ result = subprocess.run(
34
+ [str(venv_python), "-c", "import net, scapy, mlx, transformers"],
35
+ capture_output=True,
36
+ text=True
37
+ )
38
+ if result.returncode == 0:
39
+ return True, str(net_path), str(venv_python)
40
+ else:
41
+ # Venv exists but missing dependencies
42
+ return False, str(net_path), str(venv_python)
43
+
44
+ # No venv, check system Python
45
+ result = subprocess.run(
46
+ [sys.executable, "-c", "import scapy"],
47
+ capture_output=True,
48
+ text=True
49
+ )
50
+
51
+ if result.returncode == 0:
52
+ return True, str(net_path), sys.executable
53
+ else:
54
+ return False, str(net_path), None
55
+
56
+
57
+ def install_net_dependencies(net_path: str, python_exe: str = None) -> bool:
58
+ """Install hanzo/net dependencies.
59
+
60
+ Args:
61
+ net_path: Path to hanzo/net directory
62
+ python_exe: Python executable to use (optional)
63
+
64
+ Returns:
65
+ True if installation successful
66
+ """
67
+ if python_exe is None:
68
+ python_exe = sys.executable
69
+
70
+ # Install dependencies
71
+ result = subprocess.run(
72
+ [python_exe, "-m", "pip", "install", "-e", net_path],
73
+ capture_output=True,
74
+ text=True
75
+ )
76
+
77
+ return result.returncode == 0
78
+
79
+
80
+ def get_missing_dependencies(python_exe: str = None) -> list:
81
+ """Check which dependencies are missing for hanzo/net.
82
+
83
+ Args:
84
+ python_exe: Python executable to check (default: sys.executable)
85
+
86
+ Returns:
87
+ List of missing package names
88
+ """
89
+ if python_exe is None:
90
+ python_exe = sys.executable
91
+
92
+ required_packages = [
93
+ "scapy", "mlx", "mlx_lm", "transformers", "tinygrad",
94
+ "aiohttp", "grpcio", "pydantic", "rich", "tqdm"
95
+ ]
96
+
97
+ missing = []
98
+ for package in required_packages:
99
+ result = subprocess.run(
100
+ [python_exe, "-c", f"import {package}"],
101
+ capture_output=True,
102
+ text=True
103
+ )
104
+ if result.returncode != 0:
105
+ missing.append(package)
106
+
107
+ return missing
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hanzo
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Summary: Hanzo AI - Complete AI Infrastructure Platform with CLI, Router, MCP, and Agent Runtime
5
5
  Project-URL: Homepage, https://hanzo.ai
6
6
  Project-URL: Repository, https://github.com/hanzoai/python-sdk
@@ -1,6 +1,6 @@
1
- hanzo/__init__.py,sha256=_nqVYfS2Zw03KZbODuZL7wT7vGjTTEMCQJ6T97eQj48,168
1
+ hanzo/__init__.py,sha256=O8RZSC5Ib4DEBkXnYSP82LXK7VlKN08JKWtgFrrEVmU,168
2
2
  hanzo/__main__.py,sha256=qRjwG8-7MHPOy3czoyDP9VK1GhEaJJsVeZcz2AG9NV0,104
3
- hanzo/cli.py,sha256=rsVF_KJo8CIAGk27ivoE3aIMqJWoR8hsvP8cDb_X3Fw,9754
3
+ hanzo/cli.py,sha256=jcoEVVPpa1vKlYh4PkJ8zbWBgQoH-vDUSabrXMYcQyw,9187
4
4
  hanzo/mcp_server.py,sha256=FBqcXhaJgV8_9O83H3fUy_pv4cV1707XCYm7FXaJeWY,422
5
5
  hanzo/repl.py,sha256=sC7EXbIBn7Oxnmzqey6neAg5-116gfpmrF0YFDYrhAQ,1014
6
6
  hanzo/commands/__init__.py,sha256=vXfIgioA6eakIYEN5ff5k_5BqOYQCJggD_MW40gb56w,138
@@ -20,8 +20,9 @@ hanzo/interactive/repl.py,sha256=-SwCSxwIHLiZBJOEShvqa4tgg2c7YYMf00zYRHazyIY,578
20
20
  hanzo/router/__init__.py,sha256=7Ulou75xQF8KKVzxOd4xXrmn3_Ti52M0NsAf6jXgGhk,913
21
21
  hanzo/utils/__init__.py,sha256=zmCH4YxefrpWmR-netV99UeECqrXjkKbi3ZjbcD79dw,68
22
22
  hanzo/utils/config.py,sha256=RU27eiSxGWAT9fI5-CjRdEJZEeT_xjMxjlMVeKC1gMg,4830
23
+ hanzo/utils/net_check.py,sha256=tuIMpy44p5nkSTEco52y-Bhp58FVFMvx1S4oQn9BsKI,3032
23
24
  hanzo/utils/output.py,sha256=lROF8RDOkck7ySt1kiTlVlHZqx1E0B-PqcJc78ZHYOs,2694
24
- hanzo-0.2.5.dist-info/METADATA,sha256=od4EnWzBDiPqBoAlmhLlnLR8wsImVU_J-ZCpZdpQuqc,4315
25
- hanzo-0.2.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
- hanzo-0.2.5.dist-info/entry_points.txt,sha256=pQLPMdqOXU_2BfTcMDhkqTCDNk_H6ApvYuSaWcuQOOw,171
27
- hanzo-0.2.5.dist-info/RECORD,,
25
+ hanzo-0.2.6.dist-info/METADATA,sha256=vPZKal3vrQDQYr8LoNnBymZJOqz_UvUPyGD2TRWMO78,4315
26
+ hanzo-0.2.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ hanzo-0.2.6.dist-info/entry_points.txt,sha256=pQLPMdqOXU_2BfTcMDhkqTCDNk_H6ApvYuSaWcuQOOw,171
28
+ hanzo-0.2.6.dist-info/RECORD,,
File without changes