Wing Tips: Configuring Wing's Python Debugger for Your Code Base

Jun 04, 2020


This Wing Tip provides a roadmap to the configuration options available for Wing Pro's debugger, to make it easier to understand the available possibilities and how these can be applied to your development projects.

In short: Wing can develop and debug just about any kind of Python code, regardless of whether is resides locally or on a remote host, on a container or cluster, whether it's launched by the IDE from from the outside, and whether it is asynchronous, threaded, or runs in multiple processes. Read on for the details.

Configuration Options

Broadly speaking there are six ways to configure Wing's debugger:

Local Stand-Alone Code -- Wing can debug stand-alone scripts and applications that run on your local machine and that are launched on demand from within Wing. This development approach can be used for anything that is convenient to launch from the IDE, including scripts, desktop apps, and most web frameworks. See the Debugger Quick-Start for a quick introduction to this simple case.

Remote Stand-Alone Code -- Wing Pro can also debug stand-alone code running on a remote host, virtual machine or device, in the same way as it debugs locally running code. Wing uses a remote agent launched by SSH in order to work directly with files stored on the remote host, as if Wing were itself running on that system. For details, see Remote Development with Wing Pro.

Container and Cluster Code -- Wing Pro can debug code that runs on a container like those hosted by Docker or LXC/LXD, or clusters hosted by Docker Compose. In this case, editing, version control, and search operate files stored on your local disk, but code is transparently executed and debugged in the context of a container instance. For details, see Working with Containers and Clusters.

Local Externally Launched or Embedded Code -- Wing can debug locally running code that is launched by a web server or framework, embedded Python code that is used to script a larger application, and any other Python code that cannot be directly launched from the IDE. In this case, the code is started from outside of Wing and connects to the IDE by importing Wing's debugger. Debug can be controlled from the IDE and through an API accessible from the debug process. For details, see Debugging Externally Launched Code

Remote Externally Launched or Embedded Code -- Wing Pro can also debug externally launched or embedded code that is running on a remote system. In this case, Wing uses a remote agent to access the remote host via SSH and the debugged code imports Wing's debugger in order to connect back to the IDE through an automatically established reverse SSH tunnel. See Debugging Externally Launched Remote Code for brief instructions or Remote Web Development for a more detailed guide.

Manually Configured Remote Debugging -- For remote hosts and devices that are not accessible through SSH, or where Wing's remote agent cannot be run, Wing provides a manual configuration option to make debugging on these systems possible. In this case, the device must be able to connect to the host where Wing is running via TCP/IP, and there must be some file sharing configuration so files are available both locally and on the remote system. In this approach, connectivity, file sharing, and other configuration needed to make debugging possible is accomplished entirely manually, so it can be tailored to unusual custom environments. For details, see Manually Configured Remote Debugging.

VirtualEnv, Poetry, pipenv, and Anaconda Environments

In context of the above , Wing may be used with or without an environment created by virtualenv, Poetry, pipenv, or Anaconda's conda create.

Environments can be created with your Wing project as described in Creating Python Environments.

Alternatively, environments may be selected after the fact. For local debugging, this is done by setting the Python Executable in Project Properties. For remote debugging, it is set in the remote host configuration.

For virtualenv, Poetry, and pipenv, you can either set the Python Executable to Command Line and enter the full path to the environment's Python, or you can select Activated Env and enter the command that activates the environment. See Using Wing with virtualenv, Using Wing with Poetry, and Using Wing with pipenv for details.

For Anaconda environments, you must select Activated Env and then choose the environment from the drop down list to the right of this field. See Using Wing with Anaconda for details.

If you are working with containers or clusters, Wing uses the environment set up and managed by the container. See Working with Containers and Clusters, Using Wing with Docker, and Using Wing with LXC/LXD for details.

Specific Frameworks and Tools

Some frameworks and tools require some additional custom configuration to make them easy to work with in Wing. In addition to understanding the general options explained above, it is a good idea to seek out configuration details for the frameworks and tools that you use:

The New Project dialog accessed from the Project menu provides some assistance for setting up new Wing projects for most of these.

Multi-threaded and Multi-process Debugging

Wing automatically debugs any multi-threaded code without any additional configuration.

Multi-process code can also be debugged but requires turning on the Debug/Execute > Debug Child Processes option in Project Properties before child processes are automatically debugged. In this case, you may also want to configure specific options for how Wing handles and terminates child processes. See Multi-Process Debugging for details.



That's it for now! We'll be back soon with more Wing Tips for Wing Python IDE.

As always, please don't hesitate to email support@wingware.com if you run into problems or have any questions.



Share this article: