pywinpty


Namepywinpty JSON
Version 2.0.14 PyPI version JSON
download
home_pageNone
SummaryPseudo terminal support for Windows from Python.
upload_time2024-10-17 16:01:43
maintainerNone
docs_urlNone
authorEdgar Andrés Margffoy Tuay <andfoy@gmail.com>
requires_python>=3.8
licenseMIT
keywords pty pseudo-terminal conpty windows winpty
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyWinpty: Pseudoterminals for Windows in Python

[![Project License - MIT](https://img.shields.io/pypi/l/pywinpty.svg)](./LICENSE.txt)
[![pypi version](https://img.shields.io/pypi/v/pywinpty.svg)](https://pypi.org/project/pywinpty/)
[![conda version](https://img.shields.io/conda/vn/conda-forge/pywinpty.svg)](https://www.anaconda.com/download/)
[![download count](https://img.shields.io/conda/dn/conda-forge/pywinpty.svg)](https://www.anaconda.com/download/)
[![Downloads](https://pepy.tech/badge/pywinpty)](https://pepy.tech/project/pywinpty)
[![PyPI status](https://img.shields.io/pypi/status/pywinpty.svg)](https://github.com/spyder-ide/pywinpty)
[![Windows tests](https://github.com/andfoy/pywinpty/actions/workflows/windows_build.yml/badge.svg)](https://github.com/andfoy/pywinpty/actions/workflows/windows_build.yml)

*Copyright © 2017–2022 Spyder Project Contributors*
*Copyright © 2022– Edgar Andrés Margffoy Tuay*


## Overview

PyWinpty allows creating and communicating with Windows processes that receive input and print outputs via console input and output pipes. PyWinpty supports both the native [ConPTY](https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-console-conpty/) interface and the previous, fallback [winpty](https://github.com/rprichard/winpty) library.


## Dependencies
To compile pywinpty sources, you must have [Rust](https://rustup.rs/) installed.
Optionally, you can also have Winpty's C header and library files available on your include path.


## Installation
You can install this library by using conda or pip package managers, as it follows:

Using conda (Recommended):
```bash
conda install pywinpty
```

Using pip:
```bash
pip install pywinpty
```

## Building from source

To build from sources, you will require both a working stable or nightly Rust toolchain with
target `x86_64-pc-windows-msvc`, which can be installed using [rustup](https://rustup.rs/).

Optionally, this library can be linked against winpty library, which you can install using conda-forge:

```batch
conda install winpty -c conda-forge
```

If you don't want to use conda, you will need to have the winpty binaries and headers available on your PATH.

Finally, pywinpty uses [Maturin](https://github.com/PyO3/maturin) as the build backend, which can be installed using `pip`:

```batch
pip install maturin
```

To test your compilation environment settings, you can build pywinpty sources locally, by
executing:

```bash
maturin develop
```

This package depends on the following Rust crates:

* [PyO3](https://github.com/PyO3/pyo3): Library used to produce Python bindings from Rust code.
* [WinPTY-rs](https://github.com/andfoy/winpty-rs): Create and spawn processes inside a pseudoterminal in Windows from Rust.
* [Maturin](https://github.com/PyO3/maturin): Build system to build and publish Rust-based Python packages.

## Package usage
Pywinpty offers a single python wrapper around winpty library functions.
This implies that using a single object (``winpty.PTY``) it is possible to access to all functionality, as it follows:

```python
# High level usage using `spawn`
from winpty import PtyProcess

proc = PtyProcess.spawn('python')
proc.write('print("hello, world!")\r\n')
proc.write('exit()\r\n')
while proc.isalive():
	print(proc.readline())

# Low level usage using the raw `PTY` object
from winpty import PTY

# Start a new winpty-agent process of size (cols, rows)
cols, rows = 80, 25
process = PTY(cols, rows)

# Spawn a new console process, e.g., CMD
process.spawn(br'C:\windows\system32\cmd.exe')

# Read console output (Unicode)
process.read()

# Write input to console (Unicode)
process.write(b'Text')

# Resize console size
new_cols, new_rows = 90, 30
process.set_size(new_cols, new_rows)

# Know if the process is alive
alive = process.isalive()

# End winpty-agent process
del process
```

## Running tests
We use pytest to run tests as it follows (after calling ``maturin develop``), the test suite depends
on pytest-lazy-fixture, which can be installed via pip:

```batch
pip install pytest pytest-lazy-fixture flaky
```

All the tests can be exceuted using the following command

```bash
python runtests.py
```


## Changelog
Visit our [CHANGELOG](CHANGELOG.md) file to learn more about our new features and improvements.


## Contribution guidelines
We follow PEP8 and PEP257 for pure python packages and Rust to compile extensions. We use MyPy type annotations for all functions and classes declared on this package. Feel free to send a PR or create an issue if you have any problem/question.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pywinpty",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "pty, pseudo-terminal, conpty, windows, winpty",
    "author": "Edgar Andr\u00e9s Margffoy Tuay <andfoy@gmail.com>",
    "author_email": "Edgar Andr\u00e9s Margffoy Tuay <andfoy@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/f1/82/90f8750423cba4b9b6c842df227609fb60704482d7abf6dd47e2babc055a/pywinpty-2.0.14.tar.gz",
    "platform": null,
    "description": "# PyWinpty: Pseudoterminals for Windows in Python\n\n[![Project License - MIT](https://img.shields.io/pypi/l/pywinpty.svg)](./LICENSE.txt)\n[![pypi version](https://img.shields.io/pypi/v/pywinpty.svg)](https://pypi.org/project/pywinpty/)\n[![conda version](https://img.shields.io/conda/vn/conda-forge/pywinpty.svg)](https://www.anaconda.com/download/)\n[![download count](https://img.shields.io/conda/dn/conda-forge/pywinpty.svg)](https://www.anaconda.com/download/)\n[![Downloads](https://pepy.tech/badge/pywinpty)](https://pepy.tech/project/pywinpty)\n[![PyPI status](https://img.shields.io/pypi/status/pywinpty.svg)](https://github.com/spyder-ide/pywinpty)\n[![Windows tests](https://github.com/andfoy/pywinpty/actions/workflows/windows_build.yml/badge.svg)](https://github.com/andfoy/pywinpty/actions/workflows/windows_build.yml)\n\n*Copyright \u00a9 2017\u20132022 Spyder Project Contributors*\n*Copyright \u00a9 2022\u2013 Edgar Andr\u00e9s Margffoy Tuay*\n\n\n## Overview\n\nPyWinpty allows creating and communicating with Windows processes that receive input and print outputs via console input and output pipes. PyWinpty supports both the native [ConPTY](https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-console-conpty/) interface and the previous, fallback [winpty](https://github.com/rprichard/winpty) library.\n\n\n## Dependencies\nTo compile pywinpty sources, you must have [Rust](https://rustup.rs/) installed.\nOptionally, you can also have Winpty's C header and library files available on your include path.\n\n\n## Installation\nYou can install this library by using conda or pip package managers, as it follows:\n\nUsing conda (Recommended):\n```bash\nconda install pywinpty\n```\n\nUsing pip:\n```bash\npip install pywinpty\n```\n\n## Building from source\n\nTo build from sources, you will require both a working stable or nightly Rust toolchain with\ntarget `x86_64-pc-windows-msvc`, which can be installed using [rustup](https://rustup.rs/).\n\nOptionally, this library can be linked against winpty library, which you can install using conda-forge:\n\n```batch\nconda install winpty -c conda-forge\n```\n\nIf you don't want to use conda, you will need to have the winpty binaries and headers available on your PATH.\n\nFinally, pywinpty uses [Maturin](https://github.com/PyO3/maturin) as the build backend, which can be installed using `pip`:\n\n```batch\npip install maturin\n```\n\nTo test your compilation environment settings, you can build pywinpty sources locally, by\nexecuting:\n\n```bash\nmaturin develop\n```\n\nThis package depends on the following Rust crates:\n\n* [PyO3](https://github.com/PyO3/pyo3): Library used to produce Python bindings from Rust code.\n* [WinPTY-rs](https://github.com/andfoy/winpty-rs): Create and spawn processes inside a pseudoterminal in Windows from Rust.\n* [Maturin](https://github.com/PyO3/maturin): Build system to build and publish Rust-based Python packages.\n\n## Package usage\nPywinpty offers a single python wrapper around winpty library functions.\nThis implies that using a single object (``winpty.PTY``) it is possible to access to all functionality, as it follows:\n\n```python\n# High level usage using `spawn`\nfrom winpty import PtyProcess\n\nproc = PtyProcess.spawn('python')\nproc.write('print(\"hello, world!\")\\r\\n')\nproc.write('exit()\\r\\n')\nwhile proc.isalive():\n\tprint(proc.readline())\n\n# Low level usage using the raw `PTY` object\nfrom winpty import PTY\n\n# Start a new winpty-agent process of size (cols, rows)\ncols, rows = 80, 25\nprocess = PTY(cols, rows)\n\n# Spawn a new console process, e.g., CMD\nprocess.spawn(br'C:\\windows\\system32\\cmd.exe')\n\n# Read console output (Unicode)\nprocess.read()\n\n# Write input to console (Unicode)\nprocess.write(b'Text')\n\n# Resize console size\nnew_cols, new_rows = 90, 30\nprocess.set_size(new_cols, new_rows)\n\n# Know if the process is alive\nalive = process.isalive()\n\n# End winpty-agent process\ndel process\n```\n\n## Running tests\nWe use pytest to run tests as it follows (after calling ``maturin develop``), the test suite depends\non pytest-lazy-fixture, which can be installed via pip:\n\n```batch\npip install pytest pytest-lazy-fixture flaky\n```\n\nAll the tests can be exceuted using the following command\n\n```bash\npython runtests.py\n```\n\n\n## Changelog\nVisit our [CHANGELOG](CHANGELOG.md) file to learn more about our new features and improvements.\n\n\n## Contribution guidelines\nWe follow PEP8 and PEP257 for pure python packages and Rust to compile extensions. We use MyPy type annotations for all functions and classes declared on this package. Feel free to send a PR or create an issue if you have any problem/question.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Pseudo terminal support for Windows from Python.",
    "version": "2.0.14",
    "project_urls": {
        "Source Code": "https://github.com/spyder-ide/pywinpty"
    },
    "split_keywords": [
        "pty",
        " pseudo-terminal",
        " conpty",
        " windows",
        " winpty"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "070956376af256eab8cc5f8982a3b138d387136eca27fa1a8a68660e8ed59e4b",
                "md5": "2427fc403d8f980b1a6398324acb6eeb",
                "sha256": "0b149c2918c7974f575ba79f5a4aad58bd859a52fa9eb1296cc22aa412aa411f"
            },
            "downloads": -1,
            "filename": "pywinpty-2.0.14-cp310-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "2427fc403d8f980b1a6398324acb6eeb",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.8",
            "size": 1397115,
            "upload_time": "2024-10-17T16:04:46",
            "upload_time_iso_8601": "2024-10-17T16:04:46.736973Z",
            "url": "https://files.pythonhosted.org/packages/07/09/56376af256eab8cc5f8982a3b138d387136eca27fa1a8a68660e8ed59e4b/pywinpty-2.0.14-cp310-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bee2af1a99c0432e4e58c9ac8e334ee191790ec9793d33559189b9d2069bdc1d",
                "md5": "462ccae765bc89620cf76991f13d6745",
                "sha256": "cf2a43ac7065b3e0dc8510f8c1f13a75fb8fde805efa3b8cff7599a1ef497bc7"
            },
            "downloads": -1,
            "filename": "pywinpty-2.0.14-cp311-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "462ccae765bc89620cf76991f13d6745",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.8",
            "size": 1397223,
            "upload_time": "2024-10-17T16:04:33",
            "upload_time_iso_8601": "2024-10-17T16:04:33.080696Z",
            "url": "https://files.pythonhosted.org/packages/be/e2/af1a99c0432e4e58c9ac8e334ee191790ec9793d33559189b9d2069bdc1d/pywinpty-2.0.14-cp311-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ad79759ae767a3b78d340446efd54dd1fe4f7dafa4fc7be96ed757e44bcdba54",
                "md5": "fffc3d7df42be6335ce5d938309ae2a6",
                "sha256": "55dad362ef3e9408ade68fd173e4f9032b3ce08f68cfe7eacb2c263ea1179737"
            },
            "downloads": -1,
            "filename": "pywinpty-2.0.14-cp312-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "fffc3d7df42be6335ce5d938309ae2a6",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.8",
            "size": 1397207,
            "upload_time": "2024-10-17T16:04:14",
            "upload_time_iso_8601": "2024-10-17T16:04:14.633153Z",
            "url": "https://files.pythonhosted.org/packages/ad/79/759ae767a3b78d340446efd54dd1fe4f7dafa4fc7be96ed757e44bcdba54/pywinpty-2.0.14-cp312-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7d34b77b3c209bf2eaa6455390c8d5449241637f5957f41636a2204065d52bfa",
                "md5": "4227262fde7291df269c577cf1c6b6b2",
                "sha256": "074fb988a56ec79ca90ed03a896d40707131897cefb8f76f926e3834227f2819"
            },
            "downloads": -1,
            "filename": "pywinpty-2.0.14-cp313-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "4227262fde7291df269c577cf1c6b6b2",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": ">=3.8",
            "size": 1396698,
            "upload_time": "2024-10-17T16:04:15",
            "upload_time_iso_8601": "2024-10-17T16:04:15.172830Z",
            "url": "https://files.pythonhosted.org/packages/7d/34/b77b3c209bf2eaa6455390c8d5449241637f5957f41636a2204065d52bfa/pywinpty-2.0.14-cp313-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d8ef85e1b0ef7864fa2c579b1c1efce92c5f6fa238c8e73cf9f53deee08f8605",
                "md5": "9772fa0dec1a24b271d0f98704d370a9",
                "sha256": "5725fd56f73c0531ec218663bd8c8ff5acc43c78962fab28564871b5fce053fd"
            },
            "downloads": -1,
            "filename": "pywinpty-2.0.14-cp39-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "9772fa0dec1a24b271d0f98704d370a9",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.8",
            "size": 1397396,
            "upload_time": "2024-10-17T16:05:30",
            "upload_time_iso_8601": "2024-10-17T16:05:30.319212Z",
            "url": "https://files.pythonhosted.org/packages/d8/ef/85e1b0ef7864fa2c579b1c1efce92c5f6fa238c8e73cf9f53deee08f8605/pywinpty-2.0.14-cp39-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f18290f8750423cba4b9b6c842df227609fb60704482d7abf6dd47e2babc055a",
                "md5": "246129dd26269ee192acb88d079dc576",
                "sha256": "18bd9529e4a5daf2d9719aa17788ba6013e594ae94c5a0c27e83df3278b0660e"
            },
            "downloads": -1,
            "filename": "pywinpty-2.0.14.tar.gz",
            "has_sig": false,
            "md5_digest": "246129dd26269ee192acb88d079dc576",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 27769,
            "upload_time": "2024-10-17T16:01:43",
            "upload_time_iso_8601": "2024-10-17T16:01:43.197066Z",
            "url": "https://files.pythonhosted.org/packages/f1/82/90f8750423cba4b9b6c842df227609fb60704482d7abf6dd47e2babc055a/pywinpty-2.0.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-17 16:01:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "spyder-ide",
    "github_project": "pywinpty",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pywinpty"
}
        
Elapsed time: 0.35254s