Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated bootstrap script for non developers #669

Closed
zeffii opened this issue Jun 2, 2015 · 26 comments
Closed

updated bootstrap script for non developers #669

zeffii opened this issue Jun 2, 2015 · 26 comments

Comments

@zeffii
Copy link
Collaborator

zeffii commented Jun 2, 2015

the long form of the script... node readall() should now be read()

import re
import os
import zipfile
import urllib
import json
import bpy
from urllib.request import urlopen

def get_raw_url_from_gist_id(gist_id):
    gist_id = str(gist_id)
    url = 'https://api.github.com/gists/' + gist_id
    found_json = urlopen(url).readall().decode()
    wfile = json.JSONDecoder()
    wjson = wfile.decode(found_json)

    files_flag = 'files'
    file_names = list(wjson[files_flag].keys())
    file_name = file_names[0]
    return wjson[files_flag][file_name]['raw_url']


def get_gist_as_string(gist_id):
    url = get_raw_url_from_gist_id(gist_id)
    conn = urlopen(url).readall().decode()
    return conn

def get_sv():
    print("getting sverchok bootstrapper")
    string_load = get_gist_as_string("5a4440e7455940174ab9")

    svbl = bpy.data.texts.new('sverchok bootloader')
    svbl.write(string_load)
    print("obtained bootstrapper code from github")

    # until a tidier solution comes along
    ctx = bpy.context.copy()
    ctx['edit_text'] = svbl # specify the text datablock to execute
    bpy.ops.text.run_script(ctx)
    print("execution bootstrapper complete")

get_sv()
@zeffii

This comment has been minimized.

@zeffii zeffii closed this as completed Nov 22, 2015
@zeffii

This comment has been minimized.

@zeffii
Copy link
Collaborator Author

zeffii commented Aug 6, 2021

works on 2.93 or 3.0

import re
import os
import zipfile
import urllib

import bpy
from urllib.request import urlopen

# 2.93  or 3.0  ... you don't need to set this manually anymore.
MAJOR, MINOR = bpy.app.version_file[0:2]
blender_version = f"{MAJOR}.{MINOR}"

url = "https://gist.githubusercontent.com/zeffii/5a4440e7455940174ab9/raw/bootstrap.py"

def get_sv():
    print("getting sverchok bootstrapper")
    string_load = urlopen(url).read().decode()
    
    # depending on the current version...
    new_string_load = re.sub("version=(\d\.\d+)", f"version={blender_version}", string_load)

    svbl = bpy.data.texts.new('sverchok bootloader')
    svbl.write(new_string_load)
    print("obtained bootstrapper code from github")

    ctx = bpy.context.copy()
    ctx['edit_text'] = svbl  # specify the text datablock to execute
    bpy.ops.text.run_script(ctx)
    print("execution bootstrapper complete")

get_sv()

@luckychris
Copy link

i got this error when running on my macbook:

Traceback (most recent call last):
File "/Users/cd/Downloads/install_sverchok.blend/InstallSverchok", line 34, in
File "/Applications/Blender.app/Contents/Resources/3.0/scripts/modules/bpy/ops.py", line 130, in call
ret = _op_call(self.idname_py(), C_dict, kw, C_exec, C_undo)
RuntimeError: Error: Traceback (most recent call last):
File "/Applications/Blender.app/Contents/Resources/3.0/scripts/modules/addon_utils.py", line 351, in enable
mod = import(module_name)
ModuleNotFoundError: No module named 'sverchok'

Error: Python script failed, check the message in the system console

@zeffii
Copy link
Collaborator Author

zeffii commented Aug 7, 2021

If you used the "install Addon" button in Blender preferences, then Blender will put the add-on in a system-specific folder.

https://docs.blender.org/manual/en/latest/advanced/blender_directory_layout.html#platform-dependent-paths

as you use osx, if you get the message no module named sverchok, then Blender is not finding a folder named sverchok
in any of the scripts subdirs in https://docs.blender.org/manual/en/latest/advanced/blender_directory_layout.html#macos

@zeffii
Copy link
Collaborator Author

zeffii commented Aug 7, 2021

maybe Blender 3.0 needs to be given permissions to modify the filesystem ? else Python can not create a directory to unzip the sverchok source correctly.

@luckychris
Copy link

Maybe - but why did all other adons work?🙈

@zeffii
Copy link
Collaborator Author

zeffii commented Aug 7, 2021

beats me.

@luckychris
Copy link

Or don’t they create folders? I don’t know. You are the expert.

@zeffii
Copy link
Collaborator Author

zeffii commented Aug 7, 2021

well the bootstrap script will, i think, specifically look in the first addon folder shown in that list, and look for a folder called 'sverchok'. If that folder's 3.0/scripts/addons doesn't contain a folder called "sverchok" then there's nothing to enable.

for example in windows..

image

@luckychris
Copy link

ok, don't know why and don't know how...maybe because i downloaded the newest blender3.0 alpha....but all of a sudden it showed now for the first time the 1.0 version in sverchok and i could enable it. And believe or not ....rendering works too now. But i have no idea why i now could see 1.0 and it worked. Whenever i saw 1.0 version until now, i wasn't able to enable it.

@luckychris
Copy link

But...(after downloading a fresh 2.93) i got this error, when installing 1.0 beta .....
image

@luckychris
Copy link

i don't know if it is interesting for you, just checked the folder structure of 3.0 which works now, it looks like this:

image

folder name is sverchok-0 ...i think you ...and i ....didn't expect that. But that's how it works. I did not rename that.

@luckychris
Copy link

2.93 in comparison to that...(does not work) looks like this:

image

@zeffii
Copy link
Collaborator Author

zeffii commented Aug 7, 2021

rename it to sverchok , the extra -1.0.0-beta.2 turns the folder into an invalid module name i think... for the enable step

@zeffii
Copy link
Collaborator Author

zeffii commented Aug 7, 2021

correct, i have no explanation at the moment for the folder being called sverchok-0 unless that's what happens if you have two folders called sverchok, there might be some autorenaming of new folders..

@luckychris
Copy link

i renamed it and when i tried to enable, i got this:

image

@luckychris
Copy link

then i was brave, maybe reckless...and renamed it to sverchok-1...and i got:

image

now i am feeling ripped....

@luckychris
Copy link

ok, clean try:

i have:

image

after installing and before enabling it looks like this:

image

then tried to enable and got:

image

@luckychris
Copy link

luckychris commented Aug 7, 2021

next "clean try" was: renaming it to sverchok BEFORE enabling, same result with "no module named 'sverchok-1' ...it's weird.

@zeffii
Copy link
Collaborator Author

zeffii commented Aug 7, 2021

if there was no other folder in scripts/addons called sverchok, then there should be no reason for Blender to automatically rename that folder, this suggests to me that there are parallel folders ( system specific as listed above ) that do have a folder named sverchok and blender attempts to avoid name collisions over all the potential folders.

but i'm not certain.

@luckychris
Copy link

luckychris commented Aug 7, 2021

nope, that's why i wrote "clean try" and copied the folder structure as screenshot for you. There were no sverchok folders.

@zeffii
Copy link
Collaborator Author

zeffii commented Aug 7, 2021

well.. now you've seen the dirtier side of add-on development.

@luckychris
Copy link

I just cannot believe I am the only one with a macOS having this problem….🙈

@zeffii
Copy link
Collaborator Author

zeffii commented Aug 18, 2021

https://gist.github.com/zeffii/a325ab87931114311198c4571322b82b

this is a slightly modified that drops features i planned but never used.

@0nzlo
Copy link

0nzlo commented Jun 21, 2022

ok, don't know why and don't know how...maybe because i downloaded the newest blender3.0 alpha....but all of a sudden it showed now for the first time the 1.0 version in sverchok and i could enable it. And believe or not ....rendering works too now. But i have no idea why i now could see 1.0 and it worked. Whenever i saw 1.0 version until now, i wasn't able to enable it.

Wow this works!! Thank you haha...After trying with many versions I gave it a try and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants