Skip to content

Instantly share code, notes, and snippets.

@zeffii
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/91faac0febf94c2f7831 to your computer and use it in GitHub Desktop.
Save zeffii/91faac0febf94c2f7831 to your computer and use it in GitHub Desktop.
sverchok bootstrap
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])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment