Top Banner
Debugging Python in Maya Cyrille Fauvel - ADN
19

Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Dec 15, 2015

Download

Documents

Adeline Fancy
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Debugging Python in MayaCyrille Fauvel - ADN

Page 2: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

About the PresenterCyrille Fauvel - Autodesk Developer Network

Cyrille is a member of the M&E workgroup of the Autodesk Developer Network (ADN) team, providing developer support, training, and conference presentations on AutoCAD, RealDWG, Inventor, Maya, 3ds Max, FBX API, and many others.He joined Autodesk in 1994 as an AutoCAD developer based in Switzerland and California, USA. Later moved to the Developer Support group, and Consulting division.Cyrille graduated in Mechanics and Electronics in France, worked as a teacher and C++ developer for a 3rd party developer on AutoCAD. He is fluent in six programming languages, tries to learn Japanese which turns out to be more difficult than learning English, has two kids, plays the guitar and piano, likes reading, love sailing on oceans, sports, and especially hand-ball.

Page 3: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

M&E ADN Sparks program today• Access to almost all Autodesk software and SDK’s

– Includes early access to beta software• Members-only website with thousands of technical articles• Unlimited technical support• Product direction through conferences• Marketing benefits

– Exposure on autodesk.com– Promotional opportunities

• One to three free API training classes– Based on user level

www.autodesk.com/joinadn

Page 4: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

M&E ADN Sparks program todayMembers in the following categories:• Commercial plug-in developers• Corporate (customer sites)• Authors and Publishers• Hardware partners• Consultants • Universities

Page 5: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Agenda• Maya and Python• Maya integration and Python development• Debugging Python in Maya

– What benefits? What risks?• Exploring various solutions (with demos)• Q&A

Page 6: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Maya and Python• Introduced in the 8.5 release

– Scripting & API– For scripting, see PyMEL (more pythonic)

• Adoption in 2010/2011 releases– Maya engineering team continues to improve

Python support in Maya releases

Page 7: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Maya Python Scripting• Wraps MEL• Embedded UI

– Color syntax– Automatically saved– Automatically reparsed– No intellisense– No debugger

Page 8: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Maya Python API• C++ wrappers• OpenMaya & Maya

– Works like C++ plug-ins / applications

– Difficult to debug

Page 9: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

What risks?

What benefits?

Debugging Python in Maya

Page 10: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Python internal• Pythons dictionaries

– Python loads module only once– References are saved into internal Dictionaries– I.e.: imp.load_module and __builtin__.__import__

Page 11: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Risks• If not using reload(), code is not reparsed• Python variables may be initialized already

– Internal and application variables• Maya may have references set already

– Nodes or UI

Page 12: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Not using a debugger• Use print() ?

– Painful and cumbersome– Slow process– No control on execution

• Needs overriding __str__() for better Runtime Information

Page 13: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Using a debugger• Conditional Breakpoint• Inspect variables / Evaluating some expression• Code changes / Alter debug data values• Exception traceback reporting• Call stack• Remote debugging

Page 14: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Solutions available• Python pdb debugger• Winpdb http://winpdb.org/docs/embedded-debugging/

• Eclipse and pydev http://pydev.org/

• Wingware IDE http://www.wingware.com/

Page 15: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Python pdb debugger• Available in all Python distribution

import pdbpdb.run(“…”)

• Maya Script editor does not support pdb– Requires you to redirect the sys.stdin and sys.stdout in order to control pdb i/o

• Not really a solution for plug-ins

Page 16: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Winpdb• Light debugger and IDE

– But free• Breakpoints• Callstack• Inspect values• Exceptions

Page 17: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Eclipse and pydev• Stronger debugger and

IDE– Still free, but requires

more work at install time,

Page 18: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Wingware IDE • Stronger debugger and

IDE– Commercial release

Page 19: Debugging Python in Maya Cyrille Fauvel - ADN. About the Presenter Cyrille Fauvel - Autodesk Developer Network Cyrille is a member of the M&E workgroup.

Thank You !

Q & A

ADN SparksAutodesk