Python Tools for Visual Studio 2012

python

#1

Hey guys,

Recently I had Java removed from my system by IT and it broke Eclipse. So I did some searching and found Python Tools for Visual Studio.

http://pytools.codeplex.com/

I guess it has been around for a while, but I didn’t know about it before now. It’s a completely FREE IDE if you install the VS 2012 Integrated + Isolated Shells and it supports advanced features like Python Interactive Mode while debugging in Maya and lots of other stuff (check out the videos on the codeplex page).

My impressions for the past two weeks of use are that it is awesome and I’m switching to it from Eclipse for Maya/Python development.

The version 1.5 binary release does not yet support remote debugging (which is required for debugging in Maya), but since the project is Open Source you can download and compile the latest code yourself, which does have remote debugging. Instructions for building are here.

The team working on this here at Microsoft had no idea Python was so popular in our industry and they are eager to hear feedback. They are shaping the product roadmap based on user needs and so far that has mostly been server people and Microsoft Research. Check it out if you have time!


#2

Still haven’t found an IDE I really like so I’m going to give this one a shot. I always thought Eclipse was way too bloated. Thanks for sharing.


#3

I use this every day, and it is my IDE of choice. You can do debugging with it as well by using “attach to process” with debugging set to Python, though it is a bit sketchy, and will often require a Maya restart, but if you’ve been writing Python/MEL for Maya for any length of time, you are probably pretty accustomed to restarting. If your using python.net, you can also use System.Debugger.Attach(), or System.Debugger.Break() to break into running code.

The new version has a Wizard that will scan your Python project tree and make a VS project out of it. The ability to use the built in refactoring (rename), and “find all references” is ridiculously helpful. EDIT: Don’t forget to add whatever search paths/system paths that your have running in Maya to the VS project.

Also, don’t forget the MEL syntax highlighting for VS. It is a little out of date, and it took me a while to figure out how to get it installed for VS 10, but it works fine. http://www.creativecrash.com/maya/downloads/applications/syntax-scripting/c/mel-syntax-highligt-for-visual-studio-6/bugs


#4

Oh, also, it does support remote debugging, but it is designed for working with web servers, not Maya…


#5

Thanks for the laugh. Eclipse is bloated and you’re considering VS as better? But the plugin does look cool to try out.


#6

I tried these out and didnt really have time to give it a fair shot before having to go back to wing to finish some stuff. Later i had to debug a maya cpp plugin and VS wouldn’t break when attaching to maya. I was racking my brain! Then I remembered these tools. When attaching it says what type of process it is and it lists maya.exe as a Pythong Engine… so it would only attach using python and not x64.

Anyhow, i uninstalled and VS debugging worked again. Is there a way around this or is it one way or the other?


#7

Here at CCP we’re basically split between PTVS and PyCharm (and Sublime but I don’t consider that an IDE). I think PyCharm is far and away better than PTVS but PyCharm isn’t free. It’s totally worth the cost though, IMO.


#8

going to be better off useing a ide meant for python, pycharm is a good start, or even just using a editor, and customizing it. im a little old school so am still useing gvim, but i got it so custmized and setup to my likeing that i am faster at working with python in it than anythign else.


#9

We have the ear of the PTVS team. I met with them yesterday on campus and they are very interested in what we like about other Python IDEs and how they can make PTVS better.

I have been using a self-compiled version from codeplex that supports remote debugging and this is pretty stable with Maya. I am setting up a box for them with Maya and VS2012 installed so they can debug Attach to process directly and fix any issues.

Seriously, if you guys have anything you ever wanted or wished was in your IDE, speak up! If PTVS doesn’t do something PyCharm or Wing does, let me know and I’ll pass it along. Examples are great! These guys are all-ears and motivated to make an awesome product for the end user. Bonus that it’s completely free.


#10

hi everyone,

1st a thank you to jesse for connecting us with your community.

as he stated, we’re a bunch of python & OSS fans inside msft that make the http://pytools.codeplex.com plug-in for visual Studio. we’re currently working on the 2.0 version of the product and would love to hear what your needs are.

regarding Maya/Python debugging, we have some generic debug/attach support, but had not tested it w Maya before. we’re in the process of making Maya support rock solid w jesse’s help. some it will show up in alpha (~2 weeks), the rest in beta (~3 months). proper remote debug support for windows & linux is also available.

if there’s anything else you’d like to see in your ideal IDE pls dont hesitate to let me know. we’ll do our best to get it into PTVS.

some video overviews for PTVS on YT: http://www.youtube.com/results?search_query=Python+PTVS&oq=Python+PTVS&gs_l=youtube.3..35i39l2.2054.3714.0.5111.11.11.0.0.0.0.191.769.10j1.11.0...0.0...1ac.1.6Y38We4o5Jg

cheers,

s


#11

[QUOTE=TheMaxx;20176]I tried these out and didnt really have time to give it a fair shot before having to go back to wing to finish some stuff. Later i had to debug a maya cpp plugin and VS wouldn’t break when attaching to maya. I was racking my brain! Then I remembered these tools. When attaching it says what type of process it is and it lists maya.exe as a Pythong Engine… so it would only attach using python and not x64.

Anyhow, i uninstalled and VS debugging worked again. Is there a way around this or is it one way or the other?[/QUOTE]

By default, VS tries to guess the “best” debugging engine when attaching to the process. If you have PTVS installed, then any process running Python will default to Python debugging. However, this may be overridden explicitly - above the “Available Processes” list, there is a text box labelled “Attach to:” that shows the selected debugging engine for the current process. That would normally show something like “Automatic: Python code” for Maya. However, there is a “Select …” button to the right of the text box that lets you pick the engine that you want to use. You can then switch to “Native” there.


#12

@int19h: Thanks, i’ll re-install and give it another go :slight_smile:


#13

The ability to run tests easily from the IDE is a must for me- right-clicking on a test, class, file, directory, etc., and running all tests under it via nose. Also, the ‘Main’ idea of an assembly does not map to python- any number of scripts in a package can be runnable. It needs to be easier. I guess what I mean is, make running python code like it is in PyCharm.

I don’t (and won’t) use PTVS, but the C++ programmers here do (and probably will continue to), so I have a vested interest in making sure I am minimally frustrated when I work at their desks :slight_smile:


#14

Also, the ‘Main’ idea of an assembly does not map to python- any number of scripts in a package can be runnable. It needs to be easier. I guess what I mean is, make running python code like it is in PyCharm.

Can you please clarify? I’ve played with PyCharm a little bit, and the quickest and the most obvious way to do the above is to right-click a .py file in Project pane, and then you get the options to run or debug it. But PTVS also does the same thing for .py files in Solution Explorer. Or were you rather referring to Configurations in PyCharm?


#15

Well, both.
Right click a folder, you can run tests. Right click a file, you can run tests or the file. Right click a test or test case, you can run those tests. You can take any of these configurations and save/edit them. You can switch between configurations, and configurations are remembered. It just all works fairly intuitively.


#16

I’ve started to use VS (only 2012) for python scripts and made a quick tool to excute selected python code in maya.
This is still a test but I’m planning to make it more advanced. (Right now it’s just the selected text.)
If you have any remarks or ideas please shoot
http://josbalcaen.com/scripts/maya/tomaya/


#17

Hey guys,

Just a heads-up that PTVS 2.0 Alpha has hit Codeplex with remote debugging support (in addition to the already-supported direct-attach to the Maya.exe process). Remote debugging works a little differently than Eclipse / PyDev since the server and client relationship is reversed. Instead of Maya’s Python process attaching to the Debug Server, PTVS attaches to the remote Maya Python process. This works locally on your machine or any other machine on the network.

Watch this video for an overview of the process in general (if you want to attach to the Maya process on your machine just use localhost):

Having done the PyDev debugging dance, this process seems a lot easier to me, especially when debugging Maya on remote machines where production code does not use the same file paths as your development code (no need to specify client-server path translations in pydevd_file_utils.py).


Jesse


#18

I’ve just been trying out the remote debugging workflow in PTVS 2.0 in VS 2012 (ultimate) with Maya 2013 today but I don’t seem to be able to get breakpoints to trigger.

I think I’ve followed everything outlined in the video posted by Jesse. I’m able to import the ptvsd package in my script and set ptvsd.enable_attach() and I’m able to attach to the Maya process via localhost but no breakpoints seem to be triggered.

Any suggestions? It’s quite possible I’m just doing something stupid :slight_smile:

EDIT:

Turns out I was just doing something relatively stupid (or at least unsupported) :P. It looks like it wasn’t breaking because Maya was accessing the source via an absolute path while the PTVS project was using a subst drive mapped path. Although both were pointing to the same source files I’m guessing the debugger couldn’t reconcile the differing paths. When I set up Maya to access the source via the same subst mapped path as VS the breakpoints work fine.


#19

I finally had some time to try this out with Motionbuilder. And it works!!

It’s amazingly simple to set up. Some very quick steps:

Setup
. Get PTVS, free version here: https://pytools.codeplex.com/wikipage?title=PTVS%20Installation
. Copy C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.0\ptvsd somewhere to your Mobu’s python path, or add it to sys.path

Debugging
. Add import ptvsd and some breakpoint to your python script
. Launch Motionbuilder, on VS do Debug/Attach to Process and select motionbuilder.exe
. Open the same python script on the python editor (and this is important, drag and dropping the script on the viewport does not work) and run it.
. Motionbuilder should stop on the breakpoint and you should have all the debugging info on VS

Intellisense
It’s a bit trickier. Basically you need to have C:\Program Files\Autodesk\MotionBuilder 2013\bin\config\Python\pyfbsdk_gen_doc.py accessible by VS. You could copy it to something like c:\Python26\Lib, but that sucks. The best option is to add it on the Search Path for the project, either from that folder or some custom one. And lastly, you need to rename it pyfbsdk.py (to be able to do import pyfbsdk, instead of pyfbsdk_gen_doc)


#20

[QUOTE=eksimioni;22398]I finally had some time to try this out with Motionbuilder. And it works!!

It’s amazingly simple to set up. Some very quick steps:(snip)[/QUOTE]
Yeah, they’re pretty close to releasing the release candidate for 2.0. Can’t wait till it’s “official”.