Skip to content

Commit bee485d

Browse files
committed
Merge branch 'feat/pecos-deps' into bug/issues-213-and-89
2 parents 732c5f5 + 3d3161a commit bee485d

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

scripts/clean.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def find_and_remove_dirs(
7575
# Optionally skip .venv directories (third-party packages)
7676
if skip_venv and ".venv" in path.parts:
7777
continue
78-
if rmtree_safe(path, dry_run):
78+
if rmtree_safe(path, dry_run=dry_run):
7979
count += 1
8080
return count
8181

@@ -97,7 +97,7 @@ def find_and_remove_files(
9797
# Optionally skip .venv directories (third-party packages)
9898
if skip_venv and ".venv" in path.parts:
9999
continue
100-
if rm_safe(path, dry_run):
100+
if rm_safe(path, dry_run=dry_run):
101101
count += 1
102102
return count
103103

@@ -130,10 +130,10 @@ def clean_project(root: Path, *, dry_run: bool = False) -> None:
130130

131131
# Top-level directories
132132
for dirname in ["dist", "site", ".ruff_cache"]:
133-
rmtree_safe(root / dirname, dry_run)
133+
rmtree_safe(root / dirname, dry_run=dry_run)
134134

135135
# Python docs build
136-
rmtree_safe(root / "python" / "docs" / "_build", dry_run)
136+
rmtree_safe(root / "python" / "docs" / "_build", dry_run=dry_run)
137137

138138
# Find and remove common build directories
139139
dir_patterns = [
@@ -146,36 +146,36 @@ def clean_project(root: Path, *, dry_run: bool = False) -> None:
146146
"__pycache__",
147147
]
148148
for pattern in dir_patterns:
149-
count = find_and_remove_dirs(root, pattern, dry_run)
149+
count = find_and_remove_dirs(root, pattern, dry_run=dry_run)
150150
if count > 0 and not dry_run:
151151
print(f" Removed {count} '{pattern}' directories")
152152

153153
# Compiled Python extensions
154154
python_dir = root / "python"
155155
if python_dir.exists():
156-
so_count = find_and_remove_files(python_dir, "*.so", dry_run)
157-
pyd_count = find_and_remove_files(python_dir, "*.pyd", dry_run)
156+
so_count = find_and_remove_files(python_dir, "*.so", dry_run=dry_run)
157+
pyd_count = find_and_remove_files(python_dir, "*.pyd", dry_run=dry_run)
158158
if (so_count + pyd_count) > 0 and not dry_run:
159159
print(f" Removed {so_count + pyd_count} compiled extensions")
160160

161161
# Julia artifacts
162162
julia_dir = root / "julia"
163163
if julia_dir.exists():
164-
rm_safe(julia_dir / "PECOS.jl" / "Manifest.toml", dry_run)
164+
rm_safe(julia_dir / "PECOS.jl" / "Manifest.toml", dry_run=dry_run)
165165
rm_safe(
166166
julia_dir / "PECOS.jl" / "dev" / "PECOS_julia_jll" / "Manifest.toml",
167-
dry_run,
167+
dry_run=dry_run,
168168
)
169-
find_and_remove_files(julia_dir, "*.jl.*.cov", dry_run)
170-
find_and_remove_files(julia_dir, "*.jl.cov", dry_run)
171-
find_and_remove_files(julia_dir, "*.jl.mem", dry_run)
169+
find_and_remove_files(julia_dir, "*.jl.*.cov", dry_run=dry_run)
170+
find_and_remove_files(julia_dir, "*.jl.cov", dry_run=dry_run)
171+
find_and_remove_files(julia_dir, "*.jl.mem", dry_run=dry_run)
172172

173173
# Clean pecos_rslib from venv
174174
venv_dir = root / ".venv"
175175
if venv_dir.exists():
176176
for site_packages in venv_dir.rglob("site-packages"):
177177
for pecos_rslib in site_packages.glob("pecos_rslib*"):
178-
rmtree_safe(pecos_rslib, dry_run)
178+
rmtree_safe(pecos_rslib, dry_run=dry_run)
179179

180180
# Clean uv cache for pecos-rslib
181181
if not dry_run:
@@ -194,7 +194,7 @@ def clean_selene(root: Path, *, dry_run: bool = False) -> None:
194194
if plugin_dir.is_dir():
195195
for python_pkg in (plugin_dir / "python").glob("*"):
196196
dist_dir = python_pkg / "_dist"
197-
if rmtree_safe(dist_dir, dry_run):
197+
if rmtree_safe(dist_dir, dry_run=dry_run):
198198
count += 1
199199
if count > 0:
200200
print(f" Removed {count} _dist directories")
@@ -210,19 +210,19 @@ def clean_pecos_home(
210210

211211
if what == "cache":
212212
print("Cleaning ~/.pecos/cache/ and ~/.pecos/tmp/...")
213-
rmtree_safe(pecos_home / "cache", dry_run)
214-
rmtree_safe(pecos_home / "tmp", dry_run)
213+
rmtree_safe(pecos_home / "cache", dry_run=dry_run)
214+
rmtree_safe(pecos_home / "tmp", dry_run=dry_run)
215215
elif what == "deps":
216216
print("Cleaning ~/.pecos/deps/...")
217-
rmtree_safe(pecos_home / "deps", dry_run)
217+
rmtree_safe(pecos_home / "deps", dry_run=dry_run)
218218
elif what == "llvm":
219219
print("Cleaning ~/.pecos/llvm/...")
220-
if rmtree_safe(pecos_home / "llvm", dry_run):
221-
print(" Run 'make install-llvm' to reinstall LLVM")
220+
if rmtree_safe(pecos_home / "llvm", dry_run=dry_run):
221+
print(" Run 'just install-llvm' to reinstall LLVM")
222222
elif what == "cuda":
223223
print("Cleaning ~/.pecos/cuda/...")
224-
if rmtree_safe(pecos_home / "cuda", dry_run):
225-
print(" Run 'make install-cuda' to reinstall CUDA")
224+
if rmtree_safe(pecos_home / "cuda", dry_run=dry_run):
225+
print(" Run 'just install-cuda' to reinstall CUDA")
226226

227227

228228
def main() -> int:
@@ -279,28 +279,28 @@ def main() -> int:
279279

280280
# Determine what to clean
281281
if args.all:
282-
clean_project(root, args.dry_run)
283-
clean_selene(root, args.dry_run)
284-
clean_pecos_home("cache", args.dry_run)
285-
clean_pecos_home("deps", args.dry_run)
286-
clean_pecos_home("llvm", args.dry_run)
287-
clean_pecos_home("cuda", args.dry_run)
282+
clean_project(root, dry_run=args.dry_run)
283+
clean_selene(root, dry_run=args.dry_run)
284+
clean_pecos_home("cache", dry_run=args.dry_run)
285+
clean_pecos_home("deps", dry_run=args.dry_run)
286+
clean_pecos_home("llvm", dry_run=args.dry_run)
287+
clean_pecos_home("cuda", dry_run=args.dry_run)
288288
elif args.selene:
289-
clean_selene(root, args.dry_run)
289+
clean_selene(root, dry_run=args.dry_run)
290290
elif args.cache or args.deps or args.llvm or args.cuda:
291291
# Only clean specified ~/.pecos/ subdirectories
292292
if args.cache:
293-
clean_pecos_home("cache", args.dry_run)
293+
clean_pecos_home("cache", dry_run=args.dry_run)
294294
if args.deps:
295-
clean_pecos_home("deps", args.dry_run)
295+
clean_pecos_home("deps", dry_run=args.dry_run)
296296
if args.llvm:
297-
clean_pecos_home("llvm", args.dry_run)
297+
clean_pecos_home("llvm", dry_run=args.dry_run)
298298
if args.cuda:
299-
clean_pecos_home("cuda", args.dry_run)
299+
clean_pecos_home("cuda", dry_run=args.dry_run)
300300
else:
301301
# Default: clean project artifacts only
302-
clean_project(root, args.dry_run)
303-
clean_selene(root, args.dry_run)
302+
clean_project(root, dry_run=args.dry_run)
303+
clean_selene(root, dry_run=args.dry_run)
304304

305305
print("\nDone.")
306306
return 0

0 commit comments

Comments
 (0)