Skip to content

benjavides/TD_debugger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

This is a working proof of concept for debugging python code executing inside of Touchdesigner. Can trigger breakpoints and watch the execution state (inspect variables). Tested in Touchdesigner 2022.31030.

gif

πŸ›  Setup

πŸ“½ You can alternatively follow this video tutorial.

  1. 🐍 Install debugpy in Touchdesigner's python installation:

    1. In Touchdesigner's textport execute:

      print(sys.exec_prefix)
    2. πŸ“‚ Go to the path in the output and open a cmd console there. Run:

      python -m pip install debugpy
    3. ❗ If there is an error saying No module named pip, you can use this solution. Translated to Windows it would be:

      1. 🌐 Go to the link in a browser and save the file (ctrl+s).

      2. πŸ“‚ Put it in the path where the python.exe is located (output of step 1.1).

      3. ⌨️ On a command prompt located there run:

        arduinoCopy code
        python get-pip.py
      4. πŸ”„ Restart the console and try step 1.2 again.

  2. πŸ›£οΈ Touchdesigner paths have to be replicated in Windows file system for breakpoints set in the UI to trigger:

    1. πŸ“‚ Put the TD_debugger folder directly in your C drive.
    2. πŸ“‚ Put the .vscode inside TD_debugger directly in your C drive.

    You can skip step 2 but you are going to have to set the breakpoints explicitly in the code with the command debugpy.breakpoint(). If you choose to use it like this, make sure that the pathMappings section in your launch.json is like this:

    "pathMappings": [{
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "c:"
                }],
    

    Where the letter of the remoteRoot has to match the drive letter of where you have the Debugger.toe.

  3. On a terminal run

    setx DEBUGPY_PROCESS_SPAWN_TIMEOUT 90
    

    to increase the time vscode is going to wait for the debugger to connect to the server. Thanks to @AlphaMoonbaseBerlin for figuring this out!

  4. πŸ–₯️ Open Visual Studio Code in your C drive.

  5. 🎨 Open the Debugger.toe in TouchDesigner.

  6. πŸ•ΉοΈ Connect vscode by going to the Debug tab and pressing the play button. A dropdown should open, look for TouchDesigner.exe and select that process. It takes around 35 seconds for the debugger to connect the first time.

πŸ” If the bottom bar turns orange it means that it was able to connect successfully. Add a breakpoint in line 15 in vscode and trigger a Jump in the exampleExtension using the jump pulse. Vs code should stop at that line and allow you to inspect the state of the program in the left column.

πŸ€” How does this work?

I think that vscode injects a dll in the running Touchdesigner process which launches a debugpy server to which the vscode debugger connects to. By default it times out, that is why we have to increase the timeout time

πŸ“ To do

  • πŸš€Figure out how to make the breakopoints set in the vscode UI work with this. I think the problem is related to the paths because when we move the whole project directly to the C drive and the paths are equal in Touchdesigner and in Windows, it works.

Link to discussion on Derivative's forum

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published