Skip to main content

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.

Metadata

Release files for pywinpty 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pywinpty 3.1.0
File Size Uploaded Provenance
pywinpty-3.1.0.tar.gz 16.2 MB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for pywinpty 3.1.0
File
pywinpty-3.1.0-cp315-cp315t-win_arm64.whl CPython 3.15 CPython 3.15 free-threading Windows ARM64 Details
pywinpty-3.1.0-cp315-cp315t-win_amd64.whl CPython 3.15 CPython 3.15 free-threading Windows x86-64 Details
pywinpty-3.1.0-cp315-cp315-win_arm64.whl CPython 3.15 CPython 3.15 Windows ARM64 Details
pywinpty-3.1.0-cp315-cp315-win_amd64.whl CPython 3.15 CPython 3.15 Windows x86-64 Details
pywinpty-3.1.0-cp314-cp314t-win_arm64.whl CPython 3.14 CPython 3.14 free-threading Windows ARM64 Details
pywinpty-3.1.0-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details
pywinpty-3.1.0-cp314-cp314-win_arm64.whl CPython 3.14 CPython 3.14 Windows ARM64 Details
pywinpty-3.1.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
pywinpty-3.1.0-cp313-cp313-win_arm64.whl CPython 3.13 CPython 3.13 Windows ARM64 Details
pywinpty-3.1.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
pywinpty-3.1.0-cp312-cp312-win_arm64.whl CPython 3.12 CPython 3.12 Windows ARM64 Details
pywinpty-3.1.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
pywinpty-3.1.0-cp311-cp311-win_arm64.whl CPython 3.11 CPython 3.11 Windows ARM64 Details
pywinpty-3.1.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
pywinpty-3.1.0-cp310-cp310-win_arm64.whl CPython 3.10 CPython 3.10 Windows ARM64 Details
pywinpty-3.1.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details

Total release size: 39.7 MB

Release files / pywinpty-3.1.0.tar.gz

Download URL pywinpty-3.1.0.tar.gz
Size 16.2 MB
Tags Source
SHA-256 checksum
How to use checksums
14595b68054d61f2f1e90cc2b30be47be201de200ae1851c433d8cded101bce0
BLAKE2b-256 checksum
How to use checksums
1c736bc452ae57820feb8bb6d993ecd91e24643d8f9a05409e8f83c56c852f04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.0

Release files / pywinpty-3.1.0-cp315-cp315t-win_arm64.whl

Download URL pywinpty-3.1.0-cp315-cp315t-win_arm64.whl
Size 830.4 kB
Tags CPython 3.15 CPython 3.15 free-threading Windows ARM64
SHA-256 checksum
How to use checksums
751d0c727d0e81a246aba722cf0dcb2155fd6bc7b82574b1432f81256157ec73
BLAKE2b-256 checksum
How to use checksums
a619dece20a98f989c0eb8e35a2300e0357b98a1e8b5e3ea0149fad62ed16c12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / pywinpty-3.1.0-cp315-cp315t-win_amd64.whl

Download URL pywinpty-3.1.0-cp315-cp315t-win_amd64.whl
Size 2.1 MB
Tags CPython 3.15 CPython 3.15 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
c08a2e5fa7a62f31b5965f0be1b92c67394cd5f75dc0a033d45fadc597f0640d
BLAKE2b-256 checksum
How to use checksums
e94a6d9048716dbf969b31ffacbf8a0a0ff944196807957826601cdc995b4afa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / pywinpty-3.1.0-cp315-cp315-win_arm64.whl

Download URL pywinpty-3.1.0-cp315-cp315-win_arm64.whl
Size 830.5 kB
Tags CPython 3.15 Windows ARM64
SHA-256 checksum
How to use checksums
714e8aa138bc61dcfd26c139d8cb8e7b954ea5c09c98bb014ab9b1f5741e289c
BLAKE2b-256 checksum
How to use checksums
d2f41b91263807eaf5a98b4c00b3c144576e3d4bd8e093d40e447013c3745334
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / pywinpty-3.1.0-cp315-cp315-win_amd64.whl

Download URL pywinpty-3.1.0-cp315-cp315-win_amd64.whl
Size 2.1 MB
Tags CPython 3.15 Windows x86-64
SHA-256 checksum
How to use checksums
188923081eea840c15f37c54a29ad6871b04fddf8fbf1c4acf317d0e27bd9cac
BLAKE2b-256 checksum
How to use checksums
47e826d10fc6c02628fc6052f820bad0a55531ba7d937f0952233bcbaaba85b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / pywinpty-3.1.0-cp314-cp314t-win_arm64.whl

Download URL pywinpty-3.1.0-cp314-cp314t-win_arm64.whl
Size 830.1 kB
Tags CPython 3.14 CPython 3.14 free-threading Windows ARM64
SHA-256 checksum
How to use checksums
98f00e50639e9edb740eb6eedd6c0ab82959f9633029db59363d06973d00ac0d
BLAKE2b-256 checksum
How to use checksums
425a4155005f0879ae4f348567abd175bd68902e8b036e39d86e50a025f7a5b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / pywinpty-3.1.0-cp314-cp314t-win_amd64.whl

Download URL pywinpty-3.1.0-cp314-cp314t-win_amd64.whl
Size 2.1 MB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
08afc428ec8765f2b8b9a9954727e1dafbefcb5912acc65952007779449650a1
BLAKE2b-256 checksum
How to use checksums
168ce3a2921b39cbf9e27c67787996bdd99ba0acdf0d3f4c3a12b71e7e19a482
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / pywinpty-3.1.0-cp314-cp314-win_arm64.whl

Download URL pywinpty-3.1.0-cp314-cp314-win_arm64.whl
Size 830.2 kB
Tags CPython 3.14 Windows ARM64
SHA-256 checksum
How to use checksums
44918ef8bc408fbf52f54db9b8c33370aee0a59cee76b071a4b4f41ad5ed89c8
BLAKE2b-256 checksum
How to use checksums
0e6abafc3af2a864d9b681dc6dfcf46cf5de0b070276c9a0baec30c1201e88be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / pywinpty-3.1.0-cp314-cp314-win_amd64.whl

Download URL pywinpty-3.1.0-cp314-cp314-win_amd64.whl
Size 2.1 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
d01178e9391366bc3325b4c49068cfce95d10d416f6ade62140b274741bc11e0
BLAKE2b-256 checksum
How to use checksums
876a0c049de9e2d7d6b637aa36ee3825e643d5dba0a4890881652a6685bbaead
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / pywinpty-3.1.0-cp313-cp313-win_arm64.whl

Download URL pywinpty-3.1.0-cp313-cp313-win_arm64.whl
Size 830.3 kB
Tags CPython 3.13 Windows ARM64
SHA-256 checksum
How to use checksums
3670cd05447e56836301620e92dfdd3ef40408cfb59f2ce6290c66c9986b53ef
BLAKE2b-256 checksum
How to use checksums
efe8c6146bf22daaf9a6457902a99caa5da386d1ba3e82622fa2acc8b2d4e921
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Release files / pywinpty-3.1.0-cp313-cp313-win_amd64.whl

Download URL pywinpty-3.1.0-cp313-cp313-win_amd64.whl
Size 2.1 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
cc51bc690f58a969eab7dcc8d070321187ed47d5f076edc3b4a56076b38831f3
BLAKE2b-256 checksum
How to use checksums
3e0bfc29cd8d1db4b17fb83074cb763568728a5f21a80e91a481a967e2482f67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pywinpty-3.1.0-cp312-cp312-win_arm64.whl

Download URL pywinpty-3.1.0-cp312-cp312-win_arm64.whl
Size 830.6 kB
Tags CPython 3.12 Windows ARM64
SHA-256 checksum
How to use checksums
31c9928935046abe20475392493b5074b3d966ea85c63cc83e939fb54cd9edfe
BLAKE2b-256 checksum
How to use checksums
9edb957d5f4d64239720d01839c86f1c9c52aab0dbd4c25767889904bcda7d63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / pywinpty-3.1.0-cp312-cp312-win_amd64.whl

Download URL pywinpty-3.1.0-cp312-cp312-win_amd64.whl
Size 2.1 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
df249a2d942cbeef71f736119e96d246ea968fe9723dd25e8e439ba81814f85e
BLAKE2b-256 checksum
How to use checksums
4f89ac7ce4b13b3131c1344c3af4053d70219e92d4c8e35b7182a9365432f7a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / pywinpty-3.1.0-cp311-cp311-win_arm64.whl

Download URL pywinpty-3.1.0-cp311-cp311-win_arm64.whl
Size 833.0 kB
Tags CPython 3.11 Windows ARM64
SHA-256 checksum
How to use checksums
6cf46443732493e78efb130ac525df117e49db493eee1fc98ba9db70be410c96
BLAKE2b-256 checksum
How to use checksums
57ddfd3617b3af749ba66227d280e637474f49ce8acbceb87a7ee8e55858bd8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.0

Release files / pywinpty-3.1.0-cp311-cp311-win_amd64.whl

Download URL pywinpty-3.1.0-cp311-cp311-win_amd64.whl
Size 2.1 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
7ed683c7e4f31d92084d062478bf4aa9066a983c92700cb6ac6e4d5ca218723c
BLAKE2b-256 checksum
How to use checksums
ee49d78b094428f10f3365dc9ef48c32e0bb336b2e03c8ab3f786ac5c2ccff99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / pywinpty-3.1.0-cp310-cp310-win_arm64.whl

Download URL pywinpty-3.1.0-cp310-cp310-win_arm64.whl
Size 833.0 kB
Tags CPython 3.10 Windows ARM64
SHA-256 checksum
How to use checksums
cf8812cd0f30de7163cf479114e17d31d03a480c6fe2c7e1c42f367c507f0c1b
BLAKE2b-256 checksum
How to use checksums
0bcbddc5ab87e9b7507a4873557b258fde447cb57a0023e8380d144faf9fdd77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.0

Release files / pywinpty-3.1.0-cp310-cp310-win_amd64.whl

Download URL pywinpty-3.1.0-cp310-cp310-win_amd64.whl
Size 2.1 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
04c6ea57c118f920d03e008dea7a06a8b735e4dd41fe7df8414e9b658f719aed
BLAKE2b-256 checksum
How to use checksums
243e0fa92c53159d6d974205f7dacf4b0b0f00d1828152961201c94a9d93c3e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Security for pywinpty 3.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.1.0 This release

17 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page