-
-
Save zeffii/5a4440e7455940174ab9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import urllib.request | |
from zipfile import ZipFile | |
import shutil | |
import os | |
from os.path import basename | |
from os.path import dirname | |
url = 'https://github.com/nortikin/sverchok/archive/master.zip' | |
configs = dict( | |
version=2.93, | |
addons_folder='addons', # or addons_contrib | |
fresh_install=True, | |
backup_existing=True, | |
addon_folder_name='sverchok' | |
) | |
bpath = bpy.app.binary_path | |
bdir = dirname(bpath) | |
destination_dir = os.path.join( | |
bdir, | |
str(configs['version']), 'scripts', | |
configs['addons_folder'], | |
configs['addon_folder_name']) | |
print('destination directory:', destination_dir) | |
if not os.path.exists(destination_dir): | |
os.makedirs(destination_dir) | |
zip_filename = os.path.basename(url) | |
sverchok_zip_path = os.path.join(destination_dir, zip_filename) | |
# download it | |
urllib.request.urlretrieve(url, sverchok_zip_path) | |
g = [] | |
archive = ZipFile(sverchok_zip_path) | |
for _file in archive.namelist(): | |
if _file.startswith('sverchok-master'): | |
n = archive.extract(_file, destination_dir) | |
g.append(n) | |
left = os.path.split(g[1]) | |
left = os.path.split(left[0]) | |
# # move all from \sverchok\sverchok-master to \sverchok | |
for _f in g[1:]: | |
if os.path.isfile(_f): | |
m = _f.replace(g[0], left[0]) | |
dest = os.path.dirname(m) | |
if not os.path.exists(dest): | |
os.makedirs(dest) | |
shutil.move(_f, m) | |
shutil.rmtree(g[0]) | |
try: | |
bpy.utils.refresh_script_paths() | |
bpy.ops.preferences.addon_enable('INVOKE_DEFAULT', module="sverchok") | |
except Exception as err: | |
print(err) | |
print("-- end bootstrapper script execution --") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment