| 40 | |
| 41 | |
| 42 | def clean(): |
| 43 | print("Cleaning build artifacts...") |
| 44 | print("Cleaning pip-out/...") |
| 45 | shutil.rmtree("pip-out/", ignore_errors=True) |
| 46 | dirs = glob.glob("cmake-out*/") + glob.glob("cmake-android-out/") |
| 47 | for d in dirs: |
| 48 | print(f"Cleaning {d}...") |
| 49 | shutil.rmtree(d, ignore_errors=True) |
| 50 | print("Cleaning buck-out/...") |
| 51 | shutil.rmtree("buck-out/", ignore_errors=True) |
| 52 | |
| 53 | # Removes all buck cached state and metadata |
| 54 | print("Cleaning buck cached state and metadata ...") |
| 55 | shutil.rmtree(os.path.expanduser("~/.buck/buckd"), ignore_errors=True) |
| 56 | |
| 57 | # tokenizers build cleanup |
| 58 | tokenizer_dirs = [ |
| 59 | "extension/llm/tokenizers/build", |
| 60 | "extension/llm/tokenizers/pytorch_tokenizers.egg-info", |
| 61 | ] |
| 62 | |
| 63 | for d in tokenizer_dirs: |
| 64 | print(f"Cleaning {d}...") |
| 65 | shutil.rmtree(d, ignore_errors=True) |
| 66 | |
| 67 | # Clean ccache if available |
| 68 | try: |
| 69 | result = subprocess.run(["ccache", "--version"], capture_output=True, text=True) |
| 70 | if result.returncode == 0: |
| 71 | print("Cleaning ccache...") |
| 72 | subprocess.run(["ccache", "--clear"], check=True) |
| 73 | print("ccache cleared successfully.") |
| 74 | else: |
| 75 | print("ccache not found, skipping ccache cleanup.") |
| 76 | except (subprocess.CalledProcessError, FileNotFoundError): |
| 77 | print("ccache not found, skipping ccache cleanup.") |
| 78 | |
| 79 | print("Done cleaning build artifacts.") |
| 80 | |
| 81 | |
| 82 | ################################################################################ |