forked from taichi-dev/taichi_elements
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_blender_addon.py
39 lines (33 loc) · 983 Bytes
/
install_blender_addon.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
import os
import time
import shutil
import argparse
parser = argparse.ArgumentParser(description='Install the current Blender addon.')
parser.add_argument('-k', action='store_true', help='keep refreshing')
addon_path = os.environ['BLENDER_USER_ADDON_PATH']
if addon_path[:-1] == '/':
addon_path = addon_path[:-1]
assert addon_path.endswith(os.path.join('scripts', 'addons'))
addon_folder = os.path.join(addon_path, 'taichi_elements')
def install():
print("Installing...")
if os.path.exists(addon_folder): # delete the old addon
shutil.rmtree(addon_folder)
os.mkdir(addon_folder)
for f in os.listdir('.'):
if f.endswith('.py'):
shutil.copy(f, os.path.join(addon_folder, f))
print("Done.")
args = parser.parse_args()
if args.k:
while True:
time.sleep(1)
install()
else:
print(f"This will remove everything under {addon_folder}.")
print("Are you sure? [y/N]")
if input() != 'y':
print("exiting")
exit()
else:
install()