-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_dev.py
More file actions
82 lines (66 loc) · 2.48 KB
/
Copy pathsetup_dev.py
File metadata and controls
82 lines (66 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
"""
Development setup script for ANTLR Next Generation Python implementation.
"""
import subprocess
import sys
from pathlib import Path
def run_command(cmd, description):
"""Run a command and print status."""
print(f"\n{description}...")
try:
result = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True)
print(f"✓ {description} completed successfully")
if result.stdout:
print(result.stdout)
return True
except subprocess.CalledProcessError as e:
print(f"✗ {description} failed")
if e.stdout:
print("STDOUT:", e.stdout)
if e.stderr:
print("STDERR:", e.stderr)
return False
def main():
"""Set up development environment."""
print("Setting up ANTLR Next Generation Python development environment")
# Check Python version
if sys.version_info < (3, 8):
print("Error: Python 3.8 or higher is required")
sys.exit(1)
print(f"✓ Python {sys.version_info.major}.{sys.version_info.minor} detected")
# Install package in development mode
success = run_command(
"pip install -e .[dev]",
"Installing package in development mode"
)
if not success:
print("Failed to install package. Trying alternative approach...")
run_command(
"pip install -e .",
"Installing package without dev dependencies"
)
run_command(
"pip install pytest pytest-cov black flake8 mypy click",
"Installing dev dependencies separately"
)
# Run tests
run_command("python -m pytest tests/ -v", "Running tests")
# Check code formatting
run_command("python -m black --check src/ tests/", "Checking code formatting")
# Run linting
run_command("python -m flake8 src/ tests/", "Running linter")
# Test CLI commands
print("\n=== Testing CLI Commands ===")
run_command("antlr-ng --help", "Testing antlr-ng command")
run_command("testrig --help", "Testing testrig command")
run_command("interpreter --help", "Testing interpreter command")
print("\n=== Development Environment Ready ===")
print("You can now:")
print("- Run tests: pytest")
print("- Format code: black src/ tests/")
print("- Check types: mypy src/")
print("- Use CLI: antlr-ng --help")
print("- Run example: python examples/usage_example.py")
if __name__ == "__main__":
main()