deepctl-shared-utils 0.1.13__tar.gz → 0.1.14__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.
Files changed (16) hide show
  1. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/PKG-INFO +1 -1
  2. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/pyproject.toml +1 -1
  3. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/src/deepctl_shared_utils/__init__.py +1 -1
  4. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/src/deepctl_shared_utils/ffprobe.py +46 -8
  5. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/src/deepctl_shared_utils.egg-info/PKG-INFO +1 -1
  6. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/README.md +0 -0
  7. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/setup.cfg +0 -0
  8. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/src/deepctl_shared_utils/diagnostics.py +0 -0
  9. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/src/deepctl_shared_utils/ffprobe_models.py +0 -0
  10. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/src/deepctl_shared_utils/models.py +0 -0
  11. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/src/deepctl_shared_utils/py.typed +0 -0
  12. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/src/deepctl_shared_utils/validation.py +0 -0
  13. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/src/deepctl_shared_utils.egg-info/SOURCES.txt +0 -0
  14. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/src/deepctl_shared_utils.egg-info/dependency_links.txt +0 -0
  15. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/src/deepctl_shared_utils.egg-info/requires.txt +0 -0
  16. {deepctl_shared_utils-0.1.13 → deepctl_shared_utils-0.1.14}/src/deepctl_shared_utils.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepctl-shared-utils
3
- Version: 0.1.13
3
+ Version: 0.1.14
4
4
  Summary: Shared utilities for deepctl
5
5
  Author-email: Deepgram <devrel@deepgram.com>
6
6
  Maintainer-email: Deepgram <devrel@deepgram.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "deepctl-shared-utils"
7
- version = "0.1.13" # x-release-please-version
7
+ version = "0.1.14" # x-release-please-version
8
8
  description = "Shared utilities for deepctl"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -28,4 +28,4 @@ __all__ = [
28
28
  "validate_url",
29
29
  ]
30
30
 
31
- __version__ = "0.1.13" # x-release-please-version
31
+ __version__ = "0.1.14" # x-release-please-version
@@ -5,7 +5,6 @@ from __future__ import annotations
5
5
  import json
6
6
  import os
7
7
  import platform
8
- import shutil
9
8
  import subprocess
10
9
  import tempfile
11
10
  from typing import TYPE_CHECKING
@@ -26,22 +25,61 @@ if TYPE_CHECKING:
26
25
  console = create_diagnostic_console()
27
26
 
28
27
 
28
+ def ffprobe_input(file_path: str | os.PathLike[str]) -> str:
29
+ """Name ``file_path`` for ffprobe as an input file, never as an option.
30
+
31
+ ffprobe has no ``--`` end-of-options marker, so a file named ``-f lavfi``
32
+ would be read as options. The ``file:`` protocol prefix with an absolute
33
+ path makes ffprobe treat it as a plain file, whatever it is called.
34
+ """
35
+ return "file:" + os.path.abspath(os.fspath(file_path))
36
+
37
+
29
38
  def get_ffprobe_path(config: Config | None = None) -> str | None:
30
39
  """Get the ffprobe binary path.
31
40
 
32
- Checks stored config path first, then falls back to auto-detection
33
- via shutil.which().
41
+ Checks the stored config path first, then falls back to a PATH lookup.
42
+ A stored path is used only when it is absolute, and the PATH lookup
43
+ skips relative and empty entries and the current directory itself (on
44
+ every OS), so a binary inside the current directory is never picked up
45
+ implicitly. The result is always an absolute path.
34
46
  """
35
47
  if config is not None:
36
48
  stored_path = config.get("tools.ffprobe_path")
37
49
  if (
38
- stored_path
50
+ isinstance(stored_path, str)
51
+ and os.path.isabs(stored_path)
39
52
  and os.path.isfile(stored_path)
40
53
  and os.access(stored_path, os.X_OK)
41
54
  ):
42
- return str(stored_path)
55
+ return stored_path
56
+ return _find_on_path("ffprobe")
43
57
 
44
- return shutil.which("ffprobe")
58
+
59
+ def _find_on_path(name: str) -> str | None:
60
+ """Absolute path of ``name`` from PATH, never from the current directory.
61
+
62
+ Mirrors ``deepctl_core.tools.find_executable`` (this package does not
63
+ depend on deepctl-core).
64
+ """
65
+ try:
66
+ cwd: str | None = os.path.realpath(os.getcwd())
67
+ except OSError:
68
+ cwd = None
69
+ names = [name]
70
+ if platform.system() == "Windows" and not os.path.splitext(name)[1]:
71
+ exts = os.environ.get("PATHEXT", ".COM;.EXE;.BAT;.CMD").split(os.pathsep)
72
+ names = [name + ext for ext in exts if ext]
73
+ for entry in os.environ.get("PATH", os.defpath).split(os.pathsep):
74
+ if not entry or not os.path.isabs(entry):
75
+ continue
76
+ if cwd is not None and os.path.realpath(entry) == cwd:
77
+ continue
78
+ for candidate in names:
79
+ path = os.path.join(entry, candidate)
80
+ if os.path.isfile(path) and os.access(path, os.X_OK):
81
+ return path
82
+ return None
45
83
 
46
84
 
47
85
  def check_ffprobe(config: Config | None = None) -> bool:
@@ -162,7 +200,7 @@ def probe_file(file_path: str, config: Config | None = None) -> AudioProbeResult
162
200
  "json",
163
201
  "-show_format",
164
202
  "-show_streams",
165
- file_path,
203
+ ffprobe_input(file_path),
166
204
  ]
167
205
 
168
206
  result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
@@ -209,7 +247,7 @@ def probe_buffer(
209
247
  "json",
210
248
  "-show_format",
211
249
  "-show_streams",
212
- tmp_name,
250
+ ffprobe_input(tmp_name),
213
251
  ]
214
252
 
215
253
  result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepctl-shared-utils
3
- Version: 0.1.13
3
+ Version: 0.1.14
4
4
  Summary: Shared utilities for deepctl
5
5
  Author-email: Deepgram <devrel@deepgram.com>
6
6
  Maintainer-email: Deepgram <devrel@deepgram.com>