-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_manual.py
More file actions
107 lines (88 loc) · 3.12 KB
/
setup_manual.py
File metadata and controls
107 lines (88 loc) · 3.12 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python3
"""
PurgeProof Setup Script
Installation script for the PurgeProof enterprise data sanitization tool.
This script complements the pyproject.toml configuration and provides
additional setup functionality for the hybrid Rust/Python architecture.
"""
import os
import sys
import subprocess
import platform
from pathlib import Path
def check_python_version():
"""Check if Python version is supported."""
if sys.version_info < (3, 8):
print("Error: PurgeProof requires Python 3.8 or later")
print(f"Current version: {sys.version}")
return False
return True
def check_rust_installation():
"""Check if Rust is installed for building the native engine."""
try:
result = subprocess.run(['cargo', '--version'], capture_output=True, text=True)
if result.returncode == 0:
print(f"✓ Rust/Cargo found: {result.stdout.strip()}")
return True
else:
print("✗ Rust/Cargo not found")
return False
except FileNotFoundError:
print("✗ Rust/Cargo not found")
return False
def build_native_engine():
"""Build the native Rust engine."""
print("\nBuilding native engine...")
engine_dir = Path(__file__).parent / "engine"
if not engine_dir.exists():
print("✗ Engine directory not found")
return False
try:
# Build in release mode
subprocess.run(['cargo', 'build', '--release'],
cwd=engine_dir, check=True)
print("✓ Native engine built successfully")
return True
except subprocess.CalledProcessError as e:
print(f"✗ Failed to build native engine: {e}")
return False
def run_tests():
"""Run the test suite to verify installation."""
print("\nRunning test suite...")
try:
subprocess.run([sys.executable, '-m', 'pytest', 'tests/', '-v'],
check=True)
print("✓ All tests passed")
return True
except subprocess.CalledProcessError:
print("⚠ Some tests failed - installation may have issues")
return False
def main():
"""Main setup function."""
print("PurgeProof Setup")
print("=" * 50)
# Check prerequisites
if not check_python_version():
return 1
# Check for Rust
if not check_rust_installation():
print("\nRust is required for the native engine.")
print("Install from: https://rustup.rs/")
print("Then run: pip install -e .")
return 1
# Build native engine
if not build_native_engine():
print("⚠ Native engine build failed. Using Python fallback.")
# Optional: Run tests
if len(sys.argv) > 1 and '--test' in sys.argv:
run_tests()
print("\n" + "=" * 50)
print("✓ PurgeProof setup completed!")
print("\nInstall with: pip install -e .")
print("\nUsage:")
print(" purgeproof --gui # GUI interface")
print(" purgeproof list # CLI interface")
print(" purgeproof --help # CLI help")
return 0
if __name__ == "__main__":
sys.exit(main())