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.

Release files for pywinpty 3.0.5

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.0.5
File Size Uploaded
pywinpty-3.0.5.tar.gz 16.2 MB Details

Built distributions (wheels)

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

Total release size: 36.6 MB

Release files / pywinpty-3.0.5.tar.gz

Download URL pywinpty-3.0.5.tar.gz
Size 16.2 MB
Tags Source
SHA-256 checksum
How to use checksums
61db0db063de9865adbea66db294628f8577f608d9764a4c7d3384eeacc4e81b
BLAKE2b-256 checksum
How to use checksums
a9ef2d27f30c59a67be7025b2d7858c8c2d282b74d66544b2384730b82de74fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

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

Download URL pywinpty-3.0.5-cp314-cp314t-win_arm64.whl
Size 814.5 kB
Tags CPython 3.14 CPython 3.14 free-threading Windows ARM64
SHA-256 checksum
How to use checksums
24366280a8aa677323da87bec729cb3ea3b35367386cece0978bdc6e4695c690
BLAKE2b-256 checksum
How to use checksums
57fdfe2b0db922ba052ce3976a08f3fc05d0c05047c8b4ebb6102e832b8ef563
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

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

Download URL pywinpty-3.0.5-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
7b566165e0c5fdd6abe167a5ac8b954be6a843eb55a85946576d6bc1dea03d6d
BLAKE2b-256 checksum
How to use checksums
3036d98087bce0acaa4cce7f196103cfa7be3f63ce65f52473bb3e38784ae5d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

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

Download URL pywinpty-3.0.5-cp314-cp314-win_arm64.whl
Size 815.7 kB
Tags CPython 3.14 Windows ARM64
SHA-256 checksum
How to use checksums
89c5c6ef08997a3b4b277b214a35fe15cab4dd6d119f0140aa71df5b1168fdbc
BLAKE2b-256 checksum
How to use checksums
9ddd96d6cbfc6d9ddab5c1c2f92c26545ae8997446a2ba7ee2024cd43c81f49b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

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

Download URL pywinpty-3.0.5-cp314-cp314-win_amd64.whl
Size 2.1 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
03bb3c16d691d9242267201830bcd0e64a9b663170e9042bc84b210da9de15ac
BLAKE2b-256 checksum
How to use checksums
e923f3cd1b1e5fc56517f54452c49f92049e7dd9ffc8a63de22a495581f50d04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / pywinpty-3.0.5-cp313-cp313t-win_arm64.whl

Download URL pywinpty-3.0.5-cp313-cp313t-win_arm64.whl
Size 814.5 kB
Tags CPython 3.13 CPython 3.13 free-threading Windows ARM64
SHA-256 checksum
How to use checksums
9c2919a81bc5cfb09b86fc5a002112b2de95ca4304a07413cbeeb746a1307a5c
BLAKE2b-256 checksum
How to use checksums
940c6f24f3c0799f502259b24bdf841a99ad2b0d59df5c2525b4e2a286d14be2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release files / pywinpty-3.0.5-cp313-cp313t-win_amd64.whl

Download URL pywinpty-3.0.5-cp313-cp313t-win_amd64.whl
Size 2.1 MB
Tags CPython 3.13 CPython 3.13 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
22ce1b780d89821cc52daf6eac0708af22d93d000ce9c7c07e37489db8594598
BLAKE2b-256 checksum
How to use checksums
6f1554400049a380582acd1282665c70fcf11e0bd3713679aca78e24c3aae738
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

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

Download URL pywinpty-3.0.5-cp313-cp313-win_arm64.whl
Size 815.5 kB
Tags CPython 3.13 Windows ARM64
SHA-256 checksum
How to use checksums
2c6008fb2d3774b48693b2fcb7f2cc317ade9dc581289a964ffeeaf81307c9b5
BLAKE2b-256 checksum
How to use checksums
3c2ca138491a0afbdb50eb79395577bd326d4b0fbde7209417d1a8087ff2493a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

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

Download URL pywinpty-3.0.5-cp313-cp313-win_amd64.whl
Size 2.1 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
48db1b0ad9d0a1b81dcaaa7163a99a7808deaceb0c1b2344716dc1fc090c3c4c
BLAKE2b-256 checksum
How to use checksums
b9f42a464b9893cceb3b3f416356e94fdc3e1bca9476993927e4e6d99fe95382
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

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

Download URL pywinpty-3.0.5-cp312-cp312-win_arm64.whl
Size 815.9 kB
Tags CPython 3.12 Windows ARM64
SHA-256 checksum
How to use checksums
e9391c05fbfa7a992a97e831fc6849887b4014a614192e3d984a7ca59592b376
BLAKE2b-256 checksum
How to use checksums
6a705b9053004844139ea8bd86209c57ade12b134b2782f383a095784c8531ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

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

Download URL pywinpty-3.0.5-cp312-cp312-win_amd64.whl
Size 2.1 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
d62946adf14b15b54c0b8d785f93fe18b04da23f4ad59e2e8c4612646e9abd23
BLAKE2b-256 checksum
How to use checksums
4534942cc95ca4e26489875aa8a95192766247a687379ec29543eebe73ec945f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

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

Download URL pywinpty-3.0.5-cp311-cp311-win_arm64.whl
Size 818.4 kB
Tags CPython 3.11 Windows ARM64
SHA-256 checksum
How to use checksums
c2406f54f699eab75953fb75ce805f2ae55a33a957cd070890abd454fb4b7680
BLAKE2b-256 checksum
How to use checksums
eefefe23e2229ffec0c10190cef5964f5c9b2dba179d23b69ae537b7ea90bcab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

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

Download URL pywinpty-3.0.5-cp311-cp311-win_amd64.whl
Size 2.1 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
af7a8720c78776ddd6259b71dd567944f766a6cd67f8d2887fbc4973967bacda
BLAKE2b-256 checksum
How to use checksums
b05c31feb3dd82d1b33ae0bd09ca601edb993d9da1b7f0226b3336d4b4c39e1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

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

Download URL pywinpty-3.0.5-cp310-cp310-win_arm64.whl
Size 818.1 kB
Tags CPython 3.10 Windows ARM64
SHA-256 checksum
How to use checksums
7dc4046ea8e4d7f0a16dae8dfcaeeda6df7ca3a9330444d2ba5bb96138fe0a91
BLAKE2b-256 checksum
How to use checksums
00d2dee13e67af2300a080dea30d4da8fdb05133a7eebb39171111f0530f7e88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.0

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

Download URL pywinpty-3.0.5-cp310-cp310-win_amd64.whl
Size 2.1 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
b467dcad72365bc2205ed8b6e694e817d71de269d46e56cfe267dfa9d3d30e1b
BLAKE2b-256 checksum
How to use checksums
89ff8bd91d4502b48bee0459bc912806fa512111905ab97d317e7cb1201b3542
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release history Release notifications | RSS feed

This release

3.0.5 This release

15 release files

3.0.4

14 release files

3.0.2

9 release files

3.0.1

9 release files

3.0.0

7 release files

2.0.14

6 release files

2.0.13

6 release files

2.0.11

5 release files

2.0.9

6 release files

2.0.8

5 release files

2.0.7

5 release files

2.0.6

5 release files

2.0.5

5 release files

2.0.4

5 release files

2.0.3

5 release files

2.0.2

5 release files

2.0.1

5 release files

2.0.0

5 release files

1.1.6

6 release files

1.1.5

6 release files

1.1.4

5 release files

1.1.3

5 release files

1.1.2

5 release files

1.1.1

5 release files

1.1.0

5 release files

1.0.1

5 release files

1.0.0

5 release files

0.5.7

10 release files

0.5.5

9 release files

0.5.4

7 release files

0.5.3

7 release files

0.5.2

7 release files

0.5.1

7 release files

0.5

7 release files

0.4.1

5 release files

0.4

2 release files

0.3.0

5 release files

0.2.1

5 release files

0.2.0

5 release files

0.1.4

5 release files

0.1.3

5 release files

0.1.2

5 release files

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