Skip to content

Commit 9cd4d3a

Browse files
authored
8010 more ue5 fixes (#12)
Mostly addressed CR comments from Epic. Fixed a warning with yaml loading.
1 parent e480311 commit 9cd4d3a

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def pre_app_init(self):
8888

8989
self.init_qt_app()
9090

91-
# Load the tk_unreal module (the Shotgun engine wrapper for Unreal)
91+
# Load the tk_unreal module (the SG engine wrapper for Unreal)
9292
self.tk_unreal = self.import_module("tk_unreal")
9393
self.unreal_sg_engine = self.tk_unreal.config.wrapper_instance
9494

hooks/tk-multi-publish2/basic/publish_movie.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,8 @@ def _unreal_render_sequence_with_sequencer(self, output_path, unreal_map_path, s
756756
# Prevent SG TK to try to bootstrap in the new process
757757
if "UE_SHOTGUN_BOOTSTRAP" in run_env:
758758
del run_env["UE_SHOTGUN_BOOTSTRAP"]
759+
if "UE_SHOTGRID_BOOTSTRAP" in run_env:
760+
del run_env["UE_SHOTGRID_BOOTSTRAP"]
759761

760762
subprocess.call(cmdline_args, env=run_env)
761763

@@ -896,6 +898,8 @@ def _unreal_render_sequence_with_movie_queue(self, output_path, unreal_map_path,
896898
# Prevent SG TK to try to bootstrap in the new process
897899
if "UE_SHOTGUN_BOOTSTRAP" in run_env:
898900
del run_env["UE_SHOTGUN_BOOTSTRAP"]
901+
if "UE_SHOTGRID_BOOTSTRAP" in run_env:
902+
del run_env["UE_SHOTGRID_BOOTSTRAP"]
899903
self.logger.info("Running %s" % cmd_args)
900904
subprocess.call(cmd_args, env=run_env)
901905
return os.path.isfile(output_path), output_path

plugins/basic/bootstrap.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,10 @@
44

55
import sys
66
import os
7-
import unreal
87

98
# Setup sys.path so that we can import our bootstrapper.
109
plugin_root_dir = os.path.abspath(os.path.dirname(__file__))
1110
sys.path.insert(0, os.path.join(plugin_root_dir, "python"))
1211

13-
# Temp workaround for UE5 dev: for some reasons the core/python path is missing
14-
# in sys.path but is present in the PYTHONPATH.
15-
# Make sure sys.path is up to date with what is in the PYTHON PATH
16-
python_path = os.environ.get("PYTHONPATH") or ""
17-
for path in python_path.split(os.pathsep):
18-
# We can have empty entries for consecutives separators
19-
if path and path not in sys.path:
20-
unreal.log_warning(
21-
"Adding missing %s Python path to sys paths" % path,
22-
)
23-
sys.path.append(path)
24-
2512
from tk_unreal_basic import plugin_bootstrap
2613
plugin_bootstrap.bootstrap_plugin(plugin_root_dir)

plugins/basic/python/tk_unreal_basic/plugin_bootstrap.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def _on_engine_initialized():
6868
sgtk_logger.debug("tk-unreal finished initialization.")
6969

7070
import unreal
71+
# ShotgunEngine was renamed to ShotgridEngine from UE5
7172
if hasattr(unreal, "ShotgridEngine"):
7273
unreal.ShotgridEngine.get_instance().on_engine_initialized()
7374
else:
@@ -89,7 +90,7 @@ def _initialize_manager(plugin_root_path):
8990

9091
# open the yaml file and read the data
9192
with open(plugin_info_yml, "r") as plugin_info_fh:
92-
plugin_info = yaml.load(plugin_info_fh)
93+
plugin_info = yaml.load(plugin_info_fh, yaml.SafeLoader)
9394

9495
base_config = plugin_info["base_configuration"]
9596
plugin_id = plugin_info["plugin_id"]

python/tk_unreal/unreal_sg_engine.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ def _post_init(self):
2828
config.wrapper_instance = self
2929

3030
# Shotgun integration components were renamed to Shotgrid from UE5
31+
# these new methods are not available in UE4, we provide backward
32+
# compatibility so scripts using the old methods don't break in UE5,
33+
# but also forward compatibility, so users can start using the new
34+
# names in UE4.
3135
if hasattr(UESGEngine, "get_shotgrid_menu_items"):
3236
@unreal.ufunction(override=True)
3337
def get_shotgrid_menu_items(self):
@@ -47,6 +51,7 @@ def get_shotgun_menu_items(self):
4751
"""
4852
Provide backward compatibility.
4953
"""
54+
unreal.log_warning("get_shotgun_menu_items is deprecated, get_shotgrid_menu_items should be used instead.")
5055
return self.get_shotgrid_menu_items()
5156
else:
5257
@unreal.ufunction(override=True)
@@ -59,6 +64,7 @@ def get_shotgun_menu_items(self):
5964
engine = sgtk.platform.current_engine()
6065
menu_items = self.create_menu(engine)
6166

67+
unreal.log_warning("get_shotgun_menu_items is deprecated, get_shotgrid_menu_items should be used instead.")
6268
unreal.log("get_shotgun_menu_items returned: {0}".format(menu_items.__str__()))
6369

6470
return menu_items
@@ -74,6 +80,7 @@ def get_shotgun_work_dir(self, *args, **kwargs):
7480
"""
7581
Provide backward compatibility.
7682
"""
83+
unreal.log_warning("get_shotgun_work_dir is deprecated, get_shotgrid_work_dir should be used instead.")
7784
return self.get_shotgrid_work_dir(*args, **kwargs)
7885
else:
7986
def get_shotgrid_work_dir(self, *args, **kwargs):

startup.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,17 @@ def prepare_launch(self, exec_path, args, file_to_open=None):
9090
# Signals which engine instance from the environment is going to be used.
9191
required_env["SHOTGUN_ENGINE"] = self.engine_name
9292

93-
# Set the bootstrap location in the environment variable that will be used by the Unreal Shotgun startup script
93+
# Set the bootstrap location in the environment variable that will be used by the Unreal Shotgun plugin
94+
# startup script
9495
bootstrap_script = os.path.join(self.disk_location, "plugins", "basic", "bootstrap.py")
96+
# From UE5, the UE_SHOTGRID_BOOTSTRAP environment variable is supported.
97+
# We still need to support UE_SHOTGUN_BOOTSTRAP for previous UE versions.
9598
required_env["UE_SHOTGUN_BOOTSTRAP"] = bootstrap_script
96-
99+
required_env["UE_SHOTGRID_BOOTSTRAP"] = bootstrap_script
100+
# UE5 Python ignores PYTHONPATH and only uses UE_PYTHONPATH
101+
# blindly copy what was set so modules (e.g. SG TK core) are found
102+
# when bootstrapping.
103+
required_env["UE_PYTHONPATH"] = os.environ.get("PYTHONPATH") or ""
97104
self.logger.debug("Executable path: %s", exec_path)
98105
self.logger.debug("Launch environment: %s", pprint.pformat(required_env))
99106
self.logger.debug("Launch arguments: %s", args)

0 commit comments

Comments
 (0)