METADATA 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. Metadata-Version: 2.4
  2. Name: pywinpty
  3. Version: 3.0.3
  4. Classifier: Development Status :: 5 - Production/Stable
  5. Classifier: Programming Language :: Python
  6. Classifier: License :: OSI Approved :: MIT License
  7. Classifier: Operating System :: Microsoft :: Windows
  8. Classifier: Programming Language :: Python :: Free Threading
  9. Classifier: Programming Language :: Python :: 3
  10. Classifier: Topic :: Terminals
  11. Classifier: Topic :: Terminals :: Terminal Emulators/X Terminals
  12. Classifier: Programming Language :: Rust
  13. License-File: LICENSE.txt
  14. Summary: Pseudo terminal support for Windows from Python.
  15. Keywords: PTY,Windows,pseudo-terminal,PyO3
  16. Author: Edgar Margffoy
  17. Author-email: andfoy@gmail.com
  18. Maintainer-email: Edgar Margffoy <andfoy@gmail.com>
  19. Requires-Python: >=3.9
  20. Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
  21. Project-URL: Changelog, https://github.com/andfoy/pywinpty/blob/main/CHANGELOG.md
  22. Project-URL: Repository, https://github.com/andfoy/pywinpty
  23. # PyWinpty: Pseudoterminals for Windows in Python
  24. [![Project License - MIT](https://img.shields.io/pypi/l/pywinpty.svg)](./LICENSE.txt)
  25. [![pypi version](https://img.shields.io/pypi/v/pywinpty.svg)](https://pypi.org/project/pywinpty/)
  26. [![conda version](https://img.shields.io/conda/vn/conda-forge/pywinpty.svg)](https://www.anaconda.com/download/)
  27. [![download count](https://img.shields.io/conda/dn/conda-forge/pywinpty.svg)](https://www.anaconda.com/download/)
  28. [![Downloads](https://pepy.tech/badge/pywinpty)](https://pepy.tech/project/pywinpty)
  29. [![PyPI status](https://img.shields.io/pypi/status/pywinpty.svg)](https://github.com/spyder-ide/pywinpty)
  30. [![Windows tests](https://github.com/andfoy/pywinpty/actions/workflows/windows_build.yml/badge.svg)](https://github.com/andfoy/pywinpty/actions/workflows/windows_build.yml)
  31. *Copyright © 2017–2022 Spyder Project Contributors*
  32. *Copyright © 2022– Edgar Andrés Margffoy Tuay*
  33. ## Overview
  34. 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](https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-console-conpty/) interface and the previous, fallback [winpty](https://github.com/rprichard/winpty) library.
  35. ## Dependencies
  36. To compile pywinpty sources, you must have [Rust](https://rustup.rs/) installed.
  37. Optionally, you can also have Winpty's C header and library files available on your include path.
  38. ## Installation
  39. You can install this library by using conda or pip package managers, as it follows:
  40. Using conda (Recommended):
  41. ```bash
  42. conda install pywinpty
  43. ```
  44. Using pip:
  45. ```bash
  46. pip install pywinpty
  47. ```
  48. ## Building from source
  49. To build from sources, you will require both a working stable or nightly Rust toolchain with
  50. target `x86_64-pc-windows-msvc`, which can be installed using [rustup](https://rustup.rs/).
  51. Optionally, this library can be linked against winpty library, which you can install using conda-forge:
  52. ```batch
  53. conda install winpty -c conda-forge
  54. ```
  55. If you don't want to use conda, you will need to have the winpty binaries and headers available on your PATH.
  56. Finally, pywinpty uses [Maturin](https://github.com/PyO3/maturin) as the build backend, which can be installed using `pip`:
  57. ```batch
  58. pip install maturin
  59. ```
  60. To test your compilation environment settings, you can build pywinpty sources locally, by
  61. executing:
  62. ```bash
  63. maturin develop
  64. ```
  65. This package depends on the following Rust crates:
  66. * [PyO3](https://github.com/PyO3/pyo3): Library used to produce Python bindings from Rust code.
  67. * [WinPTY-rs](https://github.com/andfoy/winpty-rs): Create and spawn processes inside a pseudoterminal in Windows from Rust.
  68. * [Maturin](https://github.com/PyO3/maturin): Build system to build and publish Rust-based Python packages.
  69. ## Package usage
  70. Pywinpty offers a single python wrapper around winpty library functions.
  71. This implies that using a single object (``winpty.PTY``) it is possible to access to all functionality, as it follows:
  72. ```python
  73. # High level usage using `spawn`
  74. from winpty import PtyProcess
  75. proc = PtyProcess.spawn('python')
  76. proc.write('print("hello, world!")\r\n')
  77. proc.write('exit()\r\n')
  78. while proc.isalive():
  79. print(proc.readline())
  80. # Low level usage using the raw `PTY` object
  81. from winpty import PTY
  82. # Start a new winpty-agent process of size (cols, rows)
  83. cols, rows = 80, 25
  84. process = PTY(cols, rows)
  85. # Spawn a new console process, e.g., CMD
  86. process.spawn(br'C:\windows\system32\cmd.exe')
  87. # Read console output (Unicode)
  88. process.read()
  89. # Write input to console (Unicode)
  90. process.write(b'Text')
  91. # Resize console size
  92. new_cols, new_rows = 90, 30
  93. process.set_size(new_cols, new_rows)
  94. # Know if the process is alive
  95. alive = process.isalive()
  96. # End winpty-agent process
  97. del process
  98. ```
  99. ## Running tests
  100. We use pytest to run tests as it follows (after calling ``maturin develop``), the test suite depends
  101. on pytest-lazy-fixture, which can be installed via pip:
  102. ```batch
  103. pip install pytest pytest-lazy-fixture flaky
  104. ```
  105. All the tests can be executed using the following command
  106. ```bash
  107. python runtests.py
  108. ```
  109. ## Changelog
  110. Visit our [CHANGELOG](CHANGELOG.md) file to learn more about our new features and improvements.
  111. ## Contribution guidelines
  112. 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.
  113. ## Security contact information
  114. To report a security vulnerability, please use the
  115. [Tidelift security contact](https://tidelift.com/security).
  116. Tidelift will coordinate the fix and disclosure.