Using wingdb to Initiate Debug
In addition to starting debug by importing wingdbstub, it is also possible to start debugging code by running wingdb (or wingdb.exe on Windows) from the top level of the Wing installation. These are invoked like the Python command line, after setting some environment variables that tell Wing which Python installation to use and how to connect to the IDE.
To use this methods, first make sure that Wing is listening for debug connections by clicking on the bug icon in the lower left and checking on Accept Debug Connections.
Next set the following two environment variables if needed:
WINGDB_PYTHON -- The full path to the python or python.exe to use if you do not want to use the default of python.
WINGDB_HOSTPORT -- The host:port where the IDE is running if different than the default of localhost:50005. The host can be either a host name or an IP address and the port is the one shown when the mouse is hovered over the bug icon in the lower left of Wing's main window.
Now you can start debugging by running wingdb (or wingdb.exe) as if it were Python. Debugging should start and the process should connect back to Wing on the configured host and port number.
For example on Windows:
set WINGDB_PYTHON=C:\Python34\python.exe set WINGDB_HOSTPORT=127.0.0.1:50005 C:\Program Files\Wing IDE 5.0\wingdb.exe myscript.py arg1 arg2
Or on Linux:
export WINGDB_PYTHON=python3.4 export WINGDB_HOSTPORT=127.0.0.1:50005 /usr/lib/wingide5/wingdb myscript.py arg1 arg2
Or on OS X:
export WINGDB_PYTHON=python3.4 export WINGDB_HOSTPORT=127.0.0.1:50005 /Applications/WingIDE.app/Contents/Resources/wingdb myscript.py arg1 arg2
Other optional environment variables include:
WINGDB_PYARGS -- Provides any arguments to send to the Python specified with WINGDB_PYTHON. Do not use this for arguments sent to your Python code. Those are specified on the command line instead.
WINGDB_STEPINTO -- 0 or 1 to indicate whether to stop on the first line of code (defaults=don't stop)
WINGDB_LOGFILE -- The full path to a diagnostic log file. Set this only at the request of Wingware Technical Support. It will slow down the debugger (default=no logging)
WINGDB_LOGVERYVERBOSE -- Whether to print extremely verbose low-level logging. Set this only at the request of Wingware Technical Support. It will drastically slow down debugging (default=off)
WINGDB_WAIT_ON_EXIT -- Whether the debug process should wait on exit for further interaction with the debugger (default=don't wait)
WINGDB_ENV_FILE -- When given, the debugger will load environment from this file and then exec sys.executable in the environment. The environment file contains a sequence of byte strings, each separated by a '0' byte. The 1st of every pair is a key and the 2nd is the value. (default=run in inherited environment)
WINGDB_WINGHOME -- The Wing installation directory (default=compute based on location of the wingdb or wingdb.exe file)
WINGDB_USERSETTINGS -- The Wing User Settings directory, used only to find the debugger implementation if provided by a patch (default=None)
The following optional envs are only used to support Python < 2.6; in Python 2.6+ set PYTHONIOENCODING instead:
WINGDB_STDOUT_ENCODING -- Sets the encoding to use for stdout
WINGDB_STDIN_ENCODING -- Sets the encoding to use for stdin
On Windows, wingdb.bat can be used in the same way as wingdb.exe and may be useful in cases where modifying the launcher is convenient or necessary.