Karim shoair commited on
Commit ·
ba72b2b
1
Parent(s): 33ec4ca
A cleanup script to use with development
Browse files- cleanup.py +42 -0
cleanup.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import shutil
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
# Clean up after installing for local development
|
| 6 |
+
def clean():
|
| 7 |
+
# Get the current directory
|
| 8 |
+
base_dir = Path.cwd()
|
| 9 |
+
|
| 10 |
+
# Directories and patterns to clean
|
| 11 |
+
cleanup_patterns = [
|
| 12 |
+
'build',
|
| 13 |
+
'dist',
|
| 14 |
+
'*.egg-info',
|
| 15 |
+
'__pycache__',
|
| 16 |
+
'.eggs',
|
| 17 |
+
'.pytest_cache'
|
| 18 |
+
]
|
| 19 |
+
|
| 20 |
+
# Clean directories
|
| 21 |
+
for pattern in cleanup_patterns:
|
| 22 |
+
for path in base_dir.glob(pattern):
|
| 23 |
+
try:
|
| 24 |
+
if path.is_dir():
|
| 25 |
+
shutil.rmtree(path)
|
| 26 |
+
else:
|
| 27 |
+
path.unlink()
|
| 28 |
+
print(f"Removed: {path}")
|
| 29 |
+
except Exception as e:
|
| 30 |
+
print(f"Could not remove {path}: {e}")
|
| 31 |
+
|
| 32 |
+
# Remove compiled Python files
|
| 33 |
+
for path in base_dir.rglob('*.py[co]'):
|
| 34 |
+
try:
|
| 35 |
+
path.unlink()
|
| 36 |
+
print(f"Removed compiled file: {path}")
|
| 37 |
+
except Exception as e:
|
| 38 |
+
print(f"Could not remove {path}: {e}")
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == '__main__':
|
| 42 |
+
clean()
|