Giter Club home page Giter Club logo

td_debugger's Introduction

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

td_debugger's People

Contributors

benjavides avatar

Stargazers

Ben Forest avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.