MCPcopy Index your code
hub / github.com/BasicProtein/AugmentCode-Free / clean_build_artifacts

Method clean_build_artifacts

build.py:237–289  ·  view source on GitHub ↗

Comprehensive cleanup of build artifacts

(self)

Source from the content-addressed store, hash-verified

235 return True
236
237 def clean_build_artifacts(self) -> bool:
238 """Comprehensive cleanup of build artifacts"""
239 logger.step("Cleaning Build Artifacts")
240
241 cleanup_targets = {
242 'directories': ['build', 'dist', '.eggs'],
243 'patterns': ['*.egg-info', '*.spec', '*.pyc', '*.pyo'],
244 'cache_dirs': ['__pycache__', '.pytest_cache', '.mypy_cache']
245 }
246
247 cleaned_count = 0
248
249 # Clean directories
250 for dir_name in cleanup_targets['directories']:
251 dir_path = self.build_dir / dir_name
252 if dir_path.exists():
253 try:
254 shutil.rmtree(dir_path)
255 logger.success(f"Removed directory: {dir_name}")
256 cleaned_count += 1
257 except Exception as e:
258 logger.warning(f"Failed to remove {dir_name}: {e}")
259
260 # Clean pattern-matched files
261 import glob
262 for pattern in cleanup_targets['patterns']:
263 for path in glob.glob(pattern, recursive=True):
264 try:
265 path_obj = Path(path)
266 if path_obj.is_dir():
267 shutil.rmtree(path_obj)
268 else:
269 path_obj.unlink()
270 logger.success(f"Removed: {path}")
271 cleaned_count += 1
272 except Exception as e:
273 logger.warning(f"Failed to remove {path}: {e}")
274
275 # Clean cache directories
276 for root, dirs, files in os.walk(self.build_dir):
277 for cache_dir in cleanup_targets['cache_dirs']:
278 if cache_dir in dirs:
279 cache_path = Path(root) / cache_dir
280 try:
281 shutil.rmtree(cache_path)
282 logger.success(f"Removed cache: {cache_path}")
283 cleaned_count += 1
284 dirs.remove(cache_dir)
285 except Exception as e:
286 logger.warning(f"Failed to remove cache {cache_path}: {e}")
287
288 logger.success(f"Cleanup completed: {cleaned_count} items removed")
289 return True
290
291 def setup_build_directories(self) -> bool:
292 """Create and setup build directories"""

Callers

nothing calls this directly

Calls 3

stepMethod · 0.80
successMethod · 0.80
warningMethod · 0.80

Tested by

no test coverage detected