Python 3 Upgrade Guide

Warning

Please be advised that Python 2 is no longer supported and there will be no more updates, including patches for critical security issues. See Sunsetting Python 2. Because of this, using Python 2 to run Deadline or run Deadline plugins is not advised.

Overview

This guide is for users that have made custom Python workflows or have modified any Python scripts shipped with Deadline. If you aren’t using custom scripts and are relying on what Deadline ships, no further actions are required. Once you upgrade to Deadline 10.1.20 (or later), you will be migrated to Python 3.7!

Important changes

Deadline now ships a Python 3 installation alongside the existing Python 2 bundle. You can control the version of Python that Deadline uses in different workflows as outlined below:

Events

Note

All Events will run in the same sandbox and use the same Python version. This means that you cannot have some Events run in Python 2 and others in Python 3. All Event Plugins shipped with Deadline are now Python 2/3 compatible. If you have custom or modified Event Plugins that are not Python 3 compatible you must revert this setting back to Python 2. Once your custom Event Plugins have also been made Python 3 compatible you can update this setting to use Python 3.

As of Deadline 10.1.20, fresh installs of a database will cause event plugins to run in Python 3 by default. If an earlier version of Deadline was installed, it will continue run in Python 2. You can change this behaviour in the repository settings. If you do nothing, it’ll automatically change to Python 3 when Python 2 is removed from Deadline.

You can change the Python version that Event Plugins use by navigating in the Deadline Monitor to Tools > Configure Respository Options > Python Settings and modifying Event Sandbox Python Version.

../_images/python_upgrade_event_sandbox.png

Plugins

Note

Each Plugin runs in its own sandbox. This means Plugins don’t have to run in the same Python version. Plugins shipped by Deadline are now Python 2/3 compatible.

Add a shebang line to the top of the Python Plugin file to explicitly choose a Python version.

  • Providing no shebang line or an invalid shebang line will default to Python 2

  • Providing: #!/usr/bin/env python or #!/usr/bin/env python2 will use Python 2

  • Providing: #!/usr/bin/env python3 will use Python 3

Example: Running the Blender plugin in Python 3:

  1. Open DeadlineRepository10/plugins/Blender/Blender.py

  2. At the top of the file add #!/usr/bin/env python3

  3. The next time you run the plugin it will run in Python 3.

#!/usr/bin/env python3
from __future__ import absolute_import
from System import *
from System.Diagnostics import *
from System.IO import *

from Deadline.Plugins import *
from Deadline.Scripting import *

def GetDeadlinePlugin():
    return BlenderPlugin()

Deadline’s Python Environment

Choosing the Deadline Client’s Python Environment

Note

By default, Deadline Client applications run in Python 3. The application’s Python is what runs the interface and any custom scripts. With the exception of the deprecated Deadline Balancer application, the interfaces and scripts shipped by Deadline are now fully Python 2/3 compatible.

There are three ways to specify the desired Python version for the Deadline Client applications. These are listed below in order of decreasing priority:

Passing the Python version as a command line argument

The Python version can be easily changed through the command line.

  1. Go into the Deadline Client folder:

    • Linux: /opt/Thinkbox/Deadline10/bin

    • Windows: C:\Program Files\Thinkbox\Deadline10\bin

    • macOS: /Applications/Thinkbox/Deadline10/bin

  1. Launch a client application providing the command line argument -py-ver <Python version>

    • Example: deadlinemonitor -py-ver 2

Setting an environment variable

Create an environment variable called DCONFIG_PYTHON_VERSION with the value of the major version of Python.

  • DCONFIG_PYTHON_VERSION=2 for Python 2

  • DCONFIG_PYTHON_VERSION=3 for Python 3

Specifying the Python version in the configuration file

To specify the Python version for a Deadline application, create an entry in the ‘Deadline.ini` configuration file similar to: <Application Name>PythonVersion=<Python Major Version>. For more information on these configuration files see Client Configuration Files.

For example: To run the Deadline Monitor in Python 3 you will need to add the following line to Thinkbox/Deadline10/Deadline.ini:

[Deadline]
MonitorPythonVersion=3

Why are we upgrading to Python 3?

Our goal is to meet the recommendations of the VFX Platform, which as of CY2020 recommends using Python 3.7. As of January 1, 2020, Python 2 was sunset. This means that it is no longer supported and there will be no more updates even if someone finds a security problem. For more information see Sunsetting Python 2.

How to upgrade to Python 3?

Your custom/modified scripts, Plugins, and Events will need to eventually support Python 3. For more information see Porting Python 2 Code to Python 3.

To which version are we upgrading Python?

We are upgrading to Python 3.7 as recommended by VFXP CY2021.

How long do we have to migrate to Python 3?

The goal is to eventually remove Python 2 support for Deadline, but there is no set date yet. We will update our documentation when the date is set. To avoid having any disruptions, we recommend you start migrating to Python 3 as soon as possible.