forked from leon-thomm/ryvencore
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcleanup_cython.py
68 lines (44 loc) · 1.35 KB
/
cleanup_cython.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""
simple helper script to remove all Cython-generated files and directories generated
"""
import os
import shutil
def get_generated_files(basedir):
"""
remove all generated .c/.so/.html files
"""
generated_files = []
for root, dirs, files in os.walk(basedir):
# print('FILES: ---------')
# print('\n'.join(files))
# print()
for f in files:
# e.g. file LICENSE doesn't have an extension at all
if len(f.split('.')) < 2:
continue
fpath = os.path.join(root, f)
fname, ext = f.split('.')[0], f.split('.')[-1]
py_file_path = os.path.join(root, fname + '.py')
if ext in ['c', 'so', 'html'] and os.path.exists(py_file_path):
generated_files.append(fpath)
return generated_files
def cleanup():
os.chdir(os.path.dirname(__file__))
# print('UNINSTALLING RYVENCORE')
#
# os.system('pip uninstall ryvencore --yes')
remove_files = get_generated_files('./ryvencore/')
print('REMOVING FILES\n', '\n'.join(remove_files))
for f in remove_files:
os.remove(f)
print('REMOVING DIRECTORIES')
dirs = [
'build',
'dist',
'ryvencore.egg-info',
]
for d in dirs:
print(d)
shutil.rmtree(d)
if __name__ == '__main__':
cleanup()