pywinpty 2.0.15__cp312-cp312-win_amd64.whl → 3.0.0__cp312-cp312-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.
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: pywinpty
3
+ Version: 3.0.0
4
+ License-File: LICENSE.txt
5
+ Requires-Python: >=3.9
@@ -0,0 +1,16 @@
1
+ pywinpty-3.0.0.dist-info/METADATA,sha256=eN0i5-E-C9srVJw2YNvzxWTSvV8X3NOtdopBzlFgpcA,101
2
+ pywinpty-3.0.0.dist-info/WHEEL,sha256=HF3aUMilrtO42xS_fBzOVaPE8OtiNjP_RotLatII7HM,96
3
+ pywinpty-3.0.0.dist-info/licenses/LICENSE.txt,sha256=-HjUdn-a0uQ9MIPvoAIBsADOk32e6GJuALpccqrJUeI,1088
4
+ winpty/OpenConsole.exe,sha256=HamnH6Ts12mO1nISxViY3CGpeUisM12Vfmv3h3rybho,1145928
5
+ winpty/__init__.py,sha256=laTi9sLjCLycyaQYO3wMvhZNIK2vh_pOvGTJT2Od4Qs,402
6
+ winpty/conpty.dll,sha256=iUSeohM9L_OQZS3QtFiJnUvfTxmdCvdUcLpDtnOSTVI,109600
7
+ winpty/enums.py,sha256=fhHvBfb0ciVR2XsAiBn67Q-zNDlUGvakqlyZ2XRicig,1859
8
+ winpty/ptyprocess.py,sha256=Cvjzl7zlQT5BHszR_84XsyB-qNMoJnll3oaxVAHqDdg,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.cp312-win_amd64.pyd,sha256=wH1bRPqu9XOr6HhZjNsSpLiejZeaSrpu6gBv_26QgVs,600576
14
+ winpty/winpty.dll,sha256=UXfzIarC-oVDbdbsa_xtQUWdJfW1M6oDNJ71E0YbTHk,2509089
15
+ winpty/winpty.pyi,sha256=N8sy5oYzQGwtekPUSZ8Ai6Z9l3TcpNv-VOMjhRHByhs,1500
16
+ pywinpty-3.0.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (1.8.1)
2
+ Generator: maturin (1.9.3)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp312-cp312-win_amd64
winpty/OpenConsole.exe ADDED
Binary file
winpty/conpty.dll ADDED
Binary file
winpty/ptyprocess.py CHANGED
@@ -26,6 +26,9 @@ class PtyProcess(object):
26
26
  self.pty = pty
27
27
  self.pid = pty.pid
28
28
  # self.fd = pty.fd
29
+ self.argv = None
30
+ self.env = None
31
+ self.launch_dir = None
29
32
 
30
33
  self.read_blocking = bool(int(os.environ.get('PYWINPTY_BLOCK', 1)))
31
34
  self.closed = False
@@ -72,8 +75,8 @@ class PtyProcess(object):
72
75
  raise TypeError("Expected a list or tuple for argv, got %r" % argv)
73
76
 
74
77
  # Shallow copy of argv so we can modify it
75
- argv = argv[:]
76
- command = argv[0]
78
+ _argv: list[str] = list(argv[:])
79
+ command = _argv[0]
77
80
  env = env or os.environ
78
81
 
79
82
  path = env.get('PATH', os.defpath)
@@ -84,8 +87,8 @@ class PtyProcess(object):
84
87
  'executable: %s.' % command
85
88
  )
86
89
  command = command_with_path
87
- argv[0] = command
88
- cmdline = ' ' + subprocess.list2cmdline(argv[1:])
90
+ _argv[0] = command
91
+ cmdline = ' ' + subprocess.list2cmdline(_argv[1:])
89
92
  cwd = cwd or os.getcwd()
90
93
 
91
94
  backend = backend or os.environ.get('PYWINPTY_BACKEND', None)
@@ -105,7 +108,7 @@ class PtyProcess(object):
105
108
  # cmdline = bytes(cmdline, encoding)
106
109
  # env = bytes(env, encoding)
107
110
 
108
- if len(argv) == 1:
111
+ if len(_argv) == 1:
109
112
  proc.spawn(command, cwd=cwd, env=env)
110
113
  else:
111
114
  proc.spawn(command, cwd=cwd, env=env, cmdline=cmdline)
@@ -114,7 +117,7 @@ class PtyProcess(object):
114
117
  inst._winsize = dimensions
115
118
 
116
119
  # Set some informational attributes
117
- inst.argv = argv
120
+ inst.argv = _argv
118
121
  if env is not None:
119
122
  inst.env = env
120
123
  if cwd is not None:
@@ -194,7 +197,7 @@ class PtyProcess(object):
194
197
  raise EOFError('Pty is closed')
195
198
 
196
199
  if data == b'0011Ignore':
197
- data = ''
200
+ data = b''
198
201
 
199
202
  err = True
200
203
  while err and data:
@@ -237,6 +240,10 @@ class PtyProcess(object):
237
240
  if not self.isalive():
238
241
  return True
239
242
  self.kill(signal.SIGINT)
243
+ try:
244
+ self.pty.cancel_io()
245
+ except Exception:
246
+ pass
240
247
  time.sleep(self.delayafterterminate)
241
248
  if not self.isalive():
242
249
  return True
@@ -266,9 +273,11 @@ class PtyProcess(object):
266
273
  self.closed = not alive
267
274
  return alive
268
275
 
269
- def kill(self, sig=None):
276
+ def kill(self, sig):
270
277
  """Kill the process with the given signal.
271
278
  """
279
+ if self.pid is None:
280
+ return
272
281
  os.kill(self.pid, sig)
273
282
 
274
283
  def sendcontrol(self, char):
@@ -307,13 +316,13 @@ class PtyProcess(object):
307
316
  It is the responsibility of the caller to ensure the eof is sent at the
308
317
  beginning of a line."""
309
318
  # Send control character 4 (Ctrl-D)
310
- self.pty.write('\x04'), '\x04'
319
+ self.pty.write('\x04')
311
320
 
312
321
  def sendintr(self):
313
322
  """This sends a SIGINT to the child. It does not require
314
323
  the SIGINT to be the first character on a line. """
315
324
  # Send control character 3 (Ctrl-C)
316
- self.pty.write('\x03'), '\x03'
325
+ self.pty.write('\x03')
317
326
 
318
327
  def eof(self):
319
328
  """This returns True if the EOF exception was ever raised.
@@ -332,7 +341,7 @@ class PtyProcess(object):
332
341
  self.pty.set_size(cols, rows)
333
342
 
334
343
 
335
- def _read_in_thread(address, pty, blocking):
344
+ def _read_in_thread(address, pty: PTY, blocking: bool):
336
345
  """Read data from the pty in a thread.
337
346
  """
338
347
  client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -342,7 +351,7 @@ def _read_in_thread(address, pty, blocking):
342
351
 
343
352
  while 1:
344
353
  try:
345
- data = pty.read(4096, blocking=blocking) or b'0011Ignore'
354
+ data = pty.read(blocking=blocking) or b'0011Ignore'
346
355
  try:
347
356
  client.send(bytes(data, 'utf-8'))
348
357
  except socket.error:
winpty/tests/test_pty.py CHANGED
@@ -28,6 +28,8 @@ def pty_factory(backend):
28
28
  # loc = bytes(os.getcwd(), 'utf8')
29
29
  assert pty.spawn(CMD)
30
30
  time.sleep(0.3)
31
+ # if backend == Backend.ConPTY:
32
+ # pty.write("\x1b[?1;0c\x1b[0;0R")
31
33
  return pty
32
34
  return pty_fixture
33
35
 
@@ -131,26 +133,26 @@ def test_isalive(pty_fixture):
131
133
  # pass
132
134
 
133
135
 
134
- @pytest.mark.parametrize(
135
- 'backend_name,backend',
136
- [("ConPTY", Backend.ConPTY), ('WinPTY', Backend.WinPTY)])
137
- def test_pty_create_size_fail(backend_name, backend):
138
- try:
139
- PTY(80, -25, backend=backend)
140
- assert False
141
- except WinptyError:
142
- pass
136
+ # @pytest.mark.parametrize(
137
+ # 'backend_name,backend',
138
+ # [("ConPTY", Backend.ConPTY), ('WinPTY', Backend.WinPTY)])
139
+ # def test_pty_create_size_fail(backend_name, backend):
140
+ # try:
141
+ # PTY(80, -25, backend=backend)
142
+ # assert False
143
+ # except WinptyError:
144
+ # pass
143
145
 
144
146
 
145
- def test_agent_resize_fail(pty_fixture):
146
- pty = pty_fixture()
147
- try:
148
- pty.set_size(-80, 70)
149
- assert False
150
- except WinptyError:
151
- pass
152
- finally:
153
- del pty
147
+ # def test_agent_resize_fail(pty_fixture):
148
+ # pty = pty_fixture()
149
+ # try:
150
+ # pty.set_size(-80, 70)
151
+ # assert False
152
+ # except WinptyError:
153
+ # pass
154
+ # finally:
155
+ # del pty
154
156
 
155
157
 
156
158
  def test_agent_resize(pty_fixture):
@@ -33,7 +33,9 @@ def pty_fixture(request):
33
33
  backend = getattr(Backend, backend)
34
34
  def _pty_factory(cmd=None, env=None):
35
35
  cmd = cmd or 'cmd'
36
- return PtyProcess.spawn(cmd, env=env, backend=backend)
36
+ pty = PtyProcess.spawn(cmd, env=env, backend=backend)
37
+ return pty
38
+ # time.sleep(10)
37
39
  _pty_factory.backend = request.param
38
40
  return _pty_factory
39
41
 
@@ -78,6 +80,7 @@ def test_write(pty_fixture):
78
80
  @flaky(max_runs=40, min_passes=1)
79
81
  def test_isalive(pty_fixture):
80
82
  pty = pty_fixture()
83
+ time.sleep(4)
81
84
 
82
85
  pty.write('echo \"foo\"\r\nexit\r\n')
83
86
  data = ''
@@ -166,7 +169,7 @@ def test_exit_status(pty_fixture):
166
169
  assert pty.exitstatus == 1
167
170
 
168
171
 
169
- @pytest.mark.timeout(30)
172
+ # @pytest.mark.timeout(30)
170
173
  def test_kill_sigterm(pty_fixture):
171
174
  pty = pty_fixture()
172
175
  pty.write('echo \"foo\"\r\nsleep 1000\r\n')
@@ -183,7 +186,7 @@ def test_kill_sigterm(pty_fixture):
183
186
  assert pty.exitstatus == signal.SIGTERM
184
187
 
185
188
 
186
- @pytest.mark.timeout(30)
189
+ # @pytest.mark.timeout(30)
187
190
  def test_terminate(pty_fixture):
188
191
  pty = pty_fixture()
189
192
  pty.write('echo \"foo\"\r\nsleep 1000\r\n')
@@ -200,7 +203,7 @@ def test_terminate(pty_fixture):
200
203
  assert pty.closed
201
204
 
202
205
 
203
- @pytest.mark.timeout(30)
206
+ # @pytest.mark.timeout(30)
204
207
  def test_terminate_force(pty_fixture):
205
208
  pty = pty_fixture()
206
209
  pty.write('echo \"foo\"\r\nsleep 1000\r\n')
Binary file
winpty/winpty.pyi CHANGED
@@ -8,6 +8,10 @@ from typing import Optional
8
8
  # Local imports
9
9
  from .enums import Backend, Encoding, MouseMode, AgentConfig
10
10
 
11
+ __version__: str
12
+
13
+ class WinptyError(Exception):
14
+ ...
11
15
 
12
16
  class PTY:
13
17
  def __init__(self, cols: int, rows: int,
@@ -19,25 +23,25 @@ class PTY:
19
23
  ...
20
24
 
21
25
  def spawn(self,
22
- appname: bytes,
23
- cmdline: Optional[bytes] = None,
24
- cwd: Optional[bytes] = None,
25
- env: Optional[bytes] = None) -> bool:
26
+ appname: str,
27
+ cmdline: Optional[str] = None,
28
+ cwd: Optional[str] = None,
29
+ env: Optional[str] = None) -> bool:
26
30
  ...
27
31
 
28
32
  def set_size(self, cols: int, rows: int): ...
29
33
 
30
34
  def read(self,
31
35
  length: Optional[int] = 1000,
32
- blocking: bool = False) -> bytes:
36
+ blocking: bool = False) -> str:
33
37
  ...
34
38
 
35
39
  def read_stderr(self,
36
40
  length: Optional[int] = 1000,
37
- blocking: bool = False) -> bytes:
41
+ blocking: bool = False) -> str:
38
42
  ...
39
43
 
40
- def write(self, to_write: bytes) -> int: ...
44
+ def write(self, to_write: str) -> int: ...
41
45
 
42
46
  def isalive(self) -> bool: ...
43
47
 
@@ -45,6 +49,8 @@ class PTY:
45
49
 
46
50
  def iseof(self) -> bool: ...
47
51
 
52
+ def cancel_io() -> bool: ...
53
+
48
54
  @property
49
55
  def pid(self) -> Optional[int]: ...
50
56
 
@@ -1,145 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pywinpty
3
- Version: 2.0.15
4
- License-File: LICENSE.txt
5
- Summary: Pseudo terminal support for Windows from Python.
6
- Keywords: pty,pseudo-terminal,conpty,windows,winpty
7
- Author: Edgar Andrés Margffoy Tuay <andfoy@gmail.com>
8
- Author-email: Edgar Andrés Margffoy Tuay <andfoy@gmail.com>
9
- License: MIT
10
- Requires-Python: >=3.9
11
- Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
12
- Project-URL: Source Code, https://github.com/spyder-ide/pywinpty
13
-
14
- # PyWinpty: Pseudoterminals for Windows in Python
15
-
16
- [![Project License - MIT](https://img.shields.io/pypi/l/pywinpty.svg)](./LICENSE.txt)
17
- [![pypi version](https://img.shields.io/pypi/v/pywinpty.svg)](https://pypi.org/project/pywinpty/)
18
- [![conda version](https://img.shields.io/conda/vn/conda-forge/pywinpty.svg)](https://www.anaconda.com/download/)
19
- [![download count](https://img.shields.io/conda/dn/conda-forge/pywinpty.svg)](https://www.anaconda.com/download/)
20
- [![Downloads](https://pepy.tech/badge/pywinpty)](https://pepy.tech/project/pywinpty)
21
- [![PyPI status](https://img.shields.io/pypi/status/pywinpty.svg)](https://github.com/spyder-ide/pywinpty)
22
- [![Windows tests](https://github.com/andfoy/pywinpty/actions/workflows/windows_build.yml/badge.svg)](https://github.com/andfoy/pywinpty/actions/workflows/windows_build.yml)
23
-
24
- *Copyright © 2017–2022 Spyder Project Contributors*
25
- *Copyright © 2022– Edgar Andrés Margffoy Tuay*
26
-
27
-
28
- ## Overview
29
-
30
- 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.
31
-
32
-
33
- ## Dependencies
34
- To compile pywinpty sources, you must have [Rust](https://rustup.rs/) installed.
35
- Optionally, you can also have Winpty's C header and library files available on your include path.
36
-
37
-
38
- ## Installation
39
- You can install this library by using conda or pip package managers, as it follows:
40
-
41
- Using conda (Recommended):
42
- ```bash
43
- conda install pywinpty
44
- ```
45
-
46
- Using pip:
47
- ```bash
48
- pip install pywinpty
49
- ```
50
-
51
- ## Building from source
52
-
53
- To build from sources, you will require both a working stable or nightly Rust toolchain with
54
- target `x86_64-pc-windows-msvc`, which can be installed using [rustup](https://rustup.rs/).
55
-
56
- Optionally, this library can be linked against winpty library, which you can install using conda-forge:
57
-
58
- ```batch
59
- conda install winpty -c conda-forge
60
- ```
61
-
62
- If you don't want to use conda, you will need to have the winpty binaries and headers available on your PATH.
63
-
64
- Finally, pywinpty uses [Maturin](https://github.com/PyO3/maturin) as the build backend, which can be installed using `pip`:
65
-
66
- ```batch
67
- pip install maturin
68
- ```
69
-
70
- To test your compilation environment settings, you can build pywinpty sources locally, by
71
- executing:
72
-
73
- ```bash
74
- maturin develop
75
- ```
76
-
77
- This package depends on the following Rust crates:
78
-
79
- * [PyO3](https://github.com/PyO3/pyo3): Library used to produce Python bindings from Rust code.
80
- * [WinPTY-rs](https://github.com/andfoy/winpty-rs): Create and spawn processes inside a pseudoterminal in Windows from Rust.
81
- * [Maturin](https://github.com/PyO3/maturin): Build system to build and publish Rust-based Python packages.
82
-
83
- ## Package usage
84
- Pywinpty offers a single python wrapper around winpty library functions.
85
- This implies that using a single object (``winpty.PTY``) it is possible to access to all functionality, as it follows:
86
-
87
- ```python
88
- # High level usage using `spawn`
89
- from winpty import PtyProcess
90
-
91
- proc = PtyProcess.spawn('python')
92
- proc.write('print("hello, world!")\r\n')
93
- proc.write('exit()\r\n')
94
- while proc.isalive():
95
- print(proc.readline())
96
-
97
- # Low level usage using the raw `PTY` object
98
- from winpty import PTY
99
-
100
- # Start a new winpty-agent process of size (cols, rows)
101
- cols, rows = 80, 25
102
- process = PTY(cols, rows)
103
-
104
- # Spawn a new console process, e.g., CMD
105
- process.spawn(br'C:\windows\system32\cmd.exe')
106
-
107
- # Read console output (Unicode)
108
- process.read()
109
-
110
- # Write input to console (Unicode)
111
- process.write(b'Text')
112
-
113
- # Resize console size
114
- new_cols, new_rows = 90, 30
115
- process.set_size(new_cols, new_rows)
116
-
117
- # Know if the process is alive
118
- alive = process.isalive()
119
-
120
- # End winpty-agent process
121
- del process
122
- ```
123
-
124
- ## Running tests
125
- We use pytest to run tests as it follows (after calling ``maturin develop``), the test suite depends
126
- on pytest-lazy-fixture, which can be installed via pip:
127
-
128
- ```batch
129
- pip install pytest pytest-lazy-fixture flaky
130
- ```
131
-
132
- All the tests can be exceuted using the following command
133
-
134
- ```bash
135
- python runtests.py
136
- ```
137
-
138
-
139
- ## Changelog
140
- Visit our [CHANGELOG](CHANGELOG.md) file to learn more about our new features and improvements.
141
-
142
-
143
- ## Contribution guidelines
144
- 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.
145
-
@@ -1,14 +0,0 @@
1
- pywinpty-2.0.15.dist-info/METADATA,sha256=JvigkiTz4bbGOWiYRrvpK42n6ASsNzKxr5j3LPpQl-o,5195
2
- pywinpty-2.0.15.dist-info/WHEEL,sha256=2fdNHxJvS2bAcI00delQ4QrnR7Oujl4cP2y-SRm5elU,96
3
- pywinpty-2.0.15.dist-info/licenses/LICENSE.txt,sha256=-HjUdn-a0uQ9MIPvoAIBsADOk32e6GJuALpccqrJUeI,1088
4
- winpty/enums.py,sha256=fhHvBfb0ciVR2XsAiBn67Q-zNDlUGvakqlyZ2XRicig,1859
5
- winpty/ptyprocess.py,sha256=OIrWzipZZ5zZSqc7k__megCZ9yWkepSzAP04Du0G2H4,12021
6
- winpty/tests/test_pty.py,sha256=PqZPzzZqfdABi_eW0KFVkDdSd8uskPtUKHj0Lw7uPIA,3725
7
- winpty/tests/test_ptyprocess.py,sha256=F-5Tp8nQnPhpJlTEKJTM3XDH-VVEbcYr7DsKiJMHT2g,5915
8
- winpty/tests/__init__.py,sha256=fzb9cDnPt2R3b_rWh6sqDgIbiQOZtBlfsV1aq-ULT2Q,53
9
- winpty/winpty-agent.exe,sha256=REZ6g9hrYSe8e4duiy-zP6df3gnZuf8nx_jvhLqWmyk,2627338
10
- winpty/winpty.dll,sha256=UXfzIarC-oVDbdbsa_xtQUWdJfW1M6oDNJ71E0YbTHk,2509089
11
- winpty/winpty.pyi,sha256=CAFZIWyBAGwV-2pekJUF5ft6uxRwFo-5n0UGEbiToRE,1418
12
- winpty/__init__.py,sha256=laTi9sLjCLycyaQYO3wMvhZNIK2vh_pOvGTJT2Od4Qs,402
13
- winpty/winpty.cp312-win_amd64.pyd,sha256=SIwSquqRsoKM1SJLEFBWXOTmZg563vL7B1EPifV0PTM,534528
14
- pywinpty-2.0.15.dist-info/RECORD,,