libPyshell 0.4.1__tar.gz → 0.6.0__tar.gz

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.
@@ -1 +1,2 @@
1
1
  exclude src/shell.py
2
+ include src/py.typed
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: libPyshell
3
- Version: 0.4.1
3
+ Version: 0.6.0
4
4
  Summary: Support for writing shell scripts in Python
5
5
  Home-page: https://github.com/skogsbaer/libPyshell
6
6
  Author: Stefan Wehr
@@ -8,6 +8,14 @@ Author-email: stefan.wehr@gmail.com
8
8
  Requires-Python: >=3.9
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
11
+ Dynamic: author
12
+ Dynamic: author-email
13
+ Dynamic: description
14
+ Dynamic: description-content-type
15
+ Dynamic: home-page
16
+ Dynamic: license-file
17
+ Dynamic: requires-python
18
+ Dynamic: summary
11
19
 
12
20
  # Pyshell
13
21
 
@@ -37,6 +45,13 @@ magicFiles = run(['grep', 'magic'] + files, captureStdout=splitLines, onError='i
37
45
 
38
46
  ## Changelog
39
47
 
48
+ * 0.6.6 (2026-07-01)
49
+ * switch to static typing
50
+ * make the package PEP 561-typed
51
+
52
+ * 0.5.0 (2025-03-11)
53
+ * support of timeouts for run
54
+
40
55
  * 0.4.1 (2024-09-12)
41
56
  * fix capture handling
42
57
  * add failOnError option to rm commands
@@ -26,6 +26,13 @@ magicFiles = run(['grep', 'magic'] + files, captureStdout=splitLines, onError='i
26
26
 
27
27
  ## Changelog
28
28
 
29
+ * 0.6.6 (2026-07-01)
30
+ * switch to static typing
31
+ * make the package PEP 561-typed
32
+
33
+ * 0.5.0 (2025-03-11)
34
+ * support of timeouts for run
35
+
29
36
  * 0.4.1 (2024-09-12)
30
37
  * fix capture handling
31
38
  * add failOnError option to rm commands
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: libPyshell
3
- Version: 0.4.1
3
+ Version: 0.6.0
4
4
  Summary: Support for writing shell scripts in Python
5
5
  Home-page: https://github.com/skogsbaer/libPyshell
6
6
  Author: Stefan Wehr
@@ -8,6 +8,14 @@ Author-email: stefan.wehr@gmail.com
8
8
  Requires-Python: >=3.9
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
11
+ Dynamic: author
12
+ Dynamic: author-email
13
+ Dynamic: description
14
+ Dynamic: description-content-type
15
+ Dynamic: home-page
16
+ Dynamic: license-file
17
+ Dynamic: requires-python
18
+ Dynamic: summary
11
19
 
12
20
  # Pyshell
13
21
 
@@ -37,6 +45,13 @@ magicFiles = run(['grep', 'magic'] + files, captureStdout=splitLines, onError='i
37
45
 
38
46
  ## Changelog
39
47
 
48
+ * 0.6.6 (2026-07-01)
49
+ * switch to static typing
50
+ * make the package PEP 561-typed
51
+
52
+ * 0.5.0 (2025-03-11)
53
+ * support of timeouts for run
54
+
40
55
  * 0.4.1 (2024-09-12)
41
56
  * fix capture handling
42
57
  * add failOnError option to rm commands
@@ -5,5 +5,7 @@ setup.py
5
5
  libPyshell.egg-info/PKG-INFO
6
6
  libPyshell.egg-info/SOURCES.txt
7
7
  libPyshell.egg-info/dependency_links.txt
8
+ libPyshell.egg-info/not-zip-safe
8
9
  libPyshell.egg-info/top_level.txt
9
- src/__init__.py
10
+ src/__init__.py
11
+ src/py.typed
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env python
2
2
 
3
- from distutils.core import setup
3
+ from setuptools import setup
4
4
 
5
- VERSION = '0.4.1'
5
+ VERSION = '0.6.0'
6
6
 
7
7
  with open("README.md", "r", encoding="utf-8") as fh:
8
8
  long_description = fh.read()
@@ -17,5 +17,9 @@ setup(name='libPyshell',
17
17
  url='https://github.com/skogsbaer/libPyshell',
18
18
  package_dir={'shell': 'src'},
19
19
  packages=['shell'],
20
+ # PEP 561: ship the py.typed marker so type checkers treat the
21
+ # package as typed for downstream consumers.
22
+ package_data={'shell': ['py.typed']},
23
+ zip_safe=False,
20
24
  python_requires='>=3.9'
21
25
  )
@@ -227,7 +227,8 @@ def run(cmd: Union[list[str], str],
227
227
  decodeErrors: str='replace',
228
228
  decodeErrorsStdout: Optional[str]=None,
229
229
  decodeErrorsStderr: Optional[str]=None,
230
- encodeErrorsStdin: Optional[str]=None
230
+ encodeErrorsStdin: Optional[str]=None,
231
+ timeout: Optional[int]=None
231
232
  ) -> RunResult:
232
233
  """Runs the given command.
233
234
 
@@ -258,7 +259,8 @@ def run(cmd: Union[list[str], str],
258
259
  * `decodeErrors`: how to handle decoding/encoding errors on stdout and stderr and stdin.
259
260
  * `decodeErrorsStdout` and `decodeErrorsStderr` and `encodeErrorsStdin`: overwrite the value
260
261
  of decodeErrors for stdout or stderr or stdin
261
-
262
+ * `timeout`: an optional timeout value in seconds. If a timeout occurs, the exit code will
263
+ be 124 (as for the unix timeout command)
262
264
  Returns:
263
265
  a `RunResult` value, given access to the captured stdout of the child process (if it was
264
266
  captured at all) and to the exit code of the child process.
@@ -315,11 +317,18 @@ def run(cmd: Union[list[str], str],
315
317
  if _PYSHELL_DEBUG:
316
318
  _debug(f'subprocess.run({cmd}, shell={shell}, input={input}, stdout={stdout}, ' \
317
319
  f'stderr={stderr}, cwd={cwd}, env={runEnv})')
318
- res = subprocess.run(cmd, shell=shell, input=input, stdout=stdout, stderr=stderr, cwd=cwd,
319
- env=runEnv)
320
- stdoutData = _massageOutput(res.stdout, encoding, decodeErrorsStdout or decodeErrors, captureStdout)
321
- stderrData = _massageOutput(res.stderr, encoding, decodeErrorsStderr or decodeErrors, captureStderr)
322
- exitcode = res.returncode
320
+ try:
321
+ res = subprocess.run(cmd, shell=shell, input=input, stdout=stdout, stderr=stderr, cwd=cwd,
322
+ env=runEnv, timeout=timeout)
323
+ out = res.stdout
324
+ err = res.stderr
325
+ exitcode = res.returncode
326
+ except subprocess.TimeoutExpired as e:
327
+ out = e.stdout
328
+ err = e.stderr
329
+ exitcode = 124
330
+ stdoutData = _massageOutput(out, encoding, decodeErrorsStdout or decodeErrors, captureStdout)
331
+ stderrData = _massageOutput(err, encoding, decodeErrorsStderr or decodeErrors, captureStderr)
323
332
  if onError == 'raise' and exitcode != 0:
324
333
  err = RunError(cmd, exitcode, stdoutData, stderrData)
325
334
  raise err
@@ -606,7 +615,9 @@ def mkTempFile(suffix: str='', prefix: str='',
606
615
  """
607
616
 
608
617
 
609
- f = tempfile.mktemp(suffix, prefix, dir)
618
+ # mktemp is deprecated because it only reserves a name without creating the file,
619
+ # which is exactly the contract of mkTempFile (the caller creates the file later).
620
+ f = tempfile.mktemp(suffix, prefix, dir) # pyright: ignore[reportDeprecated]
610
621
  if deleteAtExit:
611
622
  def action():
612
623
  if isFile(f):
@@ -711,8 +722,7 @@ def _openForTee(x: Any) -> _FILE:
711
722
  if type(x) == str:
712
723
  return open(x, 'wb')
713
724
  elif type(x) == tuple:
714
- name: Any = x[0]
715
- mode: Any = x[1]
725
+ name, mode = cast('tuple[str, str]', x)
716
726
  if mode == 'w':
717
727
  return open(name, 'wb')
718
728
  elif mode == 'a':
File without changes
File without changes
File without changes