Closed Helveg closed 3 years ago
In order to be able to literally modify bl_info
, we could clone with --depth=1
, overwrite the data in blenderneuron/__init__.py
depending on what blender --version
tells us, zip it and install it.
I am a horrible bash scripter so expect the first version to only work if everything is OK and crash horribly otherwise ;p
Yes, that should work and simplify the installation a bit.
If the addon_install
operator does not work for some reason, I know it's possible to drop the contents of the addon zip file in the blender/2.XX/scripts/addons/
folder and then call addon_enable
operator.
Couple of concerns:
pip install blenderneuron
or separately as needed. That way users with Windows OS+Blender could install the addon without having Bash. Otherwise, we'd need to write/maintain .sh/.bat files for each platform.blender(.exe)
binary. How could we collect/pass the choice to the installer? Does pip
allow passing of custom params? Could also use an ENV var e.g. BLENDER_PATH
.What do you think?
bat
as a Windows user ;p ). I do not think that we should use pip
to execute our Blender installation code. They are moving away from arbitrary code execution, which only old formats like source distributions can do, but I'd like to distribute automated wheels with cibuildwheel. Our python package shouldn't even load the code that the Blender addon needs. By checking bpy
we only load the _blender
's addon when inside Blender.blender
on the PATH or error out 😂 bl_info["blender"]
version we put in there haha.The repository is rather large, so we'd best distribute a leaner version from the CI pipelines hehe
I'm thinking that the installer could be simplified right? We just:
1) During a release
CI build we create zip for each blender version that we support and modify the bl_info
accordingly.
2) Host a python script at https://blenderneuron.org/install
, pipe that to python
blender --version
blender --background --python tmp_file.py
pip install blenderneuron
We host the build artifacts like this on blenderneuron.org
:
https://blenderneuron.org/addon/<version>/<blender-version>
Then a user can install us with:
# Linux & Windows PowerShell, (probably also Mac?)
curl https://blenderneuron.org/install | python
Take a look at the rework/installer
branch, it works but it doesn't enable the addon (see https://blender.stackexchange.com/questions/208650/how-can-i-permanently-enable-an-addon-in-the-userpref, let's hope the answer isn't "you can't").
The non-terminal oriented folks can still grab the zip files from those URLs and we can make https://blenderneuron.org/latest
point to the latest zip for the latest blender and /latest/<blender-version>
to our latest version for a specific Blender version!
Good news! We might be able to finish the installer if we save the user preferences inside of the addon install script using bpy.ops.wm.save_userpref()
. I can't test if this solves the issue right now but I'm adding it here for future reference :)
It works!!! We have an automatic installer. Still VERY fragile but as long as blender
is a valid command and blenderneuron.zip
is
in the CWD we can install using python installer/install.py
!
We should discuss next steps in CI so that we can manage the content on blenderneuron.org from the CI pipelines and sexify the install to wget https://blenderneuron.org/install | python
Next steps: some basic error handling
I was wondering if installing addons was possible programmatically, and I for sure thought it wouldn't be as imho it poses a huge security risk, but look:
https://docs.blender.org/api/current/bpy.ops.preferences.html#bpy.ops.preferences.addon_install
We should be able to provide an installer that contains something like:
Where the py file probably does:
And for users installing blenderneuron now becomes as simple as: