一半君的总结纸

听话只听一半君

Remote Python debugging in Wing

Note: Wing can interact with Maya in three different ways. This is one of the three. See an overview here on the whole system: Interaction between Wing and Maya

I currently do all my Python authoring in Wing (professional). As explained in other subjects (see note above) I have it setup so I can execute commands in Wing, and send them to Maya, which allows me to prettymuch bypass the script editor. More or less.

There are some instances where I need to leave the code in wing, but have it act on a physical Maya file in Maya. To do this, Wing lets you setup remote debugging: What does this give you? You set break-points in you code in Wing. You execute Python code in Maya. When the break-point is hit, Maya halts, and you can then start debugging in the Wing window, but physically querying the data from the open Maya session.

Since I’ve authored this, I found that Maya’s official documentation has been updated as well to show this process, here (under ‘Using Wing IDE with Maya ‘)

Here’s how to set it up:
(Find the official Wing docs for this here)


  • Copy these two files to the directory that the module you want to debug lives in. OR, you can simply put them somewhere in your Python path, and import them into your module from there (both methods work equally well it seems).

wingdebugw (no extension) from Wing’s user settings directory

XP:
C:\Documents and Settings\\Application Data\Wing IDE 3\wingdebugpw
Vista:
C:\Users\\AppData\Roaming\Wing IDE 3\wingdebugpw

wingdbstub.py from the Wing IDE installation directory

XP:
C:\Program Files\Wing IDE X.X\wingdbstub.py
Vista:
C:\Program Files (x86)\Wing IDE X.X\wingdbstub.py
  • It is important that in wingdbstub.py on around line 90, you set ‘kEmbedded = 1’. Elsewise, things just may not work so well….
  • In the module you want to debug, you need to import wingdbstub.py, since this tells Wing where to start debugging:
# myModule.py

import wingdbstub
# If you are using Wing 4.0, they recommend you then call to this:
wingdbstub.Ensure()

def main():
    # code...
  • In your Wing preferences, under ‘Debugger: External/Remote’, you need to turn on:
    • ‘Enable Passive Listen’
    • ‘Kill Externally Launched’
  • You may also need to also turn on ‘Enable Passive Listen’ in the Wing ‘Debugger’ menu, which is the “bug-looking button” at the very bottom-left of the UI (better safe than sorry)
  • In your Wing Project Properties UI, make sure that you have the Python Executable set to Maya’s version of Python. For Maya 2008, it lives here:
c:\Program Files\Autodesk\Maya2008\bin\mayapy.exe

To start the debugging, set some breakpoints in your module in Wing.
In Maya, then import and execute your code:

import myModule
myModule.main()</pre>
  • Note: Do not import wingdbstub in this code.

At which point Maya should ‘hang’ at each breakpoint Wing hits, and you can start checking the Stack Data (etc) in Wing while running the debugger.

That’s more or less it. The connection between the two apps seems a bit twitchy though, so it often times requires a restart of Maya to make the systems reconnect again.
Notes:

  • If you “Stop Debugging” in Wing, it will shut down Maya (based on the above set prefs). If debugging finishes successfully, Maya will stay open (in theory).
  • Really bad errors can break the connection to Maya, at which point you’ll need to restart Maya, to get the connection back.

http://mayamel.tiddlyspot.com

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: