Was just about to post since I hit the same issue. Here’s what I found and how I resolved it personally for us:
Deadline 10.1.15.2 breaks Python platform
package for GlobalJobPreLoad.py
It seems since a recent update of Deadline the Python interpreter used to run GlobalJobPreLoad.py
has broken the core Python platform
package due to a change in the version string of the Python interpreter (sys.version
).
Version details:
Version: v10.1.15.2 Release (313fe6482)
Operating System: Windows 10 Pro
Error log:
Error: Global job preload script 'C:\ProgramData\Thinkbox\Deadline10\workers\machine\plugins\60c0e472d5ea80111de5b984\GlobalJobPreLoad.py': ValueError : failed to parse CPython sys.version: '2.7.13 | packaged by Thinkbox Software | (default, Apr 5 2021, 17:01:50) [MSC v.1926 64 bit (AMD64)]' (FranticX.Scripting.PythonNetException)
File "C:\ProgramData\Thinkbox\Deadline10\workers\machine\plugins\60c0e472d5ea80111de5b984\GlobalJobPreLoad.py", line 122, in __main__
env = get_project_asset_env_overrides(env)
File "C:\ProgramData\Thinkbox\Deadline10\workers\machine\plugins\60c0e472d5ea80111de5b984\GlobalJobPreLoad.py", line 39, in get_project_asset_env_overrides
import avalon.io as io
File "P:/pipeline/2.1_dev/git/avalon-core\avalon\io.py", line 17, in <module>
import pymongo
File "/path/to\pymongo\__init__.py", line 81, in <module>
from pymongo.mongo_client import MongoClient
File "/path/to\pymongo\mongo_client.py", line 54, in <module>
from pymongo.client_options import ClientOptions
File "/path/to\pymongo\client_options.py", line 24, in <module>
from pymongo.pool import PoolOptions
File "/path/to\pymongo\pool.py", line 240, in <module>
if platform.python_implementation().startswith('PyPy'):
File "C:\Program Files\Thinkbox\Deadline10\bin\Lib\platform.py", line 1453, in python_implementation
return _sys_version()[0]
File "C:\Program Files\Thinkbox\Deadline10\bin\Lib\platform.py", line 1418, in _sys_version
repr(sys_version))
at Python.Runtime.PyObject.Invoke(PyObject[] args)
at Python.Runtime.PyObject.InvokeMethod(String name, PyObject[] args)
at FranticX.Scripting.PythonNetScriptEngine.CallFunction(String moduleName, String functionName, Object[] args)
at Deadline.Plugins.PluginWrapper.d()
at Deadline.Plugins.PluginWrapper.StartJob(String& outMessage, AbortLevel& abortLevel)
This in particular comes from us importing pymongo
which however fails on platform.python_implementation()
which fails on platform._sys_version()
basically because sys.version
returns: 2.7.13 | packaged by Thinkbox Software | (default, Apr 5 2021, 17:01:50) [MSC v.1926 64 bit (AMD64)]
.
Where did this change come from and why?
For now I monkeypatched platform
in our GlobalJobPreLoad.py
# Monkeypatch the running Python's `platform._sys_version` which fails
# by default with the Python packaged with Deadline. Since Pymongo
# uses `platform.python_implementation` it won't work without this fix.
import platform
try:
platform._sys_version()
except ValueError as exc:
if "failed to parse CPython sys.version" in str(exc):
# Monkeypatch the error
print("Monkeypatching platform._sys_version in GlobalJobPreLoad.py")
original_fn = platform._sys_version
def _sys_version_patched(sys_version=None):
try:
original_fn(sys_version=sys_version)
except ValueError as exc:
# Strip the packaged by Thinkbox Software information which
# is causing the `platform` library regex to fail
if sys_version is None:
sys_version = sys.version
sys_version = sys_version.replace(" | packaged by Thinkbox Software |", "")
return original_fn(sys_version=sys_version)
platform._sys_version = _sys_version_patched
else:
raise
Note that this is a very hacky monkey patch kind of like of what @alexisp wrote here.
Still it seems to be quite a breaking issue if a core library like platform
in Python is broken for this Python interpreter?