Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PyWinpty: Pseudoterminals for Windows in Python

Project License - MIT pypi version conda version download count Downloads OpenCollective Backers Join the chat at https://gitter.im/spyder-ide/public
PyPI status Windows tests

Copyright © 2017– Spyder Project Contributors

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 exceuted 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.

Backers

Support us with a monthly donation and help us continue our activities.

Backers

Sponsors

Become a sponsor to get your logo on our README on Github.

Sponsors

Metadata

Release files for pywinpty 2.0.1_pre0

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 2.0.1_pre0
File Size Uploaded Provenance
pywinpty-2.0.1_pre0.tar.gz 22.5 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for pywinpty 2.0.1_pre0
File
pywinpty-2.0.1_pre0-cp310-none-win_amd64.whl CPython 3.10 none Windows x86-64 Details
pywinpty-2.0.1_pre0-cp39-none-win_amd64.whl CPython 3.9 none Windows x86-64 Details
pywinpty-2.0.1_pre0-cp38-none-win_amd64.whl CPython 3.8 none Windows x86-64 Details
pywinpty-2.0.1_pre0-cp37-none-win_amd64.whl CPython 3.7 none Windows x86-64 Details

Total release size: 5.6 MB

Release files / pywinpty-2.0.1_pre0.tar.gz

Download URL pywinpty-2.0.1_pre0.tar.gz
Size 22.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5d295f07ef21d84f556f9c1399a3cd2c7b49a0b5b427a8695b194c564dcdb3f3
BLAKE2b-256 checksum
How to use checksums
ef8c8e5fae9963f52f165407c21f313825f551b96830d1ff4c8eec1e4585aee3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / pywinpty-2.0.1_pre0-cp310-none-win_amd64.whl

Download URL pywinpty-2.0.1_pre0-cp310-none-win_amd64.whl
Size 1.4 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
f99cf3110be2efa403cc28013ab73085c5f5294c42407067851eb48ae258ce92
BLAKE2b-256 checksum
How to use checksums
facfccbdf8e1c945cab440656e4e4f68dc343589b2cf58c453e7a9612c455019
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.6

Release files / pywinpty-2.0.1_pre0-cp39-none-win_amd64.whl

Download URL pywinpty-2.0.1_pre0-cp39-none-win_amd64.whl
Size 1.4 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
30b2c83f7fdb23e8b494dfff12875508dde35079c006dcf7a962f138549ca5d0
BLAKE2b-256 checksum
How to use checksums
132239d03b1881b6f70360f6748002476b9d3b194a8bb4e409a6d26bb0da642f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.6

Release files / pywinpty-2.0.1_pre0-cp38-none-win_amd64.whl

Download URL pywinpty-2.0.1_pre0-cp38-none-win_amd64.whl
Size 1.4 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
4905fb08dac00867e05592a440b97a893d6ed294aa5560091d2a683ae571b07c
BLAKE2b-256 checksum
How to use checksums
cac6e0a8e2d906d9e7365640b879956339c4ed12b0f72589ea128c40b774401b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.6

Release files / pywinpty-2.0.1_pre0-cp37-none-win_amd64.whl

Download URL pywinpty-2.0.1_pre0-cp37-none-win_amd64.whl
Size 1.4 MB
Tags CPython 3.7 Windows x86-64
SHA-256 checksum
How to use checksums
d68d3e784a3974199d3b9a461c63e3b44c676c83da6795824abc671569a8f8ac
BLAKE2b-256 checksum
How to use checksums
7f536f4c811303896e4ad5b5b2b4a11615e96025a62f02387eb9e540c4ab0614
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.6

Security for pywinpty 2.0.1_pre0

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