Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Debugging Python in Maya Cyrille Fauvel - ADN About the Presenter Cyrille 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. 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 M&E ADN Sparks program today Members in the following categories: • • • • • • Commercial plug-in developers Corporate (customer sites) Authors and Publishers Hardware partners Consultants Universities Agenda • Maya and Python • Maya integration and Python development • Debugging Python in Maya – What benefits? What risks? • Exploring various solutions (with demos) • Q&A 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 Maya Python Scripting • Wraps MEL • Embedded UI – Color syntax – Automatically saved – Automatically reparsed – No intellisense – No debugger Maya Python API • C++ wrappers • OpenMaya & Maya – Works like C++ plug-ins / applications – Difficult to debug Debugging Python in Maya What benefits? What risks? Python internal • Pythons dictionaries – Python loads module only once – References are saved into internal Dictionaries – I.e.: imp.load_module and __builtin__.__import__ 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 Not using a debugger • Use print() ? – Painful and cumbersome – Slow process – No control on execution • Needs overriding __str__() for better Runtime Information Using a debugger • • • • • • Conditional Breakpoint Inspect variables / Evaluating some expression Code changes / Alter debug data values Exception traceback reporting Call stack Remote debugging Solutions available • • • • Python pdb debugger Winpdb http://winpdb.org/docs/embedded-debugging/ Eclipse and pydev http://pydev.org/ Wingware IDE http://www.wingware.com/ Python pdb debugger • Available in all Python distribution import pdb pdb.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 Winpdb • Light debugger and IDE – But free • • • • Breakpoints Callstack Inspect values Exceptions Eclipse and pydev • Stronger debugger and IDE – Still free, but requires more work at install time, Wingware IDE • Stronger debugger and IDE – Commercial release Q&A Thank You ! ADN Sparks Autodesk