pywinpty 3.0.1__cp313-cp313-win_amd64.whl → 3.0.3__cp313-cp313-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pywinpty-3.0.3.dist-info/METADATA +162 -0
- pywinpty-3.0.3.dist-info/RECORD +16 -0
- {pywinpty-3.0.1.dist-info → pywinpty-3.0.3.dist-info}/WHEEL +1 -1
- winpty/OpenConsole.exe +0 -0
- winpty/conpty.dll +0 -0
- winpty/ptyprocess.py +2 -4
- winpty/tests/test_pty.py +5 -2
- winpty/tests/test_ptyprocess.py +6 -1
- winpty/winpty.cp313-win_amd64.pyd +0 -0
- winpty/winpty.pyi +20 -36
- pywinpty-3.0.1.dist-info/METADATA +0 -6
- pywinpty-3.0.1.dist-info/RECORD +0 -16
- {pywinpty-3.0.1.dist-info → pywinpty-3.0.3.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -0,0 +1,162 @@
|
|
|
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
|
+
|
|
24
|
+
# PyWinpty: Pseudoterminals for Windows in Python
|
|
25
|
+
|
|
26
|
+
[](./LICENSE.txt)
|
|
27
|
+
[](https://pypi.org/project/pywinpty/)
|
|
28
|
+
[](https://www.anaconda.com/download/)
|
|
29
|
+
[](https://www.anaconda.com/download/)
|
|
30
|
+
[](https://pepy.tech/project/pywinpty)
|
|
31
|
+
[](https://github.com/spyder-ide/pywinpty)
|
|
32
|
+
[](https://github.com/andfoy/pywinpty/actions/workflows/windows_build.yml)
|
|
33
|
+
|
|
34
|
+
*Copyright © 2017–2022 Spyder Project Contributors*
|
|
35
|
+
*Copyright © 2022– Edgar Andrés Margffoy Tuay*
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## Overview
|
|
39
|
+
|
|
40
|
+
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.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## Dependencies
|
|
44
|
+
To compile pywinpty sources, you must have [Rust](https://rustup.rs/) installed.
|
|
45
|
+
Optionally, you can also have Winpty's C header and library files available on your include path.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
You can install this library by using conda or pip package managers, as it follows:
|
|
50
|
+
|
|
51
|
+
Using conda (Recommended):
|
|
52
|
+
```bash
|
|
53
|
+
conda install pywinpty
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Using pip:
|
|
57
|
+
```bash
|
|
58
|
+
pip install pywinpty
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Building from source
|
|
62
|
+
|
|
63
|
+
To build from sources, you will require both a working stable or nightly Rust toolchain with
|
|
64
|
+
target `x86_64-pc-windows-msvc`, which can be installed using [rustup](https://rustup.rs/).
|
|
65
|
+
|
|
66
|
+
Optionally, this library can be linked against winpty library, which you can install using conda-forge:
|
|
67
|
+
|
|
68
|
+
```batch
|
|
69
|
+
conda install winpty -c conda-forge
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
If you don't want to use conda, you will need to have the winpty binaries and headers available on your PATH.
|
|
73
|
+
|
|
74
|
+
Finally, pywinpty uses [Maturin](https://github.com/PyO3/maturin) as the build backend, which can be installed using `pip`:
|
|
75
|
+
|
|
76
|
+
```batch
|
|
77
|
+
pip install maturin
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
To test your compilation environment settings, you can build pywinpty sources locally, by
|
|
81
|
+
executing:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
maturin develop
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This package depends on the following Rust crates:
|
|
88
|
+
|
|
89
|
+
* [PyO3](https://github.com/PyO3/pyo3): Library used to produce Python bindings from Rust code.
|
|
90
|
+
* [WinPTY-rs](https://github.com/andfoy/winpty-rs): Create and spawn processes inside a pseudoterminal in Windows from Rust.
|
|
91
|
+
* [Maturin](https://github.com/PyO3/maturin): Build system to build and publish Rust-based Python packages.
|
|
92
|
+
|
|
93
|
+
## Package usage
|
|
94
|
+
Pywinpty offers a single python wrapper around winpty library functions.
|
|
95
|
+
This implies that using a single object (``winpty.PTY``) it is possible to access to all functionality, as it follows:
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
# High level usage using `spawn`
|
|
99
|
+
from winpty import PtyProcess
|
|
100
|
+
|
|
101
|
+
proc = PtyProcess.spawn('python')
|
|
102
|
+
proc.write('print("hello, world!")\r\n')
|
|
103
|
+
proc.write('exit()\r\n')
|
|
104
|
+
while proc.isalive():
|
|
105
|
+
print(proc.readline())
|
|
106
|
+
|
|
107
|
+
# Low level usage using the raw `PTY` object
|
|
108
|
+
from winpty import PTY
|
|
109
|
+
|
|
110
|
+
# Start a new winpty-agent process of size (cols, rows)
|
|
111
|
+
cols, rows = 80, 25
|
|
112
|
+
process = PTY(cols, rows)
|
|
113
|
+
|
|
114
|
+
# Spawn a new console process, e.g., CMD
|
|
115
|
+
process.spawn(br'C:\windows\system32\cmd.exe')
|
|
116
|
+
|
|
117
|
+
# Read console output (Unicode)
|
|
118
|
+
process.read()
|
|
119
|
+
|
|
120
|
+
# Write input to console (Unicode)
|
|
121
|
+
process.write(b'Text')
|
|
122
|
+
|
|
123
|
+
# Resize console size
|
|
124
|
+
new_cols, new_rows = 90, 30
|
|
125
|
+
process.set_size(new_cols, new_rows)
|
|
126
|
+
|
|
127
|
+
# Know if the process is alive
|
|
128
|
+
alive = process.isalive()
|
|
129
|
+
|
|
130
|
+
# End winpty-agent process
|
|
131
|
+
del process
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Running tests
|
|
135
|
+
We use pytest to run tests as it follows (after calling ``maturin develop``), the test suite depends
|
|
136
|
+
on pytest-lazy-fixture, which can be installed via pip:
|
|
137
|
+
|
|
138
|
+
```batch
|
|
139
|
+
pip install pytest pytest-lazy-fixture flaky
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
All the tests can be executed using the following command
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python runtests.py
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
## Changelog
|
|
150
|
+
Visit our [CHANGELOG](CHANGELOG.md) file to learn more about our new features and improvements.
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
## Contribution guidelines
|
|
154
|
+
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.
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
## Security contact information
|
|
158
|
+
|
|
159
|
+
To report a security vulnerability, please use the
|
|
160
|
+
[Tidelift security contact](https://tidelift.com/security).
|
|
161
|
+
Tidelift will coordinate the fix and disclosure.
|
|
162
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
pywinpty-3.0.3.dist-info\METADATA,sha256=poyhYBPHwV2raTRVtLtL-_ogd-kuEP83l1cjQbN4bGA,5890
|
|
2
|
+
pywinpty-3.0.3.dist-info\WHEEL,sha256=n_BmF69IyGtioVWE9c3M_zsEfe6-xMZy1v5HCL_6qE0,97
|
|
3
|
+
pywinpty-3.0.3.dist-info\licenses\LICENSE.txt,sha256=-HjUdn-a0uQ9MIPvoAIBsADOk32e6GJuALpccqrJUeI,1088
|
|
4
|
+
winpty\OpenConsole.exe,sha256=aykVqakcBzg0amxqez7it04mWCsMkrGxYGbnJXDd3Wg,1149472
|
|
5
|
+
winpty\__init__.py,sha256=laTi9sLjCLycyaQYO3wMvhZNIK2vh_pOvGTJT2Od4Qs,402
|
|
6
|
+
winpty\conpty.dll,sha256=H1_9Uv8Rjbl17rJbrABR9M7_PgUTE_oDpa__qede5QI,109600
|
|
7
|
+
winpty\enums.py,sha256=KAm7XJFPk7nMWwUJxvYHlql92cr6y-Y24IHK3fc0JDU,1860
|
|
8
|
+
winpty\ptyprocess.py,sha256=hucCVfBridHRc4IPiEFrEkdFhU-UKSQbyZUa97EceDc,12209
|
|
9
|
+
winpty\tests\__init__.py,sha256=fzb9cDnPt2R3b_rWh6sqDgIbiQOZtBlfsV1aq-ULT2Q,53
|
|
10
|
+
winpty\tests\test_pty.py,sha256=AXujQybXhKr0t0UKpNBSqeAfsm4fHoU_ognbiocBF5I,3947
|
|
11
|
+
winpty\tests\test_ptyprocess.py,sha256=MeGp_P-zkseEp0iXciWh9Fa548hYGdvlcaHy_WNEwXo,6112
|
|
12
|
+
winpty\winpty-agent.exe,sha256=REZ6g9hrYSe8e4duiy-zP6df3gnZuf8nx_jvhLqWmyk,2627338
|
|
13
|
+
winpty\winpty.cp313-win_amd64.pyd,sha256=ULEH7BqTk6RkBxRZAj6Mb8Sw8jbpdzHDGnQdzVZSTfg,553472
|
|
14
|
+
winpty\winpty.dll,sha256=UXfzIarC-oVDbdbsa_xtQUWdJfW1M6oDNJ71E0YbTHk,2509089
|
|
15
|
+
winpty\winpty.pyi,sha256=-VenowCvy8tjIZUCvvb5VZw5R1c6ATXEUfsiEyIZwjE,1176
|
|
16
|
+
pywinpty-3.0.3.dist-info\RECORD,,
|
winpty/OpenConsole.exe
CHANGED
|
Binary file
|
winpty/conpty.dll
CHANGED
|
Binary file
|
winpty/ptyprocess.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
3
|
# Standard library imports
|
|
4
|
-
import codecs
|
|
5
4
|
import os
|
|
6
5
|
import shlex
|
|
7
6
|
import signal
|
|
@@ -351,7 +350,7 @@ def _read_in_thread(address, pty: PTY, blocking: bool):
|
|
|
351
350
|
|
|
352
351
|
while 1:
|
|
353
352
|
try:
|
|
354
|
-
data = pty.read(blocking=blocking) or
|
|
353
|
+
data = pty.read(blocking=blocking) or '0011Ignore'
|
|
355
354
|
try:
|
|
356
355
|
client.send(bytes(data, 'utf-8'))
|
|
357
356
|
except socket.error:
|
|
@@ -363,8 +362,7 @@ def _read_in_thread(address, pty: PTY, blocking: bool):
|
|
|
363
362
|
client.send(b'')
|
|
364
363
|
except socket.error:
|
|
365
364
|
pass
|
|
366
|
-
|
|
367
|
-
break
|
|
365
|
+
break
|
|
368
366
|
|
|
369
367
|
call += 1
|
|
370
368
|
except Exception as e:
|
winpty/tests/test_pty.py
CHANGED
|
@@ -51,14 +51,17 @@ def pty_fixture(request):
|
|
|
51
51
|
|
|
52
52
|
backend = getattr(Backend, backend)
|
|
53
53
|
def _pty_factory():
|
|
54
|
-
|
|
54
|
+
try:
|
|
55
|
+
pty = PTY(80, 25, backend=backend)
|
|
56
|
+
except WinptyError:
|
|
57
|
+
pytest.skip()
|
|
58
|
+
return None
|
|
55
59
|
assert pty.spawn(CMD)
|
|
56
60
|
time.sleep(0.3)
|
|
57
61
|
return pty
|
|
58
62
|
return _pty_factory
|
|
59
63
|
|
|
60
64
|
|
|
61
|
-
|
|
62
65
|
# @pytest.fixture(scope='function', params=[
|
|
63
66
|
# pytest.lazy_fixture('conpty_provider'),
|
|
64
67
|
# pytest.lazy_fixture('winpty_provider')])
|
winpty/tests/test_ptyprocess.py
CHANGED
|
@@ -14,6 +14,7 @@ import pytest
|
|
|
14
14
|
from flaky import flaky
|
|
15
15
|
|
|
16
16
|
# Local imports
|
|
17
|
+
from winpty import WinptyError
|
|
17
18
|
from winpty.enums import Backend
|
|
18
19
|
from winpty.ptyprocess import PtyProcess, which
|
|
19
20
|
|
|
@@ -33,7 +34,11 @@ def pty_fixture(request):
|
|
|
33
34
|
backend = getattr(Backend, backend)
|
|
34
35
|
def _pty_factory(cmd=None, env=None):
|
|
35
36
|
cmd = cmd or 'cmd'
|
|
36
|
-
|
|
37
|
+
try:
|
|
38
|
+
pty = PtyProcess.spawn(cmd, env=env, backend=backend)
|
|
39
|
+
except WinptyError:
|
|
40
|
+
pytest.skip()
|
|
41
|
+
return None
|
|
37
42
|
return pty
|
|
38
43
|
# time.sleep(10)
|
|
39
44
|
_pty_factory.backend = request.param
|
|
Binary file
|
winpty/winpty.pyi
CHANGED
|
@@ -6,53 +6,37 @@
|
|
|
6
6
|
from typing import Optional
|
|
7
7
|
|
|
8
8
|
# Local imports
|
|
9
|
-
from .enums import
|
|
9
|
+
from .enums import MouseMode, AgentConfig
|
|
10
10
|
|
|
11
11
|
__version__: str
|
|
12
12
|
|
|
13
|
-
class WinptyError(Exception):
|
|
14
|
-
...
|
|
13
|
+
class WinptyError(Exception): ...
|
|
15
14
|
|
|
16
15
|
class PTY:
|
|
17
|
-
def __init__(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
cols: int,
|
|
19
|
+
rows: int,
|
|
20
|
+
backend: Optional[int] = None,
|
|
21
|
+
mouse_mode: int = MouseMode.WINPTY_MOUSE_MODE_NONE,
|
|
22
|
+
timeout: int = 30000,
|
|
23
|
+
agent_config: int = AgentConfig.WINPTY_FLAG_COLOR_ESCAPES,
|
|
24
|
+
): ...
|
|
25
|
+
def spawn(
|
|
26
|
+
self,
|
|
27
|
+
appname: str,
|
|
28
|
+
cmdline: Optional[str] = None,
|
|
29
|
+
cwd: Optional[str] = None,
|
|
30
|
+
env: Optional[str] = None,
|
|
31
|
+
) -> bool: ...
|
|
32
32
|
def set_size(self, cols: int, rows: int): ...
|
|
33
|
-
|
|
34
|
-
def read(self,
|
|
35
|
-
length: Optional[int] = 1000,
|
|
36
|
-
blocking: bool = False) -> str:
|
|
37
|
-
...
|
|
38
|
-
|
|
39
|
-
def read_stderr(self,
|
|
40
|
-
length: Optional[int] = 1000,
|
|
41
|
-
blocking: bool = False) -> str:
|
|
42
|
-
...
|
|
43
|
-
|
|
33
|
+
def read(self, blocking: bool = False) -> str: ...
|
|
44
34
|
def write(self, to_write: str) -> int: ...
|
|
45
|
-
|
|
46
35
|
def isalive(self) -> bool: ...
|
|
47
|
-
|
|
48
36
|
def get_exitstatus(self) -> Optional[int]: ...
|
|
49
|
-
|
|
50
37
|
def iseof(self) -> bool: ...
|
|
51
|
-
|
|
52
|
-
def cancel_io() -> bool: ...
|
|
53
|
-
|
|
38
|
+
def cancel_io(self) -> bool: ...
|
|
54
39
|
@property
|
|
55
40
|
def pid(self) -> Optional[int]: ...
|
|
56
|
-
|
|
57
41
|
@property
|
|
58
42
|
def fd(self) -> Optional[int]: ...
|
pywinpty-3.0.1.dist-info/RECORD
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
pywinpty-3.0.1.dist-info/METADATA,sha256=uv-Z7g2o5rjRo8IsY9CRa-o5hsuAXJ7ahffynf82knM,159
|
|
2
|
-
pywinpty-3.0.1.dist-info/WHEEL,sha256=K7foeVF-x_RZTycPKa1uE1HH2bAWe3AiJbihrXn5Hhc,96
|
|
3
|
-
pywinpty-3.0.1.dist-info/licenses/LICENSE.txt,sha256=-HjUdn-a0uQ9MIPvoAIBsADOk32e6GJuALpccqrJUeI,1088
|
|
4
|
-
winpty/OpenConsole.exe,sha256=6Dg0D2Gj8O-6rBrxtvgb31jYQDGM0fB2GQIlWrtWqmE,1148472
|
|
5
|
-
winpty/__init__.py,sha256=laTi9sLjCLycyaQYO3wMvhZNIK2vh_pOvGTJT2Od4Qs,402
|
|
6
|
-
winpty/conpty.dll,sha256=kliUMMhwG7vUzGvzCV_o8GdlaIh13W7EK6VKWwdHHoU,109624
|
|
7
|
-
winpty/enums.py,sha256=KAm7XJFPk7nMWwUJxvYHlql92cr6y-Y24IHK3fc0JDU,1860
|
|
8
|
-
winpty/ptyprocess.py,sha256=lub-1tL-LVUEY0e8s8J0VEbfWLsRdsx8gHyhagxdb28,12255
|
|
9
|
-
winpty/tests/__init__.py,sha256=fzb9cDnPt2R3b_rWh6sqDgIbiQOZtBlfsV1aq-ULT2Q,53
|
|
10
|
-
winpty/tests/test_pty.py,sha256=f6UKatWALTFM7jvcrqYWsRFCxosT-Aj0ChhvkN97ov4,3850
|
|
11
|
-
winpty/tests/test_ptyprocess.py,sha256=QP0I-gufNV7OaZZFpRIC9J1XD4nq86NrR3oqi9s4OEI,5981
|
|
12
|
-
winpty/winpty-agent.exe,sha256=REZ6g9hrYSe8e4duiy-zP6df3gnZuf8nx_jvhLqWmyk,2627338
|
|
13
|
-
winpty/winpty.cp313-win_amd64.pyd,sha256=uz9tkIFqQgNENBjvtjNh56YfuvlGEaCJ3kxZiK5XIJo,581120
|
|
14
|
-
winpty/winpty.dll,sha256=UXfzIarC-oVDbdbsa_xtQUWdJfW1M6oDNJ71E0YbTHk,2509089
|
|
15
|
-
winpty/winpty.pyi,sha256=N8sy5oYzQGwtekPUSZ8Ai6Z9l3TcpNv-VOMjhRHByhs,1500
|
|
16
|
-
pywinpty-3.0.1.dist-info/RECORD,,
|
|
File without changes
|