Name | debugpy-run JSON |
Version |
1.12
JSON |
| download |
home_page | None |
Summary | Finds and runs debugpy for VS Code "remote attach" command line debugging |
upload_time | 2024-08-03 21:55:52 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.6 |
license | GPLv3 |
keywords |
debugpy
vscode
code
ptvsd
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
## DEBUGPY-RUN
[![PyPi](https://img.shields.io/pypi/v/debugpy-run)](https://pypi.org/project/debugpy-run/)
[![AUR](https://img.shields.io/aur/version/debugpy-run)](https://aur.archlinux.org/packages/debugpy-run/)
This utility facilitates debugging a [Python](https://www.python.org/)
command line program using [Python
extension](https://code.visualstudio.com/docs/languages/python) in
[Visual Studio Code](https://code.visualstudio.com/).
The [Python
debugger](https://code.visualstudio.com/docs/python/debugging) in [VS
Code](https://code.visualstudio.com/) is superb. However debugging a
command line program which takes arguments is a little awkward to
invoke. The [official
instructions](https://code.visualstudio.com/docs/python/debugging#_initialize-configurations)
require you to edit the command line arguments in your `launch.json`
configuration which is cumbersome to do when you want to change
arguments for each run, particularly because the [arguments have to be
quoted within a JSON data
structure](https://code.visualstudio.com/docs/python/debugging#_args).
This [question on
stackoverflow](https://stackoverflow.com/questions/43704747/visual-studio-code-run-python-file-with-arguments)
describes the problem, but there is no adequate solution. This utility
provides a solution, follow the [procedure to use
it](http:/#procedure-to-use) below.
If you have the [VS Code Python
extension](https://code.visualstudio.com/docs/languages/python)
installed then the full
[`debugpy`](https://github.com/microsoft/debugpy) debugger is already
bundled with it. You open a terminal window and run this utility to
invoke your program with arguments. The utility finds the path where
[`debugpy`](https://github.com/microsoft/debugpy) is installed and then
runs it for the program and arguments you specify, in listen mode.
Connect to it from within [VS Code](https://code.visualstudio.com/)
using the Python _Remote Attach_ debug configuration (using the default
host and port settings). You can `control+c` and then re-run the command
with changed arguments using your shell history and command line editing
facilities, for each debug run. You can also run `debugpy-run` remotely,
with `debugpy` explicitly installed for this case, to debug from [VS
Code](https://code.visualstudio.com/) to a remote machine over a
network.
This utility was developed on Arch Linux but should work on all Linux
systems where [VS Code](https://code.visualstudio.com/) is installed
with the [Python
extension](https://code.visualstudio.com/docs/languages/python). The
latest version and documentation is available at
https://github.com/bulletmark/debugpy-run.
## Installation
Arch users can install [debugpy-run from the
AUR](https://aur.archlinux.org/packages/debugpy-run/).
Python 3.6 or later is required. Also, the Python
[packaging](https://pypi.org/project/packaging/) module is required.
Note [debugpy-run is on PyPI](https://pypi.org/project/debugpy-run/) so
just ensure that [`pipx`](https://pypa.github.io/pipx/) is installed
then type the following:
```
$ pipx install debugpy-run
```
To upgrade:
```
$ pipx upgrade debugpy-run
```
To remove:
```
$ pipx uninstall debugpy-run
```
## Procedure to Use
1. Open [VS Code](https://code.visualstudio.com/) for the directory
where your command line program is located.
2. Ensure you have added a [Debugging
Configuration](https://code.visualstudio.com/docs/python/debugging#_initialize-configurations)
in your `launch.json`. Specify _Remote Attach_ and just accept the
default arguments (i.e. host = `localhost`, port = `5678`). You only
have to do this once for each project.
3. Open a terminal (either within [VS
Code](https://code.visualstudio.com/), or external) and type:
$ debugpy-run my-program -- --myargs
Now `debugpy-run` will start the `debugpy` debugger for your program,
output a message, and then wait to be connected by [VS
Code](https://code.visualstudio.com/).
:warning: As seen in the above example, you should specify `--`
after your program/module name so that debugpy-run knows where it's
own options end, and the target options start.
:warning: You must run `my-program` from same work directory as VS
Code is using otherwise VS Code will not correlate your source file
path with the code being run by debugpy. I.e. if the program is
located at `src/my-program` with respect to the work directory then
you must run it as `debugpy-run src/my-program -- --myargs`
4. In [VS Code](https://code.visualstudio.com/), start debugging, e.g.
set a breakpoint then start the _Remote Attach_ debug session.
5. At any point you can `control+c` the terminal command and restart it
with new command line arguments (e.g. using the convenience of your
shell history and editing commands) and then restart the debug
session in [VS Code](https://code.visualstudio.com/).
## Remote Debugging On Another Host
The `debugpy-run` utility first looks to find the `debugpy` package in
your local `~/.vscode/extensions` directory. If it fails to find that
then `debugpy-run` next tries to import `debugpy` globally. This is is
done so you can install both `debugpy-run` and `debugpy` on a remote
headless server (e.g. where [VS Code](https://code.visualstudio.com/) is
not installed) and then debug a program on that server from [VS
Code](https://code.visualstudio.com/) on your laptop/PC remotely over
the network.
So for example, I may have a program which runs on a server which want
to debug from [VS Code](https://code.visualstudio.com/) on my laptop. I
first make sure I install the necessary software on the server (you can
also do this in the programs virtual environment of course):
````
$ pipx install debugpy
$ pipx install debugpy-run
````
The start my program on the server using the debugger:
````
$ debugpy-run -p :5678 my-program -- --myargs
````
NOTE: We need to explicitly specify the `:port` for this case so that
the port is opened on the external network interface so we can connect
to it from another machine. By default, `debugpy-run`/`debugpy`
otherwise only accept local connections.
Then I go back to my laptop, ensure I have set up _Remote Attach_
debugging configured with host = `my-server` and port = `5678`, then start
debugging.
Of course, you could start `debugpy` directly yourself on the server but
the `debugpy-run` wrapper is more convenient to use and makes the usage
consistent with the familiar way you start `debugpy-run` on your
laptop/PC.
## Debugging A Program Running As Root
Another application of `debugpy-run` is that you can, as your normal
user, easily use [VS Code](https://code.visualstudio.com/) to debug a
program you run as root. E.g. run a program using `sudo`:
$ sudo debugpy-run my-program -- --myargs
Now you can just _Remote Attach_ to it in [VS
Code](https://code.visualstudio.com/) as your normal user.
## Usage
Type `debugpy-run -h` to view the usage summary:
```
usage: debugpy-run [-h] [--listen | -C] [-W] [-p PORT] [-E] [-A] [-r]
[--log-to PATH | --log-to-stderr]
[-m MODULE | -c CODE | --pid PID] [-V]
[program] ...
Finds the "debugpy" package within your VSCode Python extension and then runs
it for "remote attach" debugging of the program/module you specify. If not
found in extensions, or bundled with this app, then tries to run the
global/venv installed "debugpy".
positional arguments:
program python program to execute and debug
args remaining arguments to debug
options:
-h, --help show this help message and exit
--listen listen on given port, default=True
-C, --connect connect to given port rather than listen
-W, --no-wait do not wait on listen for client, start immediately
-p PORT, --port PORT [host:]port to use, default=5678
-E, --no-extension don't use the debugpy bundled in the extension
-A, --no-app don't use the debugpy bundled in this app
-r, --run-on-error re-run program/module even on error
--log-to PATH log to given path
--log-to-stderr log to stderr
-m MODULE, --module MODULE
python module to execute and debug
-c CODE, --code CODE python code to execute and debug
--pid PID python pid to attach and debug
-V, --version output debugpy path and version
```
## License
Copyright (C) 2021 Mark Blakeney. This program is distributed under the
terms of the GNU General Public License.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or any later
version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License at <http://www.gnu.org/licenses/> for more details.
<!-- vim: se ai syn=markdown: -->
Raw data
{
"_id": null,
"home_page": null,
"name": "debugpy-run",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "debugpy, vscode, code, ptvsd",
"author": null,
"author_email": "Mark Blakeney <mark.blakeney@bullet-systems.net>",
"download_url": "https://files.pythonhosted.org/packages/af/e7/343dcddbe4a40d5099b7b1ea09ef838d4be8df87b504b12f7048399104de/debugpy_run-1.12.tar.gz",
"platform": null,
"description": "## DEBUGPY-RUN\n[![PyPi](https://img.shields.io/pypi/v/debugpy-run)](https://pypi.org/project/debugpy-run/)\n[![AUR](https://img.shields.io/aur/version/debugpy-run)](https://aur.archlinux.org/packages/debugpy-run/)\n\nThis utility facilitates debugging a [Python](https://www.python.org/)\ncommand line program using [Python\nextension](https://code.visualstudio.com/docs/languages/python) in\n[Visual Studio Code](https://code.visualstudio.com/).\n\nThe [Python\ndebugger](https://code.visualstudio.com/docs/python/debugging) in [VS\nCode](https://code.visualstudio.com/) is superb. However debugging a\ncommand line program which takes arguments is a little awkward to\ninvoke. The [official\ninstructions](https://code.visualstudio.com/docs/python/debugging#_initialize-configurations)\nrequire you to edit the command line arguments in your `launch.json`\nconfiguration which is cumbersome to do when you want to change\narguments for each run, particularly because the [arguments have to be\nquoted within a JSON data\nstructure](https://code.visualstudio.com/docs/python/debugging#_args).\nThis [question on\nstackoverflow](https://stackoverflow.com/questions/43704747/visual-studio-code-run-python-file-with-arguments)\ndescribes the problem, but there is no adequate solution. This utility\nprovides a solution, follow the [procedure to use\nit](http:/#procedure-to-use) below.\n\nIf you have the [VS Code Python\nextension](https://code.visualstudio.com/docs/languages/python)\ninstalled then the full\n[`debugpy`](https://github.com/microsoft/debugpy) debugger is already\nbundled with it. You open a terminal window and run this utility to\ninvoke your program with arguments. The utility finds the path where\n[`debugpy`](https://github.com/microsoft/debugpy) is installed and then\nruns it for the program and arguments you specify, in listen mode.\nConnect to it from within [VS Code](https://code.visualstudio.com/)\nusing the Python _Remote Attach_ debug configuration (using the default\nhost and port settings). You can `control+c` and then re-run the command\nwith changed arguments using your shell history and command line editing\nfacilities, for each debug run. You can also run `debugpy-run` remotely,\nwith `debugpy` explicitly installed for this case, to debug from [VS\nCode](https://code.visualstudio.com/) to a remote machine over a\nnetwork.\n\nThis utility was developed on Arch Linux but should work on all Linux\nsystems where [VS Code](https://code.visualstudio.com/) is installed\nwith the [Python\nextension](https://code.visualstudio.com/docs/languages/python). The\nlatest version and documentation is available at\nhttps://github.com/bulletmark/debugpy-run.\n\n## Installation\n\nArch users can install [debugpy-run from the\nAUR](https://aur.archlinux.org/packages/debugpy-run/).\n\nPython 3.6 or later is required. Also, the Python\n[packaging](https://pypi.org/project/packaging/) module is required.\nNote [debugpy-run is on PyPI](https://pypi.org/project/debugpy-run/) so\njust ensure that [`pipx`](https://pypa.github.io/pipx/) is installed\nthen type the following:\n\n```\n$ pipx install debugpy-run\n```\n\nTo upgrade:\n\n```\n$ pipx upgrade debugpy-run\n```\n\nTo remove:\n\n```\n$ pipx uninstall debugpy-run\n```\n\n## Procedure to Use\n\n1. Open [VS Code](https://code.visualstudio.com/) for the directory\n where your command line program is located.\n\n2. Ensure you have added a [Debugging\n Configuration](https://code.visualstudio.com/docs/python/debugging#_initialize-configurations)\n in your `launch.json`. Specify _Remote Attach_ and just accept the\n default arguments (i.e. host = `localhost`, port = `5678`). You only\n have to do this once for each project.\n\n3. Open a terminal (either within [VS\n Code](https://code.visualstudio.com/), or external) and type:\n\n $ debugpy-run my-program -- --myargs\n\n Now `debugpy-run` will start the `debugpy` debugger for your program,\n output a message, and then wait to be connected by [VS\n Code](https://code.visualstudio.com/).\n\n :warning: As seen in the above example, you should specify `--`\n after your program/module name so that debugpy-run knows where it's\n own options end, and the target options start.\n\n :warning: You must run `my-program` from same work directory as VS\n Code is using otherwise VS Code will not correlate your source file\n path with the code being run by debugpy. I.e. if the program is\n located at `src/my-program` with respect to the work directory then\n you must run it as `debugpy-run src/my-program -- --myargs`\n\n4. In [VS Code](https://code.visualstudio.com/), start debugging, e.g.\n set a breakpoint then start the _Remote Attach_ debug session.\n\n5. At any point you can `control+c` the terminal command and restart it\n with new command line arguments (e.g. using the convenience of your\n shell history and editing commands) and then restart the debug\n session in [VS Code](https://code.visualstudio.com/).\n\n## Remote Debugging On Another Host\n\nThe `debugpy-run` utility first looks to find the `debugpy` package in\nyour local `~/.vscode/extensions` directory. If it fails to find that\nthen `debugpy-run` next tries to import `debugpy` globally. This is is\ndone so you can install both `debugpy-run` and `debugpy` on a remote\nheadless server (e.g. where [VS Code](https://code.visualstudio.com/) is\nnot installed) and then debug a program on that server from [VS\nCode](https://code.visualstudio.com/) on your laptop/PC remotely over\nthe network.\n\nSo for example, I may have a program which runs on a server which want\nto debug from [VS Code](https://code.visualstudio.com/) on my laptop. I\nfirst make sure I install the necessary software on the server (you can\nalso do this in the programs virtual environment of course):\n\n````\n$ pipx install debugpy\n$ pipx install debugpy-run\n````\n\nThe start my program on the server using the debugger:\n````\n$ debugpy-run -p :5678 my-program -- --myargs\n````\n\nNOTE: We need to explicitly specify the `:port` for this case so that\nthe port is opened on the external network interface so we can connect\nto it from another machine. By default, `debugpy-run`/`debugpy`\notherwise only accept local connections.\n\nThen I go back to my laptop, ensure I have set up _Remote Attach_\ndebugging configured with host = `my-server` and port = `5678`, then start\ndebugging.\n\nOf course, you could start `debugpy` directly yourself on the server but\nthe `debugpy-run` wrapper is more convenient to use and makes the usage\nconsistent with the familiar way you start `debugpy-run` on your\nlaptop/PC.\n\n## Debugging A Program Running As Root\n\nAnother application of `debugpy-run` is that you can, as your normal\nuser, easily use [VS Code](https://code.visualstudio.com/) to debug a\nprogram you run as root. E.g. run a program using `sudo`:\n\n $ sudo debugpy-run my-program -- --myargs\n\nNow you can just _Remote Attach_ to it in [VS\nCode](https://code.visualstudio.com/) as your normal user.\n\n## Usage\n\nType `debugpy-run -h` to view the usage summary:\n\n```\nusage: debugpy-run [-h] [--listen | -C] [-W] [-p PORT] [-E] [-A] [-r]\n [--log-to PATH | --log-to-stderr]\n [-m MODULE | -c CODE | --pid PID] [-V]\n [program] ...\n\nFinds the \"debugpy\" package within your VSCode Python extension and then runs\nit for \"remote attach\" debugging of the program/module you specify. If not\nfound in extensions, or bundled with this app, then tries to run the\nglobal/venv installed \"debugpy\".\n\npositional arguments:\n program python program to execute and debug\n args remaining arguments to debug\n\noptions:\n -h, --help show this help message and exit\n --listen listen on given port, default=True\n -C, --connect connect to given port rather than listen\n -W, --no-wait do not wait on listen for client, start immediately\n -p PORT, --port PORT [host:]port to use, default=5678\n -E, --no-extension don't use the debugpy bundled in the extension\n -A, --no-app don't use the debugpy bundled in this app\n -r, --run-on-error re-run program/module even on error\n --log-to PATH log to given path\n --log-to-stderr log to stderr\n -m MODULE, --module MODULE\n python module to execute and debug\n -c CODE, --code CODE python code to execute and debug\n --pid PID python pid to attach and debug\n -V, --version output debugpy path and version\n```\n\n## License\n\nCopyright (C) 2021 Mark Blakeney. This program is distributed under the\nterms of the GNU General Public License.\nThis program is free software: you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the\nFree Software Foundation, either version 3 of the License, or any later\nversion.\nThis program is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General\nPublic License at <http://www.gnu.org/licenses/> for more details.\n\n<!-- vim: se ai syn=markdown: -->\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "Finds and runs debugpy for VS Code \"remote attach\" command line debugging",
"version": "1.12",
"project_urls": {
"Homepage": "https://github.com/bulletmark/debugpy-run"
},
"split_keywords": [
"debugpy",
" vscode",
" code",
" ptvsd"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "069d4deb75e7df23c5e1f057b66381afe2bcd63a99d32638765c4ccd07142d5d",
"md5": "8d560e276788713debe61329e2fb8491",
"sha256": "4cec6035de4a9f69c51d5c2d2d2014d5d1be52ee982be3092bdd486e538b45fc"
},
"downloads": -1,
"filename": "debugpy_run-1.12-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8d560e276788713debe61329e2fb8491",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 6969,
"upload_time": "2024-08-03T21:55:51",
"upload_time_iso_8601": "2024-08-03T21:55:51.188835Z",
"url": "https://files.pythonhosted.org/packages/06/9d/4deb75e7df23c5e1f057b66381afe2bcd63a99d32638765c4ccd07142d5d/debugpy_run-1.12-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "afe7343dcddbe4a40d5099b7b1ea09ef838d4be8df87b504b12f7048399104de",
"md5": "8181477bc2742b908921986512d08ef6",
"sha256": "8ea8893a21394a769ed28a0059835d49ab868dc9cc859c9937379da211000a89"
},
"downloads": -1,
"filename": "debugpy_run-1.12.tar.gz",
"has_sig": false,
"md5_digest": "8181477bc2742b908921986512d08ef6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 7293,
"upload_time": "2024-08-03T21:55:52",
"upload_time_iso_8601": "2024-08-03T21:55:52.875832Z",
"url": "https://files.pythonhosted.org/packages/af/e7/343dcddbe4a40d5099b7b1ea09ef838d4be8df87b504b12f7048399104de/debugpy_run-1.12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-03 21:55:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bulletmark",
"github_project": "debugpy-run",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "debugpy-run"
}