Davinci-resolve-studio External Scripts Broken

by ADMIN 47 views

Introduction

DaVinci Resolve Studio is a professional video editing software that offers advanced features and tools for filmmakers and editors. However, users have reported issues with external scripting, specifically with Python and Lua scripts, when installed via the AUR package davinci-resolve-studio (version 19.1.4-1). In this article, we will explore the issue and provide a step-by-step guide to reproduce the problem.

The Issue

External scripting (both Python and Lua) fails to connect to DaVinci Resolve Studio when installed via the AUR package davinci-resolve-studio (version 19.1.4-1). The connection attempt via Python results in a C++ runtime error: /opt/resolve/libs/libc++.so.1: undefined symbol: __cxa_init_primary_exception. This error occurs when trying to import the DaVinciResolveScript module.

Steps to Reproduce (Python)

To reproduce the issue, follow these steps:

Step 1: Ensure DaVinci Resolve Studio is Running

First, ensure that DaVinci Resolve Studio is running on your system. You can launch the application from the AUR package.

Step 2: Create a Minimal Python Script

Create a new file called test_resolve.py with the following content:

import sys

def load_source(module_name, file_path):
    if sys.version_info[0] >= 3 and sys.version_info[1] >= 5:
        import importlib.util

        module = None
        spec = importlib.util.spec_from_file_location(module_name, file_path)
        if spec:
            module = importlib.util.module_from_spec(spec)
        if module:
            sys.modules[module_name] = module
            spec.loader.exec_module(module)
        return module
    else:
        import imp
        return imp.load_source(module_name, file_path)


def GetResolve():
    try:      
        # The PYTHONPATH needs to be set correctly for this import statement to work.
        # An alternative is to import the DaVinciResolveScript by specifying absolute path (see ExceptionHandler logic)
        import DaVinciResolveScript as bmd
    except ImportError:
        expectedPath = "/opt/resolve/Developer/Scripting/Modules/"

        # check if the default path has it...
        print("Unable to find module DaVinciResolveScript from $PYTHONPATH - trying default locations")
        try:
            load_source('DaVinciResolveScript', expectedPath + "DaVinciResolveScript.py")
            import DaVinciResolveScript as bmd
        except Exception as ex:
            # No fallbacks ... report error:
            print("The module is expected to be located in: " + expectedPath)
            print(ex)
            sys.exit()
    print("DaVinciResolveScript module loaded successfully")
    return bmd.scriptapp("Resolve")

if __name__ == "__main__":
    GetResolve()

This script attempts to import the DaVinciResolveScript module and connect to DaVinci Resolve Studio using the bmd.scriptapp("Resolve") function.

Step 3: Run the Script

Run the script from your terminal using the following: python test_resolve.py

Expected Results

The script should successfully import DaVinciResolveScript, connect via bmd.scriptapp("Resolve"), and print "DaVinciResolveScript module loaded successfully!".

Actual Results

The script fails during the bmd.scriptapp("Resolve") call (or possibly during the import if the C++ library loading fails earlier), printing the following error:

Unable to find module DaVinciResolveScript from $PYTHONPATH - trying default locations
The module is expected to be located in: /opt/resolve/Developer/Scripting/Modules/
/opt/resolve/libs/libc++.so.1: undefined symbol: __cxa_init_primary_exception

Conclusion

The issue with external scripting in DaVinci Resolve Studio is specific to the AUR packaging and does not occur when using a containerized version of the software. The error occurs due to a C++ runtime error: /opt/resolve/libs/libc++.so.1: undefined symbol: __cxa_init_primary_exception. To quickly test whether scripts work, you can use the X-Raym/DaVinci-Resolve-Scripts repository.

Workarounds

While the issue is specific to the AUR packaging, there are a few workarounds that can help you use external scripting with DaVinci Resolve Studio:

  1. Use a Containerized Version: Use a containerized version of DaVinci Resolve Studio, such as the fat-tire/resolve repository, which does not exhibit this issue.
  2. Modify the Script: Modify the script to use an absolute path to the DaVinciResolveScript module, rather than relying on the PYTHONPATH environment variable.
  3. Use a Different Scripting Language: Consider using a different scripting language, such as Lua, which may not be affected by this issue.

Future Development

Q: What is the issue with external scripting in DaVinci Resolve Studio?

A: The issue with external scripting in DaVinci Resolve Studio is that it fails to connect to the software when installed via the AUR package davinci-resolve-studio (version 19.1.4-1). The connection attempt via Python results in a C++ runtime error: /opt/resolve/libs/libc++.so.1: undefined symbol: __cxa_init_primary_exception.

Q: What are the steps to reproduce the issue?

A: To reproduce the issue, follow these steps:

  1. Ensure DaVinci Resolve Studio is running on your system.
  2. Create a minimal Python script (test_resolve.py) with the following content:

import sys

def load_source(module_name, file_path): if sys.version_info[0] >= 3 and sys.version_info[1] >= 5: import importlib.util

    module = None
    spec = importlib.util.spec_from_file_location(module_name, file_path)
    if spec:
        module = importlib.util.module_from_spec(spec)
    if module:
        sys.modules[module_name] = module
        spec.loader.exec_module(module)
    return module
else:
    import imp
    return imp.load_source(module_name, file_path)

def GetResolve(): try:
# The PYTHONPATH needs to be set correctly for this import statement to work. # An alternative is to import the DaVinciResolveScript by specifying absolute path (see ExceptionHandler logic) import DaVinciResolveScript as bmd except ImportError: expectedPath = "/opt/resolve/Developer/Scripting/Modules/"

    # check if the default path has it...
    print("Unable to find module DaVinciResolveScript from $PYTHONPATH - trying default locations")
    try:
        load_source('DaVinciResolveScript', expectedPath + "DaVinciResolveScript.py")
        import DaVinciResolveScript as bmd
    except Exception as ex:
        # No fallbacks ... report error:
        print("The module is expected to be located in: " + expectedPath)
        print(ex)
        sys.exit()
print("DaVinciResolveScript module loaded successfully")
return bmd.scriptapp("Resolve")

if name == "main": GetResolve()

3.  Run the script from your terminal using the following: `python test_resolve.py`

**Q: What are the expected results?**
----------------------------------

A: The script should successfully import `DaVinciResolveScript`, connect via `bmd.scriptapp("Resolve")`, and print "DaVinciResolveScript module loaded successfully!".

**Q: What are the actual results?**
------------------------------

A: The script fails during the `bmd.scriptapp("Resolve")` call (or possibly during the import if the C++ library loading fails earlier), printing the following error:

Unable to find module DaVinciResolveScript from $PYTHONPATH - trying default locations The module is expected to be located in: /opt/resolve/Developer/Scripting/Modules/ /opt/resolve/libs/libc++.so.1: undefined symbol: __cxa_init_primary_exception

**Q: Is there a workaround for this issue?**
-----------------------------------------

A: Yes, there are a few workarounds that can help you use external scripting with DaVinci Resolve Studio:

1.  **Use a Containerized Version**: Use a containerized version of DaVinci Resolve Studio, such as the `fat-tire/resolve` repository, which does not exhibit this issue.
2.  **Modify the Script**: Modify the script to use an absolute path to the `DaVinciResolveScript` module, rather than relying on the `PYTHONPATH` environment variable.
3.  **Use a Different Scripting Language**: Consider using a different scripting language, such as Lua, which may not be affected by this issue.

**Q: Will this issue be resolved in future updates?**
------------------------------------------------

A: The issue with external scripting in DaVinci Resolve Studio is likely related to the AUR packaging and may be resolved in future updates. In the meantime, users can use the workarounds mentioned above to continue using external scripting with the software.

**Q: Where can I find more information about this issue?**
---------------------------------------------------

A: You can find more information about this issue on the official DaVinci Resolve Studio forums or by searching for related topics on online communities and forums.