Closed zeffii closed 7 years ago
I would really like to provide that. I just couldn't make it work. I will try that sorcery.
OK, I have found suitable incantations in my quest to install PyGame. It works, if you add the other interpreter's import path to Blender's and you change the working directory to be the same as the other interpreter's. You can (apparently) reset the working directory after the import happens.
Tested on win7 x86_64 CPY 35.1 and the newest release of Blender.
I am currently testing this approach in my x86 VM.
(Still setting up Python)
Apparently there are silent switches for the python install.
OK, this works with win32 and with the newest python (so the minor minor version doesn't matter).
cool!
time to move on to more interesting things then :) like an ADSR node , and simple non (modal) operator based trigger
Or, time to move to more tedious things: I will give it a try to automatize this. It greatly bugs me that this thing is effectively uninstallable without arcane knowledge of the entrails of Blender, Python and the addon. I will leave rapid and meaningful progress on interesting and visible targets to Olppu. :D
OK, so through an excellent exercise in lolcat herding, I have found out that I can not set the Blender / Python / Batch circus up to wait for Python to install. What I am going to do is a GUI install of Python to force the user itself to wait for stuff to install.
This installs python when the addon is activated:
def register():
def install():
os.system("\""+os.path.dirname(os.path.realpath(__file__))+"\\python-3.5.2.exe\"")
threading.Thread(target=install).start()
I will have to integrate the thing with the addon and tackle the fearsome pip
. This is going to be interesting.
use os.path.join(x, y, z)
instead of hardcoding the path slashes.. (sympatico suggestion)
On paper I agree with you, but what other platform uses .exe
files and warrants such silliness?
i won't disagree about the silliness of the situation, all the more reason to keep it explicit for those of us who do intend to find bugs in code for windows.
def register():
def install():
file_path = os.path.dirname(os.path.realpath(__file__))
executable_name = "python-3.5.2.exe"
os.system(os.path.join(file_path, executable_name))
threading.Thread(target=install).start()
if that works..
Makes sense.
Actually, one has to add quotes around the path as it may (and by default does) contain spaces. So this would work:
import os
import threading
bl_info = {"name": "My Test Addon", "category": "Object"}
def register():
def install():
file_path = os.path.dirname(os.path.realpath(__file__))
executable_name = "python-3.5.2.exe"
os.system('"'+os.path.join(file_path, executable_name)+'"')
threading.Thread(target=install).start()```
this might be bicycle shed territory, but shlex has a quote function for this
import os
import threading
from shlex import quote
bl_info = {"name": "My Test Addon", "category": "Object"}
def register():
def install():
file_path = os.path.dirname(os.path.realpath(__file__))
exec_string = quote(os.path.join(file_path, "python-3.5.2.exe"))
os.system(exec_string)
threading.Thread(target=install).start()```
admirable that you guys want to automate the inclusion of the third party libraries. What's the plan here?
1) have a simple script that tests the current bpy environment for all the dependencies, if all succeed then all is good 2) if not all succeed offer an install script, in hope that step 1 would work ok 3) if step 1 continues to fail use a more hard handed approach 4) if step 1 finally succeeds allow the addon to enable properly.
?
I would truly wish to have it work like that. However, the register should be an instant operation. What would (Blenderwise) make sense would be to register an addon with UI-magic in the addons panel. It would then offer Python etc. When it feels that everything works, it should register the nodes themselves.
Sverchock had something along those lines for the updates, had it not?
Sverchok replaces the content of its working directory if it finds a newer version online when you press update. Yeah, gotta hit F8 or sometimes restart blender for changes.
This could actually develop into its own library. It would add a few lines of boilerplate, but you could the do something like:
import dependecyhell
dependencyhell.import("pygame", installIfNeeded=True)
Then that could also provide means for an interface in the addons panel to automatize this etc. Deps could be shared between addons using the same library. Having such a package manager has been in the talks for ages.
yeah, it would be useful to sverchok too, plenty of geometry libs available
Yeah. It could be a standalone addon instead of an actual library. Blender's module system would support it, I guess. The bulletproofing to interact with it could be somewhat nontrivial, though.
It could itself have a somewhat more complex setup to prepare pip
etc. up, as you would only have to do it once.
Argh! Apparently Python is also distributed as a 7MB zip file for windows. How did I miss this? It does seem to require some sorcery for pip, though.
OK, pip gets installed nicely with get-pip.py. Now on to answering the question: where the heck does pip
install its packages?
The trick of copying over sys.path
and the working directory from the other interpreter seems to work. Yay!
Should we merge the branch? Also, could you tell use where the addon menu -related UI is within Sverchock? It would be of great use for the dependency thing (that has been christened DependencyHell).
The first couple of lines here show you how to lookup the variables of user_preferences.addons
https://github.com/nortikin/sverchok/blob/master/ui/nodeview_space_menu.py
As for merging the branch, do you mean my restructure? If you decide not to I'll understand. There are many ways to do it. That happens to be my favourite for the F8 support. for your own sanity do restructure soon.
Thank you. We were already planning on merging your branch, but we just wished to get your OK for it.
Yay! We have a working Windows version and the documentation to go with it. (I am not closing the issue yet, just in case.)
The flow as it is now is:
We also updated the instructions for Linux and macOS.
Ok, we should have working MIDI in for Windows. This should bring the Windows version into feature parity with Linux.
Some of us probably do want to experiment while on windows :)