一半君的总结纸

听话只听一半君

Making Eclipse Soar

http://christianakesson.com

Here is a guide to set up and get Eclipse, PyMel, PyQt4 & Python to work together. When complete, you will have a sweet IDE setup, switch between running everything 32bit and 64bit native AND the ability to compile your own 64 and 32 bit native applications. I am writing this assuming Windows 7 64 bit. I would recommend sorting all the downloads into a 32 and a 64 folder to easier keep track of everything.

1. Getting the installers:

Python:
Python x64 – http://www.python.org/download/#id5 – Python 2.6.5 Windows X86-64 installer
Python x32 – http://www.python.org/download/#id5 – Python 2.6.5 Windows installer

Java Virtual Machine (Runtime Environment) x64 (we only need the 64 bit version of this):
Sun Download Portal – Select Windows x64, agree to the licence agreement → Continue → jre-6u20-windows-x64.exe

Eclipse – We only need the 64 bit version for this one:
http://download.eclipse.org/eclipse/downloads/ – Latest Release → eclipse-SDK-3.5.2-win32-x86_64.zip

PyQt4 – We want PyQt4 for Maya 64 bit, PyQt for external Python 64 bit, PyQt for external Python 32 bit:
Props to Nathan Horne for compiling these and sharing with the community:
PyQt4 x64 – http://nathanhorne.com/?p=204&cpage=1#comment-1978 – Download the 3 files on this post.
PyQt4 x32 – http://www.riverbankcomputing.co.uk/software/pyqt/download – PyQt-Py2.6-gpl-4.7.3-2.exe

In case you need to compile your own 64 bit version in the future here are resources for standalone and Maya compiles:
Standalone – http://eoyilmaz.blogspot.com/2009/09/how-to-compile-pyqt4-for-windows-x64.html
Maya – http://images.autodesk.com/adsk/files/pyqtmaya2011.pdf

2. Getting Up & Running:

Install Python:
– If you want to run both 32 and 64 bit and compile both 32 and 64 bit programs, install the 64 to C:/Program Files/Python26/ and the 32 to C:/Program Files (x86)/Python26/

Install PyQt4:
– Install the PyQt-Py2.6-gpl-4.7.3-1 to where you installed Python26 64 bit to.
– Replace the sip.pyd with the downloaded one.
– Install the PyQt-Py2.6-gpl-4.7.3-1_QT_MAYA (the installer my prompt you to uninstall PyQt. Ignore this and just point the installer to Maya install loc/python/)

Install Java64:

Unzip Eclipse64:
– unzip it to C:/Program Files/ – you can put it wherever, but this location makes sense to me…

Launch Eclipse:
– Do NOT pick your main tool folder as the default workbench, pick some other spot (I picked C:/ or myDocuments).

3. Adding Goodies To Eclipse:

PyDev:
1. Go to Help → Install Software
2. Name it something (PyDev) and paste this path in the location field → http://pydev.org/updates
3. In the Available Software Window, you now have a new entry under the Work With drop down list. Select PyDev Address.
4. Jump through the steps and install PyDev, then restart Eclipse

Perforce:
1. Go to Help → Install Software
2. Name it something (P4) and paste this path in the location field → http://www.perforce.com/downloads/http/p4-wsad/install/3.5
3. In the Available software window you now have a new entry under the Work with: drop down list, select P4 – address
4. Jump through the steps and install Perforce and restart Eclipse

XML Formatter:
1. Download XMLBuddy to your computer – http://download.cnet.com/XMLBuddy/3000-7241_4-10405546.html
2. From the xmlbuddy_2.0.72.zip, extract com.objfac.xmleditor_2.0.72 into C:/Program Files/eclipse/plugins

Maya Connection:
1. Download MayaEditor – http://www.creativecrash.com/downloads/eclipse-maya-editor/download
2. Put the com.myplugin.eclipseMayaEditor_1.0.0.jar into C:/Program Files/eclipse/plugins
3. After reboot, read the creative cash link above. Most important to this one is to add the port connect to userSetup.mel so that Maya can connect to Eclipse.
4. In Eclipse Window → Preferences → Maya Editor Preferences. You see some doc links that you can launch within Eclipse, which is handy. I set mine to this:
– Maya Python API Doc Path →  http://download.autodesk.com/us/maya/2011help/API/classes.html
– Maya Python Commands Doc Path →  http://download.autodesk.com/us/maya/2011help/CommandsPython/index.html
– Pymel Doc Path →  http://www.luma-pictures.com/tools/pymel/docs/1.0/index.html
– I changed the WPF Doc Path to contain the PYQT Class Reference →  http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/classes.html

Mel Syntax Highlighting:
1. Download dk.maya3d.melEditor_0.5.0.jar into C:/Program Files/eclipse/plugins

Adding The Maya Interpreter:
1. In Eclipse, Go to: Window→Preferences→ Pydev→Interpreter – Python
2. Top section will list all your available interpreters, Click New…
3. For Maya 2011 add C:/Program Files/Autodesk/Maya2011/bin/mayapy.exe
4. Check all the checkboxes
5. Remove the ../site-packages path
6. Add (Path To Your Pymel/pymel-1.0.2)/extras/completion/py/
7. Add the ../site-packages path back

Add the Python Interpreter (with PyQt4 Autocompletion):
1. In Eclipse, Go to: Window→Preferences→ Pydev→Interpreter – Python
2. Top section will list all your available interpreters, Click New…
3. Pick the C:/Programs/Python26/python.exe, name the interpreter Python26-64
4. In forced buildins add “PyQt4″ and “sip”
5. Rinse and repeat for 32 bit Python and name that interpreter Python26-32

Adding the Py dev project(s):
1. In Eclipse, make sure that you have the pyDev Perspective active: Window→ Open Perspective→ Other…→ Pydev
2. In Eclipse, make sure that the PyDev Package Explorer is open: Window→ Show View→ Pydev Package Explorer
3. In the Pydev Package Explorer, Right click and select New→ project→ Pydev(folder)→ Pydev Project (Click Next)
4. Give the project any name in the Project name: field
5. Uncheck Use Default and Create defualt ‘scr’ folder. You can choose an interpreter here, but you can change this at will for the project at any time by going to project properties. If you do know which one you prefer, go ahead and set it (mayaPy2011 interpreter, for a Maya tool project for instance)
6. When you unchecked Use Default, the Directory Path unlocked. Click Browse and select the top directory of your tool folder.
7. Click Finish
8. Right click on your project →Properties→Pydev – PYTHONPATH. Add source folders here to your code base for this project. You can also add source folders between projects, by using External Libraries.
9. Rinse and repeat to add as many projects as you want.
10. To set and change the interpreter on a project by project basis (Maya Interpreter for any tool depots that relates to Maya & Python Interpreter for external compiled tools for instance). Right click on your project – Properties→ Pydev – Interpreter/Grammar. Pick one of your defined interpreters in the Interpreter drop down.

Great PyQt Reference as a PyDev Project (the PyQt Examples Library):
1. Right click and select New→ project→ Pydev(folder)→ Pydev Project
2. Uncheck Use Default and Create Default scr folder
3. Browse to C:Program FilesPython26Libsite-packagesPyQt4
4. Select the Python26-64 interpreter (if you added the C:Program Files(x86)Python26Libsite-packagesPyQt4, select the Python26-32 interpreter)
5. Click Finish
6. Right click on Project Name You Gave It→ Properties→ Pydev-PYTHONPATH – add Examples under source folders.
7. Click OK, you now can view and run source code for tons of powerful pyQt examples. It’s a great way to learn….

Adding the Py Dev Project(s) to P4:
1. Right click on a project→ team→ share project→ Perforce
2. Set up the perforce settings and apply

4. Real Time Debugging Maya In Eclipse:

1. Set a break point in a python script that will be run from Maya.
2. Go to debug view/mode in Eclipse and start the debug server.
3. Call this from Maya to connect (This utility was written by Jason Parks).

4. To connect remotely to other people and debug their Maya from the comforts of your workstation, set up a Maya call that replaces ‘localhost’ with your machine network name.

def connectToEclipse(host='localhost'):
    """
    SYNOPSIS
    Connects to Eclipse PyDev debug server

    INPUTS NONE

    RETURNS: Nothing
    """
    #import pydevd
    from diagnostics.pydevDebug import pydevd
    try:
        pydevd.settrace(host=host, stdoutToServer=True, stderrToServer=False, suspend=False)
        print 'Connected to Eclipse'
    except:
        print 'Could NOT connect to Eclipse'

5. Refer to this when it comes to the intricacies of debugging in Eclipse – http://pydev.org/manual_adv_remote_debugger.html
NOTE: You can copy the code from the python widget by double clicking once then copy.

5. Trouble Shooting, Tips & Tricks:

1. If your Eclipse get a java resource crash (using up all available cache), you can increase it by opening – C:/Program Files/eclipse/eclipse.ini. These are the settings I run with and I have not have a resource crash since:

--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.0.200.v20090519
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Xms512m
-Xmx1000m

2. Pymel is no longer autocompleting (can sometimes happen when you jump between interpreters…) – Click Force restore Internal Info Button (Right click on your project → Properties→ Pydev-PYTHONPATH) also select your PyDev project and refresh (F5).

6. Setting Up To Compile Your Own External Tools (.exe’s):

py2exe:
1. Download the latest release for Python 26 (grab both 32 and 64 bit) – http://sourceforge.net/projects/py2exe/files/
2. Install the py2exe-0.6.9.win64-py2.6.amd64 to C:/Program Files/Python26 and the 32 installer to C:/Program Files(x86)/Python26.

GUI2EXE – Nice front end for a host of compilers:
1. Dowload GUI2EXE – http://code.google.com/p/gui2exe/
2. Unzip this to anywhere on your HD
3. Before running it, install the 64 bit and 32 bit version of wxPython2.8 (required to run GUI2EXE) – http://www.wxpython.org/download.php#binaries
4. Install the 32 bit to C:/Program FIles (x86)/Python26, and the 64 bit to C:/Program FIles/Python26.
5. To get gui2exe to run, right click on the gui2exe.py and in the first tab of properties, set open with 64 bit pythonw.exe – C:/Program FIles/Python26/pythonw.exe.
6. Now you can double click GUI2EXE and compile your own 64 bit and 32 bit Python based programs. In GUI2Exe, go to Options→ Change Python Version…. to swap between compiling for 32 and 64 bit. If you use PyQt for your interface, don’t forget to add sip to included modules…..
7. To include external modules from your code base, Go to Options→ Add Custom Code. Import sys and sys.append python paths so that the compiler can find the libraries that you are using in whatever tool you want to compile.

You now have one hell of a IDE set up with the capability to generate 64 and 32 native applications from your Python code.
Happy Scripting!!

/Christian

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 博主赞过: