|
40 | 40 | # Also clean .pyc files in sentience package specifically |
41 | 41 | find sentience -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || python -c "import pathlib, shutil; [shutil.rmtree(p) for p in pathlib.Path('sentience').rglob('__pycache__') if p.is_dir()]" || true |
42 | 42 | find sentience -name "*.pyc" -delete 2>/dev/null || python -c "import pathlib; [p.unlink() for p in pathlib.Path('sentience').rglob('*.pyc')]" || true |
43 | | - # CRITICAL: Fix assertTrue bug if it exists in source (shouldn't happen, but safety check) |
44 | | - python << 'PYEOF' |
45 | | - import re |
46 | | - import os |
47 | | - import sys |
48 | | -
|
49 | | - # Set UTF-8 encoding for Windows compatibility |
50 | | - if sys.platform == 'win32': |
51 | | - import io |
52 | | - sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace') |
53 | | - sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace') |
54 | | -
|
55 | | - file_path = 'sentience/agent_runtime.py' |
56 | | - print(f'=== Auto-fix check for {file_path} ===') |
57 | | - try: |
58 | | - if not os.path.exists(file_path): |
59 | | - print(f'ERROR: {file_path} not found!') |
60 | | - sys.exit(1) |
61 | | -
|
62 | | - with open(file_path, 'r', encoding='utf-8') as f: |
63 | | - content = f.read() |
64 | | -
|
65 | | - if 'self.assertTrue(' in content: |
66 | | - print('WARNING: Found self.assertTrue( in source file! Auto-fixing...') |
67 | | - # Count occurrences |
68 | | - count = len(re.findall(r'self\.assertTrue\s*\(', content)) |
69 | | - print(f'Found {count} occurrence(s) of self.assertTrue(') |
70 | | -
|
71 | | - # Replace all occurrences |
72 | | - new_content = re.sub(r'self\.assertTrue\s*\(', 'self.assert_(', content) |
73 | | -
|
74 | | - # Write back |
75 | | - with open(file_path, 'w', encoding='utf-8') as f: |
76 | | - f.write(new_content) |
77 | | -
|
78 | | - # Verify the fix |
79 | | - with open(file_path, 'r', encoding='utf-8') as f: |
80 | | - verify_content = f.read() |
81 | | - if 'self.assertTrue(' in verify_content: |
82 | | - print('ERROR: Auto-fix failed! File still contains self.assertTrue(') |
83 | | - sys.exit(1) |
84 | | - else: |
85 | | - print('OK: Auto-fixed: Replaced self.assertTrue( with self.assert_(') |
86 | | - print('OK: Verified: File no longer contains self.assertTrue(') |
87 | | - else: |
88 | | - print('OK: Source file is correct (uses self.assert_())') |
89 | | - except Exception as e: |
90 | | - print(f'ERROR in auto-fix: {e}') |
91 | | - import traceback |
92 | | - traceback.print_exc() |
93 | | - sys.exit(1) |
94 | | - PYEOF |
95 | | - # Verify source file is fixed before installation |
96 | | - echo "=== Verifying source file after auto-fix ===" |
97 | | - python -c "import sys; import io; sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace') if sys.platform == 'win32' else sys.stdout; content = open('sentience/agent_runtime.py', 'r', encoding='utf-8').read(); assert 'self.assertTrue(' not in content, 'Source file still has self.assertTrue( after auto-fix!'; print('OK: Source file verified: uses self.assert_()')" |
| 43 | + # Ensure source uses assert_ (no auto-rewrite). |
| 44 | + python -c "import sys; import io; sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace') if sys.platform == 'win32' else sys.stdout; content = open('sentience/agent_runtime.py', 'r', encoding='utf-8').read(); assert 'self.assertTrue(' not in content, 'Source file still has self.assertTrue('; print('OK: Source file verified: uses self.assert_()')" |
98 | 45 |
|
99 | 46 | # Force reinstall to ensure latest code |
100 | 47 | pip install --no-cache-dir --force-reinstall -e ".[dev]" |
|
0 commit comments