<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Maya Python for Games and Film</title>
	<atom:link href="http://www.maya-python.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maya-python.com</link>
	<description>A Complete Guide to Maya Python and the Maya Python API</description>
	<lastBuildDate>Sun, 25 Mar 2012 02:48:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Post-GDC Wrap-Up</title>
		<link>http://www.maya-python.com/2012/03/post-gdc-wrap-up/</link>
		<comments>http://www.maya-python.com/2012/03/post-gdc-wrap-up/#comments</comments>
		<pubDate>Tue, 20 Mar 2012 04:41:35 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Maya]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.maya-python.com/?p=417</guid>
		<description><![CDATA[GDC has passed and I&#8217;ve started to recover from the workload that was awaiting me upon my return, so I thought I&#8217;d toss up a few points that came up. A lot of stuff I talked about was related to topics that can be found in the book, but I thought I&#8217;d share a few [...]]]></description>
			<content:encoded><![CDATA[<p>GDC has passed and I&#8217;ve started to recover from the workload that was awaiting me upon my return, so I thought I&#8217;d toss up a few points that came up. A lot of stuff I talked about was related to topics that can be found in the book, but I thought I&#8217;d share a few notes on other stuff. Please feel free to ask questions or to disagree in the comments for this post!<br />
<span id="more-417"></span></p>
<ul>
<li>I suggested that idiomatic Python is not simply a matter of using OOP (hence, using pymel, although awesome, is not <em>sufficient</em> to make your code &#8220;Pythonic&#8221;). I stressed that the Python community is made up of a variety of programming cultures that each have their own particular design patterns and paradigms (be it procedural, functional, object-oriented, or some half-baked convention of web programmers), and that the few existing unifying factors are centered more around readability and testability of code.</li>
<li>I talked a bit about code organization and Python&#8217;s data model in contrast to MEL (stressing again that MEL and the cmds module are equal citizens with respect to the Command Engine). I used function pointer arguments for Maya commands as one example where the differences between Python and MEL become clearer when organizing code. Namely, I would argue that there is almost never a good reason to pass a command string rather than a function pointer to e.g., GUI commands, scriptJob, etc. Passing command strings a) is more prone to error since you won&#8217;t get code completion in a string literal, b) will execute statements in __main__ rather than in the calling context, and c) therefore throws exceptions when the callback is issued and without a stack trace, rather than when the command is executed and with a stack trace.</li>
<li>I also related points about Python&#8217;s data model to the rationale for MScriptUtil, and pointed out simple ways to subclass parts of the API that make use of it in order to create more &#8220;Pythonic&#8221; APIs, as in the following snippet.</li>
<pre><code><strong>import</strong> collections
<strong>import</strong> maya.OpenMaya <strong>as</strong> om
UV = collections.namedtuple('UV', ('u','v'))
<strong>class</strong> MFnNurbsSurfaceX(om.MFnNurbsSurface):
    <strong>def</strong> __init__(<strong>self</strong>, *args):
        om.MFnNurbsSurface.__init__(<strong>self</strong>, *args)
    <strong>def</strong> closestPoint(self, *args):
        uutil = om.MScriptUtil()
        uutil.createFromDouble(0)
        uptr = uutil.asDoublePtr()
        vutil = om.MScriptUtil()
        vutil.createFromDouble(0)
        vptr = vutil.asDoublePtr()
        pt = om.MFnNurbsSurface.closestPoint(self, args[0], uptr, vptr)
        <strong>return</strong> pt, UV(uutil.getDouble(uptr), vutil.getDouble(vptr))</code></pre>
<li>One final novel point I mentioned was a technique for plug-in deployment within a package in order to streamline tool distribution and access plug-in classes from corresponding GUI tools (and enable users to simply import a single plug-in module rather than calling the loadPlugin command for several files if so desired). A brief example follows.</li>
</ul>
<pre><code><strong>import</strong> os
<strong>import</strong> maya.cmds <strong>as</strong> cmds
<strong>import</strong> maya.OpenMaya <strong>as</strong> om
<em>## the Maya plug-in path environment variable</em>
kPluginPathEnvVar = 'MAYA_PLUG_IN_PATH'
<strong>def</strong> appendToPluginPath():
    <em>"""
    Modify the Maya plug-in path for this session to include this module.
    """</em>
    path = os.environ[kPluginPathEnvVar]
    folder = os.path.dirname(__file__)
    <strong>if</strong> <strong>not</strong> folder <strong>in</strong> path:
        path = os.pathsep.join([path, folder])
    os.environ[kPluginPathEnvVar] = path
<strong>def</strong> getPluginFileName():
    <em>"""
    Get the plug-in file name for use with the loadPlugin command.
    """</em>
    <strong>return</strong> '%s.py'%os.path.splitext(os.path.basename(__file__))[0]
<em># import classes from modules</em>
<strong>import</strong> classes.pluginOne
<strong>import</strong> classes.pluginTwo
<em># etc.</em>
<strong>def</strong> initializePlugin(mobject):
  <em># create fn, register plugins</em>
  <strong>return</strong>
<strong>def</strong> uninitializePlugin(mobject):
  <em># create fn, deregister plugins</em>
  <strong>return</strong>
<em># following lines enable ability to "import" plug-ins via this module</em>
<strong>try</strong>:
    appendToPluginPath()
    cmds.loadPlugin(getPluginFileName())
<em># __file__ doesn't exist in context where loadPlugin evaluates</em>
<strong>except</strong> NameError: <strong>pass</strong>
</code></pre>
<p>Last but not least, Ryan recently completed a MasterClass for Autodesk on vector math for artists, where he provides some examples using Python. You can <a href="http://www.the-area.com/masterclasses/masterclass/class3_q1_2012" target="_blank">check it out on Autodesk&#8217;s Area web site</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maya-python.com/2012/03/post-gdc-wrap-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kindle Readers</title>
		<link>http://www.maya-python.com/2012/03/kindle-readers/</link>
		<comments>http://www.maya-python.com/2012/03/kindle-readers/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 18:56:29 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.maya-python.com/?p=424</guid>
		<description><![CDATA[We&#8217;ve received notification that the indentation problems on the Kindle version should now be fixed, which seems to be reflected in the Kindle preview on Amazon. Please feel free to share your experiences reading the Kindle version with us.]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve received notification that the indentation problems on the Kindle version should now be fixed, which seems to be reflected in the Kindle preview on Amazon. Please feel free to share your experiences reading the Kindle version with us.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maya-python.com/2012/03/kindle-readers/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Kindle Readers Beware</title>
		<link>http://www.maya-python.com/2012/02/kindle-readers-beware/</link>
		<comments>http://www.maya-python.com/2012/02/kindle-readers-beware/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 05:36:07 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.maya-python.com/?p=410</guid>
		<description><![CDATA[It has been brought to our attention that the Kindle version of the book currently has some serious formatting problems. Namely, some customers have told us that leading white space is stripped out, which of course renders the code samples uninterpretable. Although we (as authors) have little ability to do anything about it ourselves, we [...]]]></description>
			<content:encoded><![CDATA[<p>It has been brought to our attention that the Kindle version of the book currently has some serious formatting problems. Namely, some customers have told us that leading white space is stripped out, which of course renders the code samples uninterpretable.</p>
<p>Although we (as authors) have little ability to do anything about it ourselves, we have passed this info up the food chain in hopes that it can be resolved. In the meantime, if you have the option, we&#8217;d recommend avoiding the Kindle version of the book until or unless it can be resolved. Thanks to those of you who let us know! We&#8217;ll be sure to post an update if we find out anything different.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maya-python.com/2012/02/kindle-readers-beware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sloppy Exception Handling</title>
		<link>http://www.maya-python.com/2012/01/sloppy-exception-handling/</link>
		<comments>http://www.maya-python.com/2012/01/sloppy-exception-handling/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 07:44:16 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Chapters]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.maya-python.com/?p=388</guid>
		<description><![CDATA[I&#8217;ve been going over a bunch of old code lately and picking out some awful habits of mine. Today I want to talk about one that unfortunately is also prevalent throughout the 1st edition of book: sloppy exception handling. Let&#8217;s first look at a short (somewhat contrived) example to demonstrate a couple problems. import maya.cmds [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been going over a bunch of old code lately and picking out some awful habits of mine. Today I want to talk about one that unfortunately is also prevalent throughout the 1st edition of book: sloppy exception handling.<br />
<span id="more-388"></span><br />
Let&#8217;s first look at a short (somewhat contrived) example to demonstrate a couple problems.</p>
<pre><code><strong>import</strong> maya.cmds <strong>as</strong> cmds
<strong>def</strong> make_nodes(node_type_name, amount):
    """
    <em>Make the specified amount of the specified node.
    @param node_type_name: The name of the node type to create.
    @param amount: The number of nodes to make.</em>
    """
    current_selection = cmds.ls(sl=True)
    <strong>try</strong>:
        <strong>for</strong> i <strong>in</strong> range(amount):
            cmds.createNode(node_type_name)
    <strong>except</strong>:
        <strong>raise</strong>
    <strong>try</strong>:
        cmds.select(current_selection)
    <strong>except</strong>:
        <strong>pass</strong></code></pre>
<p>The first problem here concerns the first try-except clause. Namely: why does it exist? If anything in the try block fails (either the loop or the createNode call), it will raise an exception. Wrapping this code in a try clause is useless in this case, because we don&#8217;t actually change any behavior if an exception happens to be raised. The exception is just tossed out to the calling context.</p>
<p>The second problem is that both of these try-except clauses use what I have grown to call <a href="http://www.dodgycoder.net/2011/11/yoda-conditions-pokemon-exception.html">Pokémon Exception Handling</a>: they gotta catch &#8216;em all! Unlike the first try-except clause, the second one at least has a point here. (For example, if the selection list is empty when this function is called, resetting the selection would ordinarily raise a <a href="http://docs.python.org/library/exceptions.html#exceptions.TypeError" title="Python TypeError">TypeError</a>.) However, the <a href="http://www.python.org/dev/peps/pep-0008/" title="PEP style guide">PEP style guide</a> recommends against this type of bare except clause (and suggests minimally specifying <a href="http://docs.python.org/library/exceptions.html#exceptions.Exception" title="Python Exception">Exception</a>). Why?</p>
<p>Imagine this function did something more substantial to edit the scene. Suppose it possibly deletes some nodes as well as creates them. If you simply throw in a bare except clause, you may catch errors you do not actually want to, which can lead to sloppy programming. For example, while selecting an empty list throws a TypeError, trying to select an object that does not exist throws a <a href="http://docs.python.org/library/exceptions.html#exceptions.ValueError" title="Python ValueError">ValueError</a>. In this case, we want to silently trap and ignore the TypeError, but NOT the ValueError, as we anticipate the former, but not the latter. If we built a set of tests for this function, we might totally miss scenarios in which a ValueError is raised. In short, do not put in an except clause unless you anticipate a specific exception of some kind and plan to actually do something about it.</p>
<p>Finally, you should strive to try the minimum amount of code possible at any one time. It is possible some errors can be raised in multiple ways. Since the PEP discusses this point, I won&#8217;t go into detail, but you can imagine there may be some cases where you want to catch one TypeError, but not another, in which case they should not be wrapped in the same try clause.</p>
<p>I want to end this post by talking about the API command examples in the book. The book notes that when parsing the command&#8217;s arguments by constructing an <a href="[maya_docs_api]class_m_arg_database.html" title="MArgDatabase">MArgDatabase</a>, simply raising the exception throws out a really non-descriptive <a href="http://docs.python.org/library/exceptions.html#exceptions.RuntimeError" title="Python RuntimeError">RuntimeError</a>. The book errantly advises that this just be passed over instead of raised, because the command engine would display information about the problem (at least when the command is invoked from MEL). But what about when the command is invoked from Python? Obviously we want it to throw some kind of exception, and probably not just a really low-level RuntimeError. The trouble here of course is that, because you cannot initialize an MArgDatabase or an <a href="[maya_docs_api]class_m_arg_parser.html" title="MArgParser">MArgParser</a>, you can&#8217;t really tell what exactly is wrong. In this case, the safest thing to do, in my view, is to raise a TypeError, which can occur with either an invalid flag, or with a flag argument of the wrong type. While you can&#8217;t tell the user exactly what is wrong, it is still better than raising the bult-in RuntimeError, and of course infinitely preferable to raising no exception at all!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maya-python.com/2012/01/sloppy-exception-handling/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>GDC!</title>
		<link>http://www.maya-python.com/2012/01/gdc/</link>
		<comments>http://www.maya-python.com/2012/01/gdc/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 03:19:14 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Maya]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.maya-python.com/?p=383</guid>
		<description><![CDATA[Thanks to everyone who has picked up the book and has given us feedback so far! I wanted to post up a quick note that three of us will be doing Maya/Python-related poster sessions at GDC 2012. Seth Gibson: You Got Art In My Test Suite! Adam Mechtley: The Odd Couple: Maya and Python Kristine [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to everyone who has picked up the book and has given us feedback so far! I wanted to post up a quick note that three of us will be doing Maya/Python-related poster sessions at GDC 2012.</p>
<ul>
<li>Seth Gibson: <a href="http://schedule.gdconf.com/session/6483/You_Got_Art_In_My_Test_Suite%21" target="_blank">You Got Art In My Test Suite!</a></li>
<li>Adam Mechtley: <a href="http://schedule.gdconf.com/session/6479/The_Odd_Couple%3A_Maya_and_Python" target="_blank">The Odd Couple: Maya and Python</a></li>
<li>Kristine Middlemiss: <a href="http://schedule.gdconf.com/session/6481/Top_10_Autodesk_Maya_Python_API_Gotchas_When_Getting_Started" target="_blank">Top 10 Autodesk Maya Python API Gotchas When Getting Started</a></li>
</ul>
<p>Hope to see you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maya-python.com/2012/01/gdc/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Building and Installing PyQt</title>
		<link>http://www.maya-python.com/2011/09/building-and-installing-pyqt/</link>
		<comments>http://www.maya-python.com/2011/09/building-and-installing-pyqt/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 21:39:27 +0000</pubDate>
		<dc:creator>kristine</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Chapters]]></category>
		<category><![CDATA[Maya]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.maya-python.com/?p=219</guid>
		<description><![CDATA[Obtaining and installing everything needed for PyQt can be quite a task! Moreover, Maya 2012 requires some different steps to make sure you have all of the proper files needed to get going with PyQt. The information provided here should help you locate everything you need to download to be ready to build and install [...]]]></description>
			<content:encoded><![CDATA[<p>Obtaining and installing everything needed for PyQt can be quite a task! Moreover, Maya 2012 requires some different steps to make sure you have all of the proper files needed to get going with PyQt. The information provided here should help you locate everything you need to download to be ready to build and install PyQt on your particular operating system, whether it is Windows, OS X, or Linux.<br />
<span id="more-219"></span></p>
<h1>Overview and Download Links</h1>
<p>If you have previously built the PyQt libraries for Maya 2011 and older, Autodesk has made some changes in the delivery of Qt in Maya 2012 and newer. There is now an Autodesk-customized version of the open source Qt framework, which is required for C++ or PyQt GUIs. Consequently, you do not need the complete Qt SDK for Maya 2012 and newer (because they use the Autodesk-modified version), but you can download the source packages of the Qt framework if you need access Qt Designer or anything else that comes with the framework.</p>
<p><em>Note that 32-bit and 64-bit versions of Qt cannot coexist in the same directory tree. If you want both versions installed on the same system then you will have to configure, build, and install Qt twice, using different installation directories each time.</em></p>
<p>The items you are going to need to download to prepare for building and installing PyQt are:</p>
<ol>
<li>An appropriate version of the <a href="http://qt.nokia.com/downloads">Qt SDK</a> for Maya 2011 and older, or <a href="http://www.autodesk.com/lgplsource">Autodesk&#8217;s modified Qt source</a> for Maya 2012 (<em>under the heading <strong>QT4.7.1 modified for Maya</strong></em>)</li>
<li><a href="http://www.riverbankcomputing.com/software/sip/download">SIP</a>, a C++ wrapper tool</li>
<li><a href="http://www.riverbankcomputing.com/static/Downloads/PyQt4/">PyQt</a>* (<em>for Windows, use Python version 2.6, which is the version used in Maya 2012</em>)</li>
<li>Microsoft Visual Studio 2008, SP 1 (<em>Windows only</em>)**</li>
</ol>
<p><em>*PyQt does not have the same licensing as Autodesk Maya, Qt, or Python. Please consult the <a title="PyQt license information" href="http://www.riverbankcomputing.co.uk/software/pyqt/license" target="_blank">PyQt website</a> for information about licensing.</em><br />
<em>**These instructions should also work with Microsoft Visual Studio Express.</em></p>
<p>You do not need a specific version of SIP and PyQt—any recent version is good. PyQt keeps up with Qt, so anything after the compatible Qt version that is documented in the Maya API documentation is suitable. Once you have built and installed the first three components, you end up with PyQt binaries, which you put in your site-packages directory. Thereafter, you will be ready to start building custom PyQt GUIs!</p>
<h1>Building and Installing PyQt</h1>
<p><em>I am prefacing these build instructions by noting that I found I had to tinker with the settings and file locations to make it build. I have added in where I had to make adjustments, but everyone’s computer and environment is different, so what worked for me may not work for you. In spite of these few modifications, I successfully built and installed PyQt with Maya 2012, allowing me to create my PyQt custom GUIs for Maya 2012.</em></p>
<p>Jump to:</p>
<ul>
<li><a href="#Windows">Windows</a></li>
<li><a href="#OSX">OS X</a></li>
<li><a href="#Linux">Linux</a></li>
</ul>
<p><a name="Windows"></a></p>
<h2>Windows</h2>
<h3>Building Qt</h3>
<ol>
<li>Unzip the Qt package you downloaded from the Autodesk website, <code>Qt-4.7.1-Modified_for_Maya.zip</code> to a folder (e.g., <code>C:\qt-adsk-4.7.1</code>).</li>
<li>Follow the instructions inside the zip file (howToBuildQtOnWindows_m2012.txt) to configure and build the modified Maya Qt SDK.</li>
</ol>
<h3>Building SIP</h3>
<ol>
<li>Unzip the SIP package you downloaded from the Riverbank Computing website, <code>sip-4.12.4.zip</code>, to a folder (e.g., <code>C:\sip-4.12.4</code>).</li>
<li>Start a Microsoft Visual Studio 2008 Command Prompt (<strong>Start -&gt; All Programs -&gt; Microsoft Visual Studio -&gt; Visual Studio Tools -&gt; Visual Studio 2008 Command Prompt</strong>).</li>
<li>Change to the directory into which you extracted SIP. <br/><code>cd c:\sip-4.12.4</code></li>
<li>Execute the following commands in the Command Prompt. The first line is required so the build can find python26.lib.<br />
<code>set LIB=%LIB%;C:\Program Files\Autodesk\Maya2012\lib</code><br />
<code>"C:\Program Files\Autodesk\Maya2012\bin\mayapy" configure.py</code><br />
<code>nmake</code><br />
<code>nmake install</code></li>
</ol>
<p>SIP will now be installed in Maya&#8217;s site‐packages directory located at <code>C:\Program Files\Autodesk\Maya2012\Python\lib\site-packages</code>.</p>
<h3>Building PyQt</h3>
<ol>
<li>Unzip the PyQt package you downloaded from the Riverbank Computing website, <code>PyQt-win-gpl-4.8.5.zip</code>, to a folder (e.g., <code>C:\PyQt-win-gpl-4.8.5</code>).</li>
<li>Start a Microsoft Visual Studio 2008 Command Prompt.</li>
<li>Change to the directory into which you extracted PyQt.<br />
<code>cd c:\PyQt-win-gpl-4.8.5</code></li>
<li>Execute the following commands in the Command Prompt. The PyQt configure.py script searches the PATH for a Qt installation. If you have other Qt installations, make sure they aren&#8217;t in the PATH.<br />
<code>set QTDIR= c:\qt-adsk-4.7.1</code><br />
<code>set PATH=c:\qt-adsk-4.7.1\bin;%PATH%</code><br />
<code>set QMAKESPEC=C:\qt-adsk-4.7.1\mkspecs\win32‐msvc2008</code><br />
<code>"C:\Program Files\Autodesk\Maya2012\bin\mayapy" configure.py ‐w LIBDIR_QT=C:\qt-adsk-4.7.1\lib INCDIR_QT=C:\qt-adsk-4.7.1\include</code></p>
<li>You might get errors here so it is helpful to pipe it out to a file so you can see all the output.<br />
<code>"C:\Program Files\Autodesk\Maya2012\bin\mayapy" configure.py -w LIBDIR_QT=C:\qt-adsk-4.7.1\lib INCDIR_QT=C:\qt-adsk-4.7.1\include &gt; config.txt</code><br />
<code>set INCLUDE=%INCLUDE%;C:\Program Files\Autodesk\Maya2012\include\python2.6;C:\qt-adsk-4.7.1\include</code><br />
<code>nmake</code><br />
<code>nmake install</code></li>
</ol>
<p>If these commands result in errors referring to <code>D:\qt</code>, first search and replace all occurrences of <code>D:\qt-adsk-4.7.1</code> to <code>C:\qt-adsk-4.7.1</code> in all makefiles in the PyQt folder.</p>
<p>PyQt4 will now be installed in Maya&#8217;s site‐packages directory located at <code>C:\Program Files\Autodesk\Maya2012\Python\lib\site-packages</code>.<br />
<a name="OSX"></a></p>
<h2>OS X</h2>
<h3>Building Qt</h3>
<ol>
<li>Unzip the package you downloaded from the Autodesk website, <code>Qt-4.7.1-Modified_for_Maya.zip</code>.</li>
<li>Follow the instructions inside the zip file (howToBuildQtOnMac_m2012.txt), to configure and build the modified Maya Qt SDK.</li>
</ol>
<h3>Building SIP</h3>
<ol>
<li>Open the Terminal application (<strong>Applications -&gt; Utilities -&gt; Terminal</strong>).</li>
<li>Change to the directory into which you saved the SIP download, such as e.g.,<br />
<code>cd ~/Downloads</code></li>
<li>Execute the following lines to build SIP.<br />
<code>tar ‐zxvf sip‐4.12.4.tar.gz</code><br />
<code>cd sip‐4.12.4</code><br />
<code>/Applications/Autodesk/maya2012/Maya.app/Contents/bin/mayapy configure.py ‐‐arch=x86_64</code><br />
<code>make</code><br />
<code>sudo make install</code></li>
</ol>
<p>SIP will now be installed in Maya&#8217;s site‐packages directory located at <code>/Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages</code>.</p>
<h3>Building PyQt</h3>
<ol>
<li>Open the Terminal application.</li>
<li>Change to the directory into which you saved the PyQt download, such as e.g.<br />
<code>cd ~/Downloads</code></li>
<li>Execute the following lines to build PyQt.<br />
<code>tar ‐zxvf PyQt‐mac‐gpl‐4.8.5.tar.gz</code><br />
<code>cd PyQt‐mac‐gpl‐4.8.5</code><br />
<code>export QTDIR=/usr/local/Trolltech/Qt‐4.8.5</code><br />
<code>export PATH=/usr/local/Trolltech/Qt‐4.8.5/bin:$PATH</code><br />
<code>export QMAKESPEC=/usr/local/Trolltech/Qt‐4.8.5/mkspecs/macx‐g++</code><br />
<code>export DYLD_LIBRARY_PATH=/usr/local/Trolltech/Qt‐4.8.5/lib</code><br />
<code>/Applications/Autodesk/maya2012/Maya.app/Contents/bin/mayapy configure.py</code><br />
<code>LIBDIR_QT=/usr/local/Trolltech/Qt‐4.8.5/lib INCDIR_QT=/usr/local/Trolltech/Qt‐4.8.5/include</code><br />
<code>MOC=/usr/local/Trolltech/Qt‐4.8.5/bin/moc ‐w ‐‐no‐designer‐plugin</code><br />
<code>make ‐j8</code><br />
<code>sudo make install</code></li>
<li>PyQt will now be installed in Maya&#8217;s site‐packages directory located at <code>/Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages/PyQt4</code>. At this point PyQt is installed, but the binaries are improperly linked for Maya, which must be corrected. Maya only includes the Qt binaries that it actually uses, so there are several installed PyQt modules which will not work because they won&#8217;t find the missing libraries. This problem can in theory be solved by copying in the missing libraries from the Qt build earlier. Execute the following lines in Terminal to do so.<br />
<code>sudo find /Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages/PyQt4 ‐name "*so" ‐exec install_name_tool ‐change libQtCore.4.dylib @executable_path/QtCore {} \;</code><br />
<code>sudo find /Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages/PyQt4 ‐name "*so" ‐exec install_name_tool ‐change libQtGui.4.dylib @executable_path/QtGui {} \;</code><br />
<code>sudo find /Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages/PyQt4 ‐name "*so" ‐exec install_name_tool ‐change libQtSvg.4.dylib @executable_path/QtSvg {} \;</code><br />
<code>sudo find /Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages/PyQt4 ‐name "*so" ‐exec install_name_tool ‐change libQtOpenGL.4.dylib @executable_path/QtOpenGL {} \;</code><br />
<code>sudo find /Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages/PyQt4 ‐name "*so" ‐exec install_name_tool ‐change libQtXml.4.dylib @executable_path/QtXml {} \;</code></li>
</ol>
<p><a name="Linux"></a></p>
<h2>Linux</h2>
<h3>Building Qt</h3>
<ol>
<li>Unzip the package you downloaded from the Autodesk website, <code>Qt-4.7.1-Modified_for_Maya.zip</code>.</li>
<li>Follow the instructions inside the zip file (howToBuildQtOnLinux_m2012.txt) in order to configure and build the modified Maya Qt SDK. In the instructions file, you can skip downloading the Qt SDK from the Nokia website, as we downloaded a custom version from the Autodesk website. There is also one incorrect item in this file. It says the default gcc version is 4.10 for Maya 2012, which is not the case. The default gcc version is 4.1.2 for Maya 2012.</li>
</ol>
<h3>Building SIP</h3>
<ol>
<li>Open the Terminal application.</li>
<li>Unzip the package you downloaded from the Riverbank Software website, <code>sip-4.12.4.tar.gz</code>.</li>
<li>Execute the following commands in a command prompt:<br />
<code>cd sip‐4.12.4</code><br />
<code>/usr/autodesk/maya2012‐x64/bin/mayapy configure.py</code><br />
<code>make</code><br />
<code>sudo make install</code></li>
</ol>
<p>SIP will now be installed in Maya&#8217;s site‐packages directory located at <code>/usr/autodesk/maya2012‐x64/lib/python2.6/site‐packages/</code>.</p>
<h3>Building PyQt</h3>
<ol>
<li>Unzip the package you downloaded from the Riverbank Software website, <code>PyQt-x11-gpl-4.8.5.tar.gz</code>.</li>
<li>Execute the following commands in a command prompt:<br />
<code>cd PyQt‐x11‐gpl‐4.8.5</code><br />
<code>/usr/autodesk/maya2012‐x64/bin/mayapy configure.py ‐q /usr/local/Trolltech/Qt4.8.5/bin/qmake</code><br />
<code>make ‐j4</code><br />
<code>sudo make install</code></li>
</ol>
<p>PyQt will now be installed in Maya&#8217;s site‐packages directory located at <code>/usr/autodesk/maya2012‐x64/lib/python2.6/sitepackages/PyQt4</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maya-python.com/2011/09/building-and-installing-pyqt/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Writing a Book is Hard!</title>
		<link>http://www.maya-python.com/2011/08/writing-a-book-is-hard/</link>
		<comments>http://www.maya-python.com/2011/08/writing-a-book-is-hard/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 23:50:24 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Chapters]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.maya-python.com/?p=109</guid>
		<description><![CDATA[Welcome to the website for our book, Maya Python for Games and Film! We&#8217;re really happy to have the project finished, and we&#8217;re glad that you&#8217;ve either picked up the book or stopped by to check out the web site. We really just want the book and site to be helpful tools for people who [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to the website for our book, <i>Maya Python for Games and Film</i>! We&#8217;re really happy to have the project finished, and we&#8217;re glad that you&#8217;ve either picked up the book or stopped by to check out the web site. We really just want the book and site to be helpful tools for people who are learning all about Python in Maya, so we hope you find it useful! We make no claims that we are the most expert developers where these topics are concerned: we were only ambitious enough to try to write a book to help newcomers to the community.</p>
<p>That being said, writing a book is hard, and writing a book about Python is a lot more difficult than we had anticipated! As such, we want to thank our contributing authors, Seth Gibson and Kristine Middlemiss, as well as our technical editor, Dean Edmonds, without whom this project would not have been possible.</p>
<p>We also want to be the first to admit that our book is not perfect. We have striven to be incredibly attentive to detail, but we&#8217;re sure there are problems or inconsistencies in our text or code examples. (You can find errata for each chapter noted on the chapter pages.) We&#8217;re also sure that, with as talented and populous as the Python community is, there will be plenty of people who disagree with some of our decisions or coding style. (Please make the time to read the <a href="maya-python.com" title="Introduction to Maya Python">Introduction</a> chapter, as our printed code samples ended up a little unconventional to fit with the restrictions of the medium.)</p>
<p>Have fun and good luck on your journey to master Python in Maya!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maya-python.com/2011/08/writing-a-book-is-hard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

