Skip to content

Commit 3740d6f

Browse files
committed
clean uses python lib to delete
1 parent e07259e commit 3740d6f

File tree

1 file changed

+11
-9
lines changed
  • python-bindings/overview_article

1 file changed

+11
-9
lines changed

python-bindings/overview_article/tasks.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,34 @@
66
import pathlib
77
import sys
88
import os
9+
import shutil
910
import re
11+
import glob
1012

1113
on_win = sys.platform.startswith("win")
1214

1315

1416
@invoke.task
1517
def clean(c):
1618
""" Remove any built objects """
17-
for pattern in (
19+
for file_pattern in (
1820
"*.o",
1921
"*.so",
2022
"*.obj",
2123
"*.dll",
2224
"*.exp",
2325
"*.lib",
2426
"*.pyd",
25-
"cffi_example*",
27+
"cffi_example*", # Is this a dir?
2628
"cython_wrapper.cpp",
2729
):
28-
if on_win:
29-
c.run("del {} >nul 2>&1".format(pattern))
30-
else:
31-
c.run("rm -rf {}".format(pattern))
32-
if on_win:
33-
c.run("rmdir /s /q Release >nul 2>&1")
34-
30+
for file in glob.glob(file_pattern):
31+
os.remove(file)
32+
for dir_pattern in (
33+
"Release"
34+
):
35+
for dir in glob.glob(dir_pattern):
36+
shutil.rmtree(dir)
3537

3638
def print_banner(msg):
3739
print("==================================================")

0 commit comments

Comments
 (0)