Closed rwols closed 2 months ago
Do you mind providing the original full output of $ blender -b -P print_sys_path.py
so we don't need to pipe to other binaries which may not on user's machine?
Can blender execute script from stdin so that we don't need to create a temp file print_sys_path.py
?
Do you mind providing the original full output of $ blender -b -P print_sys_path.py
~/Desktop $ blender --background --python print_sys_path.py
Color management: using fallback mode for management
Color management: Error could not find role data role.
Blender 3.0.1
Read prefs: /home/raoul/.config/blender/3.0/config/userpref.blend
Color management: scene view "Filmic" not found, setting default "Standard".
{"executable": "/usr/bin/python3.10", "paths": ["/usr/share/blender/scripts/startup", "/usr/share/blender/scripts/modules", "/usr/lib/python310.zip", "/usr/lib/python3.10", "/usr/lib/python3.10/lib-dynload", "/usr/local/lib/python3.10/dist-packages", "/usr/lib/python3/dist-packages", "/usr/lib/python3.10/dist-packages", "/usr/share/blender/scripts/freestyle/modules", "/usr/share/blender/scripts/addons/modules", "/home/raoul/.config/blender/3.0/scripts/addons/modules", "/usr/share/blender/scripts/addons"]}
~/Desktop $ cat print_sys_path.py
import sys
import json
json.dump({"executable": sys.executable, "paths": sys.path}, sys.stdout)
exit(0)
so we don't need to pipe to other binaries which may not on user's machine?
I'm not sure what you mean here. Are you suggesting to not use the Blender executable to determine the extra paths? I think we should utilize the application as it's probably the most accurate way to get the extra paths.
Or are you talking about the usage of grep
? I wrote a solution in a branch (see pull request) that doesn't use grep
, but Python's str.find
.
Can blender execute script from stdin so that we don't need to create a temp file print_sys_path.py?
There is an option named --python-expr
(see: https://docs.blender.org/manual/en/latest/advanced/command_line/arguments.html#python-options). I tried using that, but it doesn't seem to execute the final exit(0)
statement, which is needed to exit the application. Otherwise it'll just idle hang.
Or are you talking about the usage of
grep
? I wrote a solution in a branch (see pull request) that doesn't usegrep
, but Python'sstr.find
.
Yes I mean this. But since you have filed a PR, it has spoken for itself. 😄
The 3D modeling program Blender is scriptable with Python scripts. I would like to use Sublime Text + LSP-pyright to write these kinds of scripts. Blender uses some additional search paths. These can be discovered with the following command-line:
It prints some additional text to stdout, which I can't seem to avoid. So I used
grep
to search for the JSON output. This is hacky and should probably be improved. The print_sys_path.py script is very simple:So from this we see that for a a "Blender" dev environment, we need the additional search paths