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.3.tar.gz (31.3 kB 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.3-cp314-cp314t-win_arm64.whl (233.4 kB view details)

Uploaded CPython 3.14tWindows ARM64

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

Uploaded CPython 3.14tWindows x86-64

pywinpty-3.0.3-cp314-cp314-win_arm64.whl (234.2 kB view details)

Uploaded CPython 3.14Windows ARM64

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

Uploaded CPython 3.14Windows x86-64

pywinpty-3.0.3-cp313-cp313t-win_arm64.whl (233.1 kB view details)

Uploaded CPython 3.13tWindows ARM64

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

Uploaded CPython 3.13tWindows x86-64

pywinpty-3.0.3-cp313-cp313-win_arm64.whl (234.6 kB view details)

Uploaded CPython 3.13Windows ARM64

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

Uploaded CPython 3.13Windows x86-64

pywinpty-3.0.3-cp312-cp312-win_arm64.whl (234.9 kB view details)

Uploaded CPython 3.12Windows ARM64

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

Uploaded CPython 3.12Windows x86-64

pywinpty-3.0.3-cp311-cp311-win_arm64.whl (236.2 kB view details)

Uploaded CPython 3.11Windows ARM64

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

Uploaded CPython 3.11Windows x86-64

pywinpty-3.0.3-cp310-cp310-win_arm64.whl (235.7 kB view details)

Uploaded CPython 3.10Windows ARM64

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

Uploaded CPython 3.10Windows x86-64

pywinpty-3.0.3-cp39-cp39-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.9Windows x86-64

File details

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

File metadata

  • Download URL: pywinpty-3.0.3.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pywinpty-3.0.3.tar.gz
Algorithm Hash digest
SHA256 523441dc34d231fb361b4b00f8c99d3f16de02f5005fd544a0183112bcc22412
MD5 1f7f9ff2585a608bcf47eef07f3e84cf
BLAKE2b-256 f75437c7370ba91f579235049dc26cd2c5e657d2a943e01820844ffc81f32176

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp314-cp314t-win_arm64.whl
Algorithm Hash digest
SHA256 c4e9c3dff7d86ba81937438d5819f19f385a39d8f592d4e8af67148ceb4f6ab5
MD5 bf683905f0617c86fb11da383faff288
BLAKE2b-256 0a44dcd184824e21d4620b06c7db9fbb15c3ad0a0f1fa2e6de79969fb82647ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 0c37e224a47a971d1a6e08649a1714dac4f63c11920780977829ed5c8cadead1
MD5 6aae7ae901b195f2fd5baeca12dd4994
BLAKE2b-256 8d545d5e52f4cb75028104ca6faf36c10f9692389b1986d34471663b4ebebd6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp314-cp314-win_arm64.whl
Algorithm Hash digest
SHA256 34789d685fc0d547ce0c8a65e5a70e56f77d732fa6e03c8f74fefb8cbb252019
MD5 6b03d4406f364b7f84b1bb8f870a1fce
BLAKE2b-256 633240a775343ace542cc43ece3f1d1fce454021521ecac41c4c4573081c2336

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 d4b6b7b0fe0cdcd02e956bd57cfe9f4e5a06514eecf3b5ae174da4f951b58be9
MD5 a5e8dd4e06a45e81065a33e85b152ce5
BLAKE2b-256 28882ff917caff61e55f38bcdb27de06ee30597881b2cae44fbba7627be015c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp313-cp313t-win_arm64.whl
Algorithm Hash digest
SHA256 15c7c0b6f8e9d87aabbaff76468dabf6e6121332c40fc1d83548d02a9d6a3759
MD5 89bf70e955b1b182cf7f85934850c58d
BLAKE2b-256 440f7ffa221757a220402bc79fda44044c3f2cc57338d878ab7d622add6f4581

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 3f07a6cf1c1d470d284e614733c3d0f726d2c85e78508ea10a403140c3c0c18a
MD5 45b168a1e55175dd68391e62738ed7c6
BLAKE2b-256 f7ad90a110538696b12b39fd8758a06d70ded899308198ad2305ac68e361126e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 fe1f7911805127c94cf51f89ab14096c6f91ffdcacf993d2da6082b2142a2523
MD5 aabad3b063d685bb7564e182d5f36fe1
BLAKE2b-256 fd50724ed5c38c504d4e58a88a072776a1e880d970789deaeb2b9f7bd9a5141a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9c91dbb026050c77bdcef964e63a4f10f01a639113c4d3658332614544c467ab
MD5 e4676d8eb39044d22d34222c33dbfd5e
BLAKE2b-256 e5cb58d6ed3fd429c96a90ef01ac9a617af10a6d41469219c25e7dc162abbb71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp312-cp312-win_arm64.whl
Algorithm Hash digest
SHA256 15e79d870e18b678fb8a5a6105fd38496b55697c66e6fc0378236026bc4d59e9
MD5 2e000574e7a7e3b75b5731980aae006f
BLAKE2b-256 b9537278223c493ccfe4883239cf06c823c56460a8010e0fc778eef67858dc14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c9081df0e49ffa86d15db4a6ba61530630e48707f987df42c9d3313537e81fc0
MD5 6c9702e498768b30ddb917d8738e4e2a
BLAKE2b-256 7cd4aeb5e1784d2c5bff6e189138a9ca91a090117459cea0c30378e1f2db3d54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp311-cp311-win_arm64.whl
Algorithm Hash digest
SHA256 fbc1e230e5b193eef4431cba3f39996a288f9958f9c9f092c8a961d930ee8f68
MD5 97ff132faeb0d65fc48927d1d969175c
BLAKE2b-256 8d1e8a54166a8c5e4f5cb516514bdf4090be4d51a71e8d9f6d98c0aa00fe45d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dff25a9a6435f527d7c65608a7e62783fc12076e7d44487a4911ee91be5a8ac8
MD5 86b492edcba7b6d78edde2b036fca428
BLAKE2b-256 79c33e75075c7f71735f22b66fab0481f2c98e3a4d58cba55cb50ba29114bcf6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp310-cp310-win_arm64.whl
Algorithm Hash digest
SHA256 340ccacb4d74278a631923794ccd758471cfc8eeeeee4610b280420a17ad1e82
MD5 efb7e60c6a190aa6c360fed16ec90094
BLAKE2b-256 b213a0181cc5c2d5635d3dbc3802b97bc8e3ad4fa7502ccef576651a5e08e54c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pywinpty-3.0.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ff05f12d775b142b11c6fe085129bdd759b61cf7d41da6c745e78e3a1ef5bf40
MD5 7cc62b68779a1f308a36fda9904a7135
BLAKE2b-256 6228a652709bd76ca7533cd1c443b03add9f5051fdf71bc6bdb8801dddd4e7a3

See more details on using hashes here.

File details

Details for the file pywinpty-3.0.3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pywinpty-3.0.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for pywinpty-3.0.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0f10e81d52d7f2c4d927f645f247028e64eaf205a3ed9e64dbd998122108a218
MD5 aea6433d67827fb89afbf953cbaf9f22
BLAKE2b-256 d74857c3d4e63aa93280ad1b1c2b3a5412d9d1fdee9955fa0aef43a84518d31b

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