Skip to main content

Pseudo terminal support for Windows from Python.

Project description

PyWinpty: Pseudoterminals for Windows in Python

Project License - MIT pypi version conda version download count Downloads PyPI status Windows tests

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 interface and the previous, fallback winpty library.

Dependencies

To compile pywinpty sources, you must have Rust 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):

conda install pywinpty

Using pip:

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.

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

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 as the build backend, which can be installed using pip:

pip install maturin

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

maturin develop

This package depends on the following Rust crates:

  • PyO3: Library used to produce Python bindings from Rust code.
  • WinPTY-rs: Create and spawn processes inside a pseudoterminal in Windows from Rust.
  • 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:

# 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:

pip install pytest pytest-lazy-fixture flaky

All the tests can be executed using the following command

python runtests.py

Changelog

Visit our CHANGELOG 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.

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywinpty-3.0.5.tar.gz (16.2 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pywinpty-3.0.5-cp314-cp314t-win_arm64.whl (814.5 kB view details)

Uploaded CPython 3.14tWindows ARM64

pywinpty-3.0.5-cp314-cp314t-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.14tWindows x86-64

pywinpty-3.0.5-cp314-cp314-win_arm64.whl (815.7 kB view details)

Uploaded CPython 3.14Windows ARM64

pywinpty-3.0.5-cp314-cp314-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.14Windows x86-64

pywinpty-3.0.5-cp313-cp313t-win_arm64.whl (814.5 kB view details)

Uploaded CPython 3.13tWindows ARM64

pywinpty-3.0.5-cp313-cp313t-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.13tWindows x86-64

pywinpty-3.0.5-cp313-cp313-win_arm64.whl (815.5 kB view details)

Uploaded CPython 3.13Windows ARM64

pywinpty-3.0.5-cp313-cp313-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.13Windows x86-64

pywinpty-3.0.5-cp312-cp312-win_arm64.whl (815.9 kB view details)

Uploaded CPython 3.12Windows ARM64

pywinpty-3.0.5-cp312-cp312-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.12Windows x86-64

pywinpty-3.0.5-cp311-cp311-win_arm64.whl (818.4 kB view details)

Uploaded CPython 3.11Windows ARM64

pywinpty-3.0.5-cp311-cp311-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.11Windows x86-64

pywinpty-3.0.5-cp310-cp310-win_arm64.whl (818.1 kB view details)

Uploaded CPython 3.10Windows ARM64

pywinpty-3.0.5-cp310-cp310-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.10Windows x86-64

File details

Details for the file pywinpty-3.0.5.tar.gz.

File metadata

  • Download URL: pywinpty-3.0.5.tar.gz
  • Upload date:
  • Size: 16.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for pywinpty-3.0.5.tar.gz
Algorithm Hash digest
SHA256 61db0db063de9865adbea66db294628f8577f608d9764a4c7d3384eeacc4e81b
MD5 1c6d25a78791cbe710faa3e7242018b0
BLAKE2b-256 a9ef2d27f30c59a67be7025b2d7858c8c2d282b74d66544b2384730b82de74fd

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp314-cp314t-win_arm64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp314-cp314t-win_arm64.whl
  • Upload date:
  • Size: 814.5 kB
  • Tags: CPython 3.14t, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pywinpty-3.0.5-cp314-cp314t-win_arm64.whl
Algorithm Hash digest
SHA256 24366280a8aa677323da87bec729cb3ea3b35367386cece0978bdc6e4695c690
MD5 243066cf986b9c3a5c44ee5fcc33ecb7
BLAKE2b-256 57fdfe2b0db922ba052ce3976a08f3fc05d0c05047c8b4ebb6102e832b8ef563

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp314-cp314t-win_amd64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.14t, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for pywinpty-3.0.5-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 7b566165e0c5fdd6abe167a5ac8b954be6a843eb55a85946576d6bc1dea03d6d
MD5 9681268d5c08038bf39f65a2b019d87d
BLAKE2b-256 3036d98087bce0acaa4cce7f196103cfa7be3f63ce65f52473bb3e38784ae5d9

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp314-cp314-win_arm64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp314-cp314-win_arm64.whl
  • Upload date:
  • Size: 815.7 kB
  • Tags: CPython 3.14, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pywinpty-3.0.5-cp314-cp314-win_arm64.whl
Algorithm Hash digest
SHA256 89c5c6ef08997a3b4b277b214a35fe15cab4dd6d119f0140aa71df5b1168fdbc
MD5 20a3cf984142ba2693f3b7529016f162
BLAKE2b-256 9ddd96d6cbfc6d9ddab5c1c2f92c26545ae8997446a2ba7ee2024cd43c81f49b

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for pywinpty-3.0.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 03bb3c16d691d9242267201830bcd0e64a9b663170e9042bc84b210da9de15ac
MD5 f1e0128dae802eeb46a0b34019151947
BLAKE2b-256 e923f3cd1b1e5fc56517f54452c49f92049e7dd9ffc8a63de22a495581f50d04

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp313-cp313t-win_arm64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp313-cp313t-win_arm64.whl
  • Upload date:
  • Size: 814.5 kB
  • Tags: CPython 3.13t, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for pywinpty-3.0.5-cp313-cp313t-win_arm64.whl
Algorithm Hash digest
SHA256 9c2919a81bc5cfb09b86fc5a002112b2de95ca4304a07413cbeeb746a1307a5c
MD5 187a36033425048f67174e3f1d34688c
BLAKE2b-256 940c6f24f3c0799f502259b24bdf841a99ad2b0d59df5c2525b4e2a286d14be2

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp313-cp313t-win_amd64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp313-cp313t-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.13t, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for pywinpty-3.0.5-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 22ce1b780d89821cc52daf6eac0708af22d93d000ce9c7c07e37489db8594598
MD5 d8e414f55e2488ff4a09fa90e676c77d
BLAKE2b-256 6f1554400049a380582acd1282665c70fcf11e0bd3713679aca78e24c3aae738

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp313-cp313-win_arm64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp313-cp313-win_arm64.whl
  • Upload date:
  • Size: 815.5 kB
  • Tags: CPython 3.13, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for pywinpty-3.0.5-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 2c6008fb2d3774b48693b2fcb7f2cc317ade9dc581289a964ffeeaf81307c9b5
MD5 8ab21aea78c85c41da851a0b040876cf
BLAKE2b-256 3c2ca138491a0afbdb50eb79395577bd326d4b0fbde7209417d1a8087ff2493a

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for pywinpty-3.0.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 48db1b0ad9d0a1b81dcaaa7163a99a7808deaceb0c1b2344716dc1fc090c3c4c
MD5 cba112ec7cb3a226bbc53c4707b44160
BLAKE2b-256 b9f42a464b9893cceb3b3f416356e94fdc3e1bca9476993927e4e6d99fe95382

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp312-cp312-win_arm64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp312-cp312-win_arm64.whl
  • Upload date:
  • Size: 815.9 kB
  • Tags: CPython 3.12, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for pywinpty-3.0.5-cp312-cp312-win_arm64.whl
Algorithm Hash digest
SHA256 e9391c05fbfa7a992a97e831fc6849887b4014a614192e3d984a7ca59592b376
MD5 66e2a8efd144d91666507db1a9e7d251
BLAKE2b-256 6a705b9053004844139ea8bd86209c57ade12b134b2782f383a095784c8531ec

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for pywinpty-3.0.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d62946adf14b15b54c0b8d785f93fe18b04da23f4ad59e2e8c4612646e9abd23
MD5 1f7350c8b59d89e819bb822b5807f985
BLAKE2b-256 4534942cc95ca4e26489875aa8a95192766247a687379ec29543eebe73ec945f

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp311-cp311-win_arm64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp311-cp311-win_arm64.whl
  • Upload date:
  • Size: 818.4 kB
  • Tags: CPython 3.11, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for pywinpty-3.0.5-cp311-cp311-win_arm64.whl
Algorithm Hash digest
SHA256 c2406f54f699eab75953fb75ce805f2ae55a33a957cd070890abd454fb4b7680
MD5 a655c529ed427387e52e7dd3f4df028a
BLAKE2b-256 eefefe23e2229ffec0c10190cef5964f5c9b2dba179d23b69ae537b7ea90bcab

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for pywinpty-3.0.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 af7a8720c78776ddd6259b71dd567944f766a6cd67f8d2887fbc4973967bacda
MD5 a3860650ae2ef20913c05ed17d2e1f9c
BLAKE2b-256 b05c31feb3dd82d1b33ae0bd09ca601edb993d9da1b7f0226b3336d4b4c39e1e

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp310-cp310-win_arm64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp310-cp310-win_arm64.whl
  • Upload date:
  • Size: 818.1 kB
  • Tags: CPython 3.10, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for pywinpty-3.0.5-cp310-cp310-win_arm64.whl
Algorithm Hash digest
SHA256 7dc4046ea8e4d7f0a16dae8dfcaeeda6df7ca3a9330444d2ba5bb96138fe0a91
MD5 ee2c55ae119712d2ce3da2af6631d370
BLAKE2b-256 00d2dee13e67af2300a080dea30d4da8fdb05133a7eebb39171111f0530f7e88

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pywinpty-3.0.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pywinpty-3.0.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b467dcad72365bc2205ed8b6e694e817d71de269d46e56cfe267dfa9d3d30e1b
MD5 514dbfba305789999396d49ea8211b92
BLAKE2b-256 89ff8bd91d4502b48bee0459bc912806fa512111905ab97d317e7cb1201b3542

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page