Project/Solution Management when using PTVS

Editor
Sep 9, 2011 at 8:26 PM

I just got VS 2010 and PTVS installed so I can evaluate using it as an IDE for python.

I'm trying to figure out how I should be configuring and managing solutions/projects.  I have a large custom framework that a lot of tools/scripts, etc. hook into.  When working on said tests/tools I don't really want to go create a new custom solution/project for every single script that plugs into the framework.  Is there a good way around this?

For comparison: I'm also evaluating WingWare IDE as a python IDE and this aspect seems far easier.  e.g. There is no management required whatsoever.  I simply load the tool/script I want and can immediately get code completion, etc. on the entire framework and debugging support.  Is there a way to make using PTVS this easy in VS2010 or am I forced to figure out how to use projects and solutions to make this happen?

Coordinator
Sep 9, 2011 at 8:53 PM

We do support just opening a file and getting completion but we'll only model the other files on disk if they're in a package with the file.  Are all of your scripts completely stand alone or are they part of a larger package w/ __init__.py?  You can also open multiple files and we'll model each of the loose files all in the same analysis domain.  So one solution might be just opening all of the files.

You can also create a project which contains all of the files - one way to do this is using File->New->Project from Existing Code.  But this has a similar limitation of only bringing in packages (this is changing for 1.1 and we'll bring in all of the .py files in the directory and below).

If new project from existing code doesn't work for you I think the last step would be to write a script which generates the .pyproj file from the directory structure exactly how you'd like it.  Then you can just open the .pyproj file.  If you have any feedback on what you'd like to see in new project from existing code we'd love to hear it to help make it better for the next release.

 

Editor
Sep 9, 2011 at 8:56 PM

We have a custom .pth file in site_packages to pull in our library into the python system path.  Any stand alone python file can then import and use anything in our library.  That doesn't appear to be working transparently at current, so I'm trying to figure out how to make it work as desired.

Editor
Sep 9, 2011 at 9:03 PM

Am I required to make a project for every script I want to debug?

Coordinator
Sep 9, 2011 at 9:08 PM

Regarding .pth files: Do you have a Microsoft.PythonTools.Analyzer process running? We are supposed to read in .pth files and process them accordingly for our cached intellisense. It may take a while for that to be generated.

Regarding the project: Yes, you do currently need to create a project to debug scripts. I've opened a feature request as this is an annoying oversight: http://pytools.codeplex.com/workitem/514 Feel free to vote for it to help us prioritize what to do for the next release (or if you're interested in implementing it we'd be happy to accept a patch!)

Editor
Sep 9, 2011 at 9:18 PM

Unfortunately it sounds like my current system may just not be able to handle intellisense on my project (Visual Studio is crashing).  Still using an old machine using XP SP3 32-bit...  http://msdn.microsoft.com/en-us/library/ff407021(VS.100).aspx

 

Trying to go to definition on my library imports in a script results in a message at the bottom "Python source analysis is not up to date".  Do you know of a way to force generation so I can force the crash and prove that's what is causing it?

Coordinator
Sep 9, 2011 at 9:25 PM

If you're getting the message that the analysis is not up to date that means the analysis is currently running inside of Visual Studio.  Hopefully you can attach another copy of VS to the existing one and wait for it to crash.  If not you can just send the error report in and we'll get it once it makes it's way through the Watson system.

 

Editor
Sep 9, 2011 at 10:09 PM
Do you have any idea if there's a way to monitor/trace the intellisense generation process? I've had VS sitting open, idle for at least 30 minutes and it's still saying it can't look up symbols. It'd be nice if there was a way to track what it's doing, where it's getting stuck, etc.

On Fri, Sep 9, 2011 at 3:25 PM, dinov <notifications@codeplex.com> wrote:

From: dinov

If you're getting the message that the analysis is not up to date that means the analysis is currently running inside of Visual Studio. Hopefully you can attach another copy of VS to the existing one and wait for it to crash. If not you can just send the error report in and we'll get it once it makes it's way through the Watson system.

Read the full discussion online.

To add a post to this discussion, reply to this email (pytools@discussions.codeplex.com)

To start a new discussion for this project, email pytools@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Coordinator
Sep 9, 2011 at 10:45 PM

There's nothing really built in but with the debugger attached you should be able to break in and find a thread named Python Analysis Queue.  When the analysis is not in progress that's blocked in MS.PT.Library.Intellisense.AnalysisQueue.Worker.  If the analysis is still running then that will be working on some AnalysisUnit.  If the issue is truly that the analysis is not completing you might see that we're processing the same analysis unit's over and over again.  If it's making progress it'll usually be going through a number of different analysis units over time. 

Sep 15, 2011 at 2:33 PM

> You can also create a project which contains all of the files - one way to do this is using File->New->Project from Existing Code.

I did this with a fairly large Python project (over 1500 .py files).  It took a long time and still takes Vs 2010 many minutes to open the resulting project.  VS appears dead during this time.

Olaf

Feb 4, 2012 at 12:49 AM

PTVS is really impressive, but I gave it up because of the project file requirement. I work with people who write code using other editors, and keeping up with changes or regenerating a project file every time I update from source control was a deal killer.

Python is naturally directory based. Couldn't a project file be as simple as "start in this directory"? That's kind of the approach of Komodo Edit, which even without many of the features of PTVS ends up working better workflow-wise for me. 

Coordinator
Feb 4, 2012 at 1:04 AM

Thanks for the feedback.  I think you can get this behavior by putting:

   <ItemGroup>
      <
Compile Include=".\**\*.py" /
   
</ItemGroup>

Into a .pyproj file, although I haven't tested it. It might mostly work but there could be corner cases that we need to consider like auto updating when files are added on disk.

You can also just open .py files and work with them w/o a project file.  We'll model the files using the default interpreter configured in Tools->Options->Python Tools->Interpreter Options and we'll search up and down the directory hierarchy as long we encounter __init__.py's and model all the files we find. I would suspect this isn't ideal for you because it sounds like you actually want a project.

Looking ahead, we're thinking about doing the "Show all Files" feature in Solution Explorer for the next release.  That'd let you have a project with no files in it, but you'd still be able to see the files in solution explorer.  I think the only possible downside here is that the .py files may look a little different visually.

And last but not least we actually had IronPython Tools working under this model originally instead of having the project files list their contents.  If none of the above really sound like what you're looking for please open a feature request.  We ended up switching back to the more explicit model because most of the feedback we heard was in favor of that.  We could certainly look at adding a feature to automatically include all files in a certain path (and maybe that's really just about adding some UI to enable this and making .\**\*.py work really nicely).