Wing Tips: Remote Python Development with Wing Pro 6

Jan 17, 2017


Introduction

Wing Pro 6 adds the ability to connect to a remote host through a secure SSH tunnel in order to work with files stored remotely in the same way that Wing supports working with files on your local system. Editing, debugging, testing, searching, version control, Python Shell, OS Commands, and other features all work with remote systems.

Currently, Wing can work remotely to macOS and Intel or ARM Linux systems. This includes any PEP 513 compatible Intel Linux system and ARM systems like Raspberry Pi and Jolla phone. We are still expanding the range of remote systems that we support. For a detailed list of the remote host types supported in the current release, please see Supported Platforms. If you try a device and cannot get it working, please don't hesitate to email support at wingware dot com for help.

Configuration

Before you can set up remote development in Wing, you first need to have an SSH key pair and set up password-less (SSH key authenticated) remote access to your target host using ssh on Linux and macOS or either OpenSSH (provided by Cygwin, Git Bash, or similar) or PuTTY on Windows. If you don't already have this, please refer to SSH Setup Details in Wing's documentation.

Once you have password-less SSH access working outside of Wing, in most cases Wing will automatically find and use your SSH configuration. If it fails to do that in the steps that follow, you may need to set the Network > SSH Executable preference to the full path to ssh, ssh.exe, or PuTTY's plink.exe, and/or ensure that Wing can access the SSH user agent. See the Accessing SSH From Wing section in Remote Hosts for detailed instructions.

Creating a Project

To set up a new project that works with a remote host, select New Project from the Project menu and choose Connect to Remote Host (via SSH) as the project type. Then enter an Identifier to use for the remote host, the `Host Name or ip address (optionally in the form username@hostname), and for WINGHOME specify the location at which Wing should install its remote agent on the remote host. You only need to specify Python Executable if Python is not on the PATH on your selected remote host or you want to select one of several Python installations (this is relatively rare).

For example, here is a configuration to access a RedHat Linux system on my local network from Windows 10:

/images/blog/remote-development/new-project.png

To keep things simple, leave Store Project on Remote Host unchecked and then press OK. This will create the project and a remote host configuration, and will try to contact the remote agent. Unless you've already installed the remote agent on that remote host in the WINGHOME your specified, you will get a dialog that looks like this:

/images/blog/remote-development/install-agent.png

Press Install Remote Agent and Wing will install the agent and then retry establishing a connection to the agent. If this succeeds, you will see a dialog as follows:

/images/blog/remote-development/install-success.png

Close this dialog and you will see a confirmation that the project was created successfully:

/images/blog/remote-development/confirmation.png

In this case, just select Save Later.

Using Your Project

Now you can right-click on the Project tool (accessed from the Tools menu) and select Add Existing Directory to add a directory containing your source code. Don't add your entire home directory or many 1000's of files since remote development does have higher latency for processing files than local development. Press the Browse button in the Add Directory dialog to browse files on the remote system. Afterward, save the project to local disk with Save Project in the Project menu.

If you restart the Python Shell from its Options menu, Wing should start the shell on the remote host. For example, here is Python running remotely on a CentOS 6 system from Wing on Windows 10:

/images/blog/remote-development/python-shell.png

To debug, open a file from the directory you added to the project and select Start/Continue in the Debug menu. Wing launches the file in the debugger on the remote host and will reach breakpoints and exceptions. Debugging a remote file works the same way as for local files. You can use the Debug Probe, Stack Data, Watch and other tools to inspect and debug your code.

/images/blog/remote-development/debugging.png

Other tools, including the Testing tool for unit testing, the version control integrations, and OS Commands for executing non-Python command lines all work on the remote host. Everything you do is protected through the use of secure SSH tunnels to the remote host.

Details

The remote host configuration you created along with your project is stored within the project file in this case, because you stored the project on local disk. You can view and edit the configuration, or create other remote host configurations, from Remote Hosts in the Project menu. Here is an example where two remote hosts were created:

/images/blog/remote-development/remote-hosts.png

It is possible to set up multiple remote host configurations for one project, but the project's Python Executable in Project Properties (from the Project menu) can only point to one of the remote hosts, and that is where the Python Shell and debug processes are run. Changing the Python Executable is what determines whether a project points to local disk or some remote system. Here are the Project Properties that were set up automatically in the project we created above:

/images/blog/remote-development/project-properties.png

Remotely Stored Projects

In this example, we stored the project file on local disk. Project files can also be stored on the remote host. In that case, the remote host configuration needs to be checked as Shared, as for remote host osx in the Manage Remote Hosts dialog above. This stores the remote host configuration locally so that it can be used to access the remote project later with Open Remote Project from the Project menu.

You can also use this feature to remotely open a regular Wing project, for example to work on something that resides on your desktop computer while you relax on the couch with your laptop.

Remote Display with X11

To work with code that displays a user interface, you will need to either display those windows to a screen attached to the remote host (by setting the DISPLAY environment variable in your Project Properties, for example to :0.0) or you can forward display to occur on the same machine where Wing is running. For the latter, unless Wing is running on Linux, you will need to run an X11 server such as Xquartz on macOS or MobaXTerm on Windows. Then check on the Forward X11 option in your remote host configuration, under the Options tab.

For more detailed instructions and advanced configuration options see Remote Hosts.

Don't hesitate to contact us at support at wingware dot com if you need help getting remote development working.



Share this article: