dap-python


Namedap-python JSON
Version 0.5.0 PyPI version JSON
download
home_pageNone
SummaryClient for Debug Adapter Protocol
upload_time2024-07-20 07:28:07
maintainerNone
docs_urlNone
authorBilly
requires_python<4.0,>=3.10
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # [DAP Client: Debug Adapter Protocol Client for Python](https://tomlin7.github.io/dap/api-reference/)

DAP Client is an up-to-date generic client side implementation of the [Debug Adapter Protocol (DAP)](https://microsoft.github.io/debug-adapter-protocol/) that is used in IDEs, editors and other tools to communicate with different debuggers. The client is not tied to any specific debugger, so it can be used to interact with any debug adapter that implements the DAP protocol, significantly reducing the effort required to build a new debugging tool. For a list of supported debug adapters, see the [official specification](https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/).

## Key Features

- **Sans I/O Implementation**: A protocol-only client that can be integrated into any I/O framework.
- **Abstract Clients**: Ready-to-use threaded and asyncio clients for immediate integration.
- **Flexible Architecture**: Easily extensible to support various debugging scenarios.

## Table of Contents

1. [Installation](#installation)
2. [Quick Start](#quick-start)
3. [Usage Examples](#usage-examples)
4. [API Reference](https://tomlin7.github.io/dap/api-reference/)
5. [License](#license)

## Installation

Install DAP Client using pip:

```bash
pip install dap-client
```

## Quick Start

The following example demonstrates how to use the async client to connect to a [`debugpy`](https://aka.ms/debugpy) debug adapter server that is running on port 1234.

```bash
python -m debugpy --listen localhost:1234 --wait-for-client hello.py
```

```python
import asyncio
from dap import AsyncServer

async def main():
    server = AsyncServer("debugpy", port=1234)
    try:
        await server.start()
    except asyncio.CancelledError:
        await server.stop()

if __name__ == "__main__":
    asyncio.run(main())
```

## Usage Examples

### Using the Sans I/O Client

The sans I/O client allows you to implement your own I/O mechanism:

```python
from dap import Client
from dap.responses import Initialized

client = Client()
client.launch(no_debug=True)

# get the request data
request = client.send()

# send the request using your I/O implementation
# ...

# feed the response data to the client
for result in client.receive(response_data):
    if isinstance(result, Initialized):
        print("The debug adapter is initialized.")
    ...
```

### Using the Threaded Socket IO Client

The threaded client provides a simple interface for synchronous usage:

```python
from dap import ThreadedServer

server = ThreadedServer("debugpy", port=1234)
server.start()
client = server.client

# Use the client synchronously
client.launch()
client.disconnect()
server.stop()
```

### Using the Asyncio Client

The asyncio client offers an asynchronous interface:

```python
import asyncio
from dap import AsyncServer

async def debug_session():
    server = AsyncServer("debugpy", port=1234)
    server.start()
    client = server.client

    client.launch()
    client.disconnect()
    server.stop()

asyncio.run(debug_session())
```

## License

DAP Client is released under the [MIT License](./LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dap-python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Billy",
    "author_email": "billydevbusiness@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/91/bb/e65364b35fcfc2f37cf28e85588e6c57a5b72236d198af55c0a8780fd66f/dap_python-0.5.0.tar.gz",
    "platform": null,
    "description": "# [DAP Client: Debug Adapter Protocol Client for Python](https://tomlin7.github.io/dap/api-reference/)\n\nDAP Client is an up-to-date generic client side implementation of the [Debug Adapter Protocol (DAP)](https://microsoft.github.io/debug-adapter-protocol/) that is used in IDEs, editors and other tools to communicate with different debuggers. The client is not tied to any specific debugger, so it can be used to interact with any debug adapter that implements the DAP protocol, significantly reducing the effort required to build a new debugging tool. For a list of supported debug adapters, see the [official specification](https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/).\n\n## Key Features\n\n- **Sans I/O Implementation**: A protocol-only client that can be integrated into any I/O framework.\n- **Abstract Clients**: Ready-to-use threaded and asyncio clients for immediate integration.\n- **Flexible Architecture**: Easily extensible to support various debugging scenarios.\n\n## Table of Contents\n\n1. [Installation](#installation)\n2. [Quick Start](#quick-start)\n3. [Usage Examples](#usage-examples)\n4. [API Reference](https://tomlin7.github.io/dap/api-reference/)\n5. [License](#license)\n\n## Installation\n\nInstall DAP Client using pip:\n\n```bash\npip install dap-client\n```\n\n## Quick Start\n\nThe following example demonstrates how to use the async client to connect to a [`debugpy`](https://aka.ms/debugpy) debug adapter server that is running on port 1234.\n\n```bash\npython -m debugpy --listen localhost:1234 --wait-for-client hello.py\n```\n\n```python\nimport asyncio\nfrom dap import AsyncServer\n\nasync def main():\n    server = AsyncServer(\"debugpy\", port=1234)\n    try:\n        await server.start()\n    except asyncio.CancelledError:\n        await server.stop()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n## Usage Examples\n\n### Using the Sans I/O Client\n\nThe sans I/O client allows you to implement your own I/O mechanism:\n\n```python\nfrom dap import Client\nfrom dap.responses import Initialized\n\nclient = Client()\nclient.launch(no_debug=True)\n\n# get the request data\nrequest = client.send()\n\n# send the request using your I/O implementation\n# ...\n\n# feed the response data to the client\nfor result in client.receive(response_data):\n    if isinstance(result, Initialized):\n        print(\"The debug adapter is initialized.\")\n    ...\n```\n\n### Using the Threaded Socket IO Client\n\nThe threaded client provides a simple interface for synchronous usage:\n\n```python\nfrom dap import ThreadedServer\n\nserver = ThreadedServer(\"debugpy\", port=1234)\nserver.start()\nclient = server.client\n\n# Use the client synchronously\nclient.launch()\nclient.disconnect()\nserver.stop()\n```\n\n### Using the Asyncio Client\n\nThe asyncio client offers an asynchronous interface:\n\n```python\nimport asyncio\nfrom dap import AsyncServer\n\nasync def debug_session():\n    server = AsyncServer(\"debugpy\", port=1234)\n    server.start()\n    client = server.client\n\n    client.launch()\n    client.disconnect()\n    server.stop()\n\nasyncio.run(debug_session())\n```\n\n## License\n\nDAP Client is released under the [MIT License](./LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Client for Debug Adapter Protocol",
    "version": "0.5.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7ac062e0083bcf114805dff22df31530a985c66955e7939ccdda95bcc102658",
                "md5": "48af1567f2435d73631165d6f3eac995",
                "sha256": "a26fd63fb666d2069c8fc802f1e93e3fadcc2726549896b63a74544bec506d1e"
            },
            "downloads": -1,
            "filename": "dap_python-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "48af1567f2435d73631165d6f3eac995",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 29270,
            "upload_time": "2024-07-20T07:28:05",
            "upload_time_iso_8601": "2024-07-20T07:28:05.632520Z",
            "url": "https://files.pythonhosted.org/packages/f7/ac/062e0083bcf114805dff22df31530a985c66955e7939ccdda95bcc102658/dap_python-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "91bbe65364b35fcfc2f37cf28e85588e6c57a5b72236d198af55c0a8780fd66f",
                "md5": "a531edf7db58140fe6f35af0ba096b28",
                "sha256": "a5ca44a524a61c989b2c95168f4c2473726effbb58eaf2e66232eed92aab90e8"
            },
            "downloads": -1,
            "filename": "dap_python-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a531edf7db58140fe6f35af0ba096b28",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 26250,
            "upload_time": "2024-07-20T07:28:07",
            "upload_time_iso_8601": "2024-07-20T07:28:07.427377Z",
            "url": "https://files.pythonhosted.org/packages/91/bb/e65364b35fcfc2f37cf28e85588e6c57a5b72236d198af55c0a8780fd66f/dap_python-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-20 07:28:07",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "dap-python"
}
        
Elapsed time: 0.91403s