Skip to main content

Pseudo terminal support for Windows from Python.

Reason this release was yanked:

This was a test run release version and not an actual release

Project description

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 and MSVC 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. Additionally, you will require a working installation of Microsoft Visual Studio C/C++ compiler.

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.
  • CXX: Call C++ libraries from Rust.
  • Maturin: Build system to build and publish Rust-based Python packages.
  • Windows: Rust for Windows.

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

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

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-1.0.0_dev0.tar.gz (47.1 kB view details)

Uploaded Source

Built Distributions

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

pywinpty-1.0.0_dev0-cp39-none-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.9Windows x86-64

pywinpty-1.0.0_dev0-cp38-none-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.8Windows x86-64

pywinpty-1.0.0_dev0-cp37-none-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.7Windows x86-64

pywinpty-1.0.0_dev0-cp36-none-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.6Windows x86-64

File details

Details for the file pywinpty-1.0.0_dev0.tar.gz.

File metadata

  • Download URL: pywinpty-1.0.0_dev0.tar.gz
  • Upload date:
  • Size: 47.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for pywinpty-1.0.0_dev0.tar.gz
Algorithm Hash digest
SHA256 ebf746b5a55b87ef8c887ec77dd2fe3b74d3ed651c7028379fa2a47ab4080066
MD5 83c35044a6adbac7b085bed36ef5eec9
BLAKE2b-256 a63bac7c0d849628110d76f92472ecc3ad8ffc1c4abdf78a53c90a1f58723e6b

See more details on using hashes here.

File details

Details for the file pywinpty-1.0.0_dev0-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for pywinpty-1.0.0_dev0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 490ae6dec821fcc4977068b4315c2f8493a10ea3fea2c29b7fd742f0bd488cb1
MD5 8b5056dbb7b42ab221a0a728a96bc3d0
BLAKE2b-256 e640b8fabdef2cf1539bdde608a0678a18981f628f983541f879576b2a293976

See more details on using hashes here.

File details

Details for the file pywinpty-1.0.0_dev0-cp38-none-win_amd64.whl.

File metadata

File hashes

Hashes for pywinpty-1.0.0_dev0-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 8dec687ebf609b6681113d7d6d8923434e267a5359b1aadd9a3d0deadfee6393
MD5 7627de24836e9816efc2890cf711c02c
BLAKE2b-256 d284294c59c44edb2bca9da348669055a64cff58e776d71f6e370937ffd3f492

See more details on using hashes here.

File details

Details for the file pywinpty-1.0.0_dev0-cp37-none-win_amd64.whl.

File metadata

File hashes

Hashes for pywinpty-1.0.0_dev0-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 005ada1b53108908972e62ed9106b567a6e7e36d61701ba7101e1f16cecdb2cc
MD5 111a2cdeb6179ea700dc5391b586cc60
BLAKE2b-256 90ee4ac1c4e64f691c65fbab400f4a95d0e6bd7a496af8cce55dea1cbd09befa

See more details on using hashes here.

File details

Details for the file pywinpty-1.0.0_dev0-cp36-none-win_amd64.whl.

File metadata

File hashes

Hashes for pywinpty-1.0.0_dev0-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 37fdacc66299928275a20e2556c910466c3b4f74ea90a61eb8f4e6fbe87f7aa1
MD5 6fa07a018e8cea3907c5a99ab1eaf78f
BLAKE2b-256 84d261470a45ab67eb26770956f55ebaa2cbfd87263cdfe8e16aec32b1de63a9

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