spyder-ide/pywinpty

Name: pywinpty

Owner: Spyder IDE

Description: Python bindings for the winpty pseudo terminal library

Created: 2017-06-02 21:13:42.0

Updated: 2018-05-24 02:58:04.0

Pushed: 2018-05-24 02:58:37.0

Homepage:

Size: 171

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

pywinpty

Python bindings for the winpty pseudo terminal library. It allows to create and communicate with Windows processes that print outputs and recieve inputs via console input and output pipes.

Project details

Project License pypi version Join the chat at https://gitter.im/spyder-ide/public OpenCollective Backers OpenCollective Sponsors

Build status

Build status Coverage Status codecov


Important Announcement: Spyder is unfunded!

Since mid November/2017, Anaconda, Inc has stopped funding Spyder development, after doing it for the past 18 months. Because of that, development will focus from now on maintaining Spyder 3 at a much slower pace than before.

If you want to contribute to maintain Spyder, please consider donating at

https://opencollective.com/spyder

We appreciate all the help you can provide us and can't thank you enough for supporting the work of Spyder devs and Spyder development.

If you want to know more about this, please read this page.


Dependencies

To compile pywinpty sources, you must have Cython and MSYS2/MinGW-w64 installed (Alongside the corresponding Python MSVC Runtime). You must 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):

a install pywinpty

Using pip:

install pywinpty
Building from sources

To build from sources, we recommend to use conda to install the following packages:

a install --file requirements.txt

Make sure that you are installing packages from the default channel. If you don't want to use conda, you will need to have the MSYS2/MinGW-w64-flavoured GCC compiler available on your PATH.

You will need to setup the following environment variables:

Conda compilation:
LIBRARY_INC=<Path to your anaconda installation>\envs\<environment name>\Library\include
LIBRARY_LIB=<Path to your anaconda installation>\envs\<environment name>\Library\lib
Manual compilation:
LIBRARY_INC=<Path to the folder that contains wintpty headers>
LIBRARY_LIB=<Path to the folder that contains wintpty library files>

To test your compilation environment settings, you can build pywinpty Cython sources locally, by executing:

on setup.py build_ext -i --compiler=mingw32

If everything works correctly, you can install winpty by using pip:

install -U .
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 functionallity, as it follows:

gh level usage using `spawn`
 winpty import PtyProcess

 = PtyProcess.spawn('python')
.write('print("hello, world!")\r\n')
.write('exit()\r\n')
e proc.isalive():
print(proc.readline())

w level usage using the raw `PTY` object
 winpty import PTY

art a new winpty-agent process of size (cols, rows)
, rows = 80, 25
ess = PTY(cols, rows)

awn a new console process, e.g., CMD
ess.spawn(ur'C:\windows\system32\cmd.exe')

ad console output (Unicode)
ess.read()

ite input to console (Unicode)
ess.write(u'Text')

size console size
cols, new_rows = 90, 30
ess.set_size(new_cols, new_rows)

ow if the process is alive
e = process.isalive()

ose console pipes
ess.close()

d winpty-agent process
process
Changelog

Visit our CHANGELOG file to know more about our new features and improvements.

Contribution guidelines

We follow PEP8 and PEP257 for pure python packages and Cython/VS to compile extensions. 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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.