Created
March 28, 2015 10:26
-
-
Save anonymous/a9e4388efa2a9426706c to your computer and use it in GitHub Desktop.
bootstrap_2015_03_28_11-26
This file contains hidden or 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.73, | |
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.wm.addon_enable(module="sverchok") | |
except: | |
print('failed to enable') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment