Skip to content

Commit 602e656

Browse files
committed
code formatted
1 parent 119582c commit 602e656

File tree

3 files changed

+301
-285
lines changed

3 files changed

+301
-285
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ select = ["E", "F", "W", "I", "UP", "B", "C4", "SIM"]
6868
ignore = ["E501"]
6969

7070
[tool.mypy]
71-
python_version = "3.8"
71+
python_version = "3.9"
7272
warn_return_any = true
7373
warn_unused_configs = true
7474
disallow_untyped_defs = true

zigx/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,30 @@
2323
import subprocess
2424
import sys
2525
from pathlib import Path
26+
from typing import Optional
2627

2728

28-
def find_zigx_binary() -> Path:
29+
def find_zigx_binary() -> Optional[Path]:
2930
"""Find the zigx binary in common locations."""
3031
# Check if running from source
3132
pkg_dir = Path(__file__).parent
32-
33+
3334
# Look for zig-out directory (built binary)
3435
zig_out = pkg_dir / "zig-out" / "bin" / get_binary_name()
3536
if zig_out.exists():
3637
return zig_out
37-
38+
3839
# Look in parent's zig-out (development mode)
3940
parent_zig_out = pkg_dir.parent / "zigx" / "zig-out" / "bin" / get_binary_name()
4041
if parent_zig_out.exists():
4142
return parent_zig_out
42-
43+
4344
# Look in installed location
4445
bin_dir = Path(sys.prefix) / "bin"
4546
installed = bin_dir / get_binary_name()
4647
if installed.exists():
4748
return installed
48-
49+
4950
# Check if zig is available and try to build
5051
return None
5152

@@ -62,16 +63,16 @@ def ensure_binary() -> Path:
6263
binary = find_zigx_binary()
6364
if binary:
6465
return binary
65-
66+
6667
# Try to build from source
6768
pkg_dir = Path(__file__).parent
6869
zig_src = pkg_dir / "src"
69-
70+
7071
# Check for Zig source
7172
if not (zig_src / "main.zig").exists():
7273
# Maybe in development structure
7374
zig_src = pkg_dir.parent / "zigx" / "src"
74-
75+
7576
if (zig_src / "main.zig").exists():
7677
build_dir = zig_src.parent
7778
print("Building zigx from source...", file=sys.stderr)
@@ -91,7 +92,7 @@ def ensure_binary() -> Path:
9192
print(f"Build failed: {result.stderr}", file=sys.stderr)
9293
except FileNotFoundError:
9394
pass
94-
95+
9596
raise RuntimeError(
9697
"zigx binary not found. Please ensure Zig is installed and run:\n"
9798
" cd zigx && zig build\n"
@@ -106,7 +107,7 @@ def run(*args: str) -> int:
106107
except RuntimeError as e:
107108
print(str(e), file=sys.stderr)
108109
return 1
109-
110+
110111
result = subprocess.run([str(binary)] + list(args), check=False)
111112
return result.returncode
112113

0 commit comments

Comments
 (0)