This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 128
Blender: Set --python-use-system-env from PreLaunchHook #5565
Closed
BigRoy
wants to merge
6
commits into
ynput:develop
from
BigRoy:enhancement/blender_prehook_use_system_env
+56
−32
Closed
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
68782d7
Set `--python-use-system-env` from PreLaunchHook instead of system se…
BigRoy c82dbc2
Fix comment
BigRoy d533f4c
Only use on `local` launch type
BigRoy e09b517
Merge branch 'develop' into enhancement/blender_prehook_use_system_env
BigRoy 7508cd8
Add adding of `--python-use-system-env` through prelaunch hook toggle…
BigRoy e2b1dbd
Merge branch 'develop' into enhancement/blender_prehook_use_system_env
mkolar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
openpype/hosts/blender/hooks/pre_add_python_use_system_env.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from openpype.lib.applications import PreLaunchHook, LaunchTypes | ||
|
||
|
||
class AddPythonUseSystemEnvArg(PreLaunchHook): | ||
"""Add `--python-use-system-env` arg to blender launch.""" | ||
|
||
# Append before file argument from add last workfile (at order 10) | ||
order = 5 | ||
app_groups = {"blender"} | ||
launch_types = {LaunchTypes.local} | ||
|
||
def execute(self): | ||
|
||
add_var = self.get_application_setting("add_python_use_system_env", | ||
default=True) | ||
if not add_var: | ||
return | ||
|
||
arg = "--python-use-system-env" | ||
if arg not in self.launch_context.launch_args: | ||
self.log.debug(f"Adding required {arg} argument") | ||
self.launch_context.launch_args.append(arg) | ||
else: | ||
self.log.debug(f"Required {arg} argument already provided before " | ||
f"this prelaunch hook.") | ||
|
||
def get_application_setting(self, key, default=None): | ||
app = self.launch_context.application | ||
group_name = app.group.name | ||
app_name = app.name | ||
return ( | ||
self.data["system_settings"]["applications"][group_name] | ||
["variants"][app_name].get(key, default) | ||
) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This likely moves in AYON? Is there a better approach to this @iLLiCiTiT ?
Basically I'm trying to get an extra key from the variant setting.
(I'd also need to update the settings + defaults in AYON of course - if I know where those are)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep this will need to be made forward compatible with AYON. Settings and their defaults are here ;) https://github.com/ynput/OpenPype/tree/develop/server_addon/applications/server