From 691d2f3b07d9d5373b49472f05c45f90dcb34a17 Mon Sep 17 00:00:00 2001 From: Jesse Lucas Date: Tue, 16 Aug 2022 15:52:04 -0400 Subject: [PATCH] Use appropriate reload method for Py2 or Py3 Avoiding use of the six.py module, since it may not be present in the user's environment at the time this proxy is imported. --- setup/tank_api_proxy/sgtk/__init__.py | 9 +++++++++ setup/tank_api_proxy/tank/__init__.py | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/setup/tank_api_proxy/sgtk/__init__.py b/setup/tank_api_proxy/sgtk/__init__.py index 0d32df077f..d1e008da8d 100644 --- a/setup/tank_api_proxy/sgtk/__init__.py +++ b/setup/tank_api_proxy/sgtk/__init__.py @@ -62,6 +62,15 @@ pipeline_config = os.path.abspath(pipeline_config) os.environ["TANK_CURRENT_PC"] = pipeline_config +# From: https://stackoverflow.com/a/40119302 +try: + reload # Python 2.7 +except NameError: + try: + from importlib import reload # Python 3.4+ + except ImportError: + from imp import reload # Python 3.0 - 3.3 + # ok we got the parent location # prepend this to the python path and reload the module # this way we will load the 'real' tank! diff --git a/setup/tank_api_proxy/tank/__init__.py b/setup/tank_api_proxy/tank/__init__.py index 11dc2b6b06..5023e3e77b 100644 --- a/setup/tank_api_proxy/tank/__init__.py +++ b/setup/tank_api_proxy/tank/__init__.py @@ -60,6 +60,15 @@ pipeline_config = os.path.abspath(pipeline_config) os.environ["TANK_CURRENT_PC"] = pipeline_config +# From: https://stackoverflow.com/a/40119302 +try: + reload # Python 2.7 +except NameError: + try: + from importlib import reload # Python 3.4+ + except ImportError: + from imp import reload # Python 3.0 - 3.3 + # ok we got the parent location # prepend this to the python path and reload the module # this way we will load the 'real' tank!