Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use remote vagrant based python interpreter when coding Visual Studio + PTVS

In our company we using vagrant VM's to have the save env. for all. Is it possible to configure VisualStudio + PTVS (python tools for VS) to use vagrant based python interpreter via ssh for example?

like image 742
Ph0en1x Avatar asked Oct 31 '22 20:10

Ph0en1x


1 Answers

There's no special support for remote interpreters in PTVS, like what PyCharm has. It's probably possible to hack something based on the existing constraints, but it would be some work...

To register an interpreter that can actually run, it would have to have a local (well, CreateProcess'able - so e.g. SMB shares are okay) binary that accepts the same command line options as python.exe. It might be possible to use ssh directly by adding the corresponding command line options to project settings. Otherwise, a proxy binary that just turns around and invokes the remote process would definitely work.

Running under debugger is much trickier. For that to work, the invoked Python binary would also have to be able to load the PTVS debugging bits (which is a bunch of .py files in PTVS install directory), and to connect to VS over TCP to establish a debugger connection. I don't see how this could be done without writing significant amounts of code to correctly proxy everything.

Attaching to a remotely running process using ptvsd, on the other hand, would be trivial.

For code editing experience, you'd need a local copy (or a share etc) of the standard library for that interpreter, so that it can be analyzed by the type inference engine.

like image 165
Pavel Minaev Avatar answered Nov 08 '22 05:11

Pavel Minaev