Skip to content

Commit e79942b

Browse files
committed
Refactor Makefile so cleanup code is fully cross-platform
1 parent a58f6fe commit e79942b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,22 @@ publish: validate-tag build ## Publish a release to PyPI, uses token from ~/.pyp
7777
BUILD_DIRS = build dist *.egg-info
7878
DOC_DIRS = build
7979
MYPY_DIRS = .mypy_cache dmypy.json dmypy.sock
80-
PYCACHE_DIRS = __pycache__
8180
TEST_DIRS = .cache .coverage .pytest_cache htmlcov
8281

8382
.PHONY: clean-build
8483
clean-build: ## Clean build artifacts
8584
@echo "🚀 Removing build artifacts"
86-
@-rm -rf $(BUILD_DIRS)
85+
@uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(BUILD_DIRS)'.split() if os.path.isdir(d)]"
8786

8887
.PHONY: clean-docs
8988
clean-docs: ## Clean documentation artifacts
9089
@echo "🚀 Removing documentation artifacts"
91-
@-rm -rf $(DOC_DIRS)
90+
@uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(DOC_DIRS)'.split() if os.path.isdir(d)]"
9291

9392
.PHONY: clean-mypy
9493
clean-mypy: ## Clean mypy artifacts
9594
@echo "🚀 Removing mypy artifacts"
96-
@-rm -rf $(MYPY_DIRS)
95+
@uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(MYPY_DIRS)'.split() if os.path.isdir(d)]"
9796

9897
.PHONY: clean-pycache
9998
clean-pycache: ## Clean pycache artifacts
@@ -108,7 +107,7 @@ clean-ruff: ## Clean ruff artifacts
108107
.PHONY: clean-test
109108
clean-test: ## Clean test artifacts
110109
@echo "🚀 Removing test artifacts"
111-
@-rm -rf $(TEST_DIRS)
110+
@uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(TEST_DIRS)'.split() if os.path.isdir(d)]"
112111

113112
.PHONY: clean
114113
clean: clean-build clean-docs clean-mypy clean-pycache clean-ruff clean-test ## Clean all artifacts

0 commit comments

Comments
 (0)