-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclean.py
More file actions
48 lines (35 loc) · 1.34 KB
/
clean.py
File metadata and controls
48 lines (35 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import glob
import shutil
from pathlib import Path
def delete_files(pattern, path):
for file in glob.glob(f"{path}/**/{pattern}", recursive=True):
try:
os.remove(file)
print(f"{file} has been deleted.")
except OSError as e:
print(f"Error: {e.filename} - {e.strerror}.")
def clean_exts(exts):
shutil.rmtree("./build", ignore_errors=True)
print(f"builds has been deleted.")
for ext in exts:
for source in ext.sources:
c_file=source.replace('pyx','c')
cpp_file = source.replace('pyx', 'cpp')
if c_file.endswith('triangle.c') or c_file.endswith('_gjk.cpp'):
pass
else:
lib = source.replace('pyx', '*.**.so')
try:
os.remove( c_file)
print(f"{ c_file} has been deleted.")
except OSError as e:
print(f"Error: {e.filename} - {e.strerror}.")
if Path(cpp_file).exists():
os.remove(cpp_file)
print(f"{cpp_file} has been deleted.")
print("/".join(lib.split('/')[:-1]))
delete_files( "*.so","./"+"/".join(lib.split('/')[:-1]))
if __name__ == '__main__':
from build import cython_extensions
clean_exts(cython_extensions)