evo-cli 0.36.2__tar.gz → 0.36.4__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 (157) hide show
  1. {evo_cli-0.36.2 → evo_cli-0.36.4}/PKG-INFO +1 -1
  2. evo_cli-0.36.4/evo_cli/VERSION +1 -0
  3. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/download.py +106 -5
  4. evo_cli-0.36.4/evo_cli/commands/route/_dnswatch.py +6 -0
  5. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/route/_spoofdpi.py +145 -25
  6. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/route/fix.py +5 -0
  7. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/route/status.py +2 -0
  8. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli.egg-info/PKG-INFO +1 -1
  9. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli.egg-info/SOURCES.txt +1 -0
  10. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_download.py +127 -0
  11. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_route.py +147 -4
  12. evo_cli-0.36.2/evo_cli/VERSION +0 -1
  13. {evo_cli-0.36.2 → evo_cli-0.36.4}/Containerfile +0 -0
  14. {evo_cli-0.36.2 → evo_cli-0.36.4}/HISTORY.md +0 -0
  15. {evo_cli-0.36.2 → evo_cli-0.36.4}/LICENSE +0 -0
  16. {evo_cli-0.36.2 → evo_cli-0.36.4}/MANIFEST.in +0 -0
  17. {evo_cli-0.36.2 → evo_cli-0.36.4}/README.md +0 -0
  18. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/__init__.py +0 -0
  19. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/__main__.py +0 -0
  20. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/base.py +0 -0
  21. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/cli.py +0 -0
  22. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/__init__.py +0 -0
  23. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/agent_toy.py +0 -0
  24. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/claude_code.py +0 -0
  25. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/cloudflare.py +0 -0
  26. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/cred.py +0 -0
  27. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/fix_claude.py +0 -0
  28. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/gdrive.py +0 -0
  29. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/gh.py +0 -0
  30. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/__init__.py +0 -0
  31. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/_dag.py +0 -0
  32. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/_git.py +0 -0
  33. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/_hub.py +0 -0
  34. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/_mirror.py +0 -0
  35. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/_model.py +0 -0
  36. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/_mutate.py +0 -0
  37. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/_paths.py +0 -0
  38. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/_render.py +0 -0
  39. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/_server.py +0 -0
  40. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/check.py +0 -0
  41. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/clone.py +0 -0
  42. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/edit.py +0 -0
  43. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/pull.py +0 -0
  44. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/serve.py +0 -0
  45. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/show.py +0 -0
  46. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/views.py +0 -0
  47. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/index-Cs7hXRPJ.css +0 -0
  48. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/index-CuNOlaH7.js +0 -0
  49. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  50. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  51. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  52. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  53. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  54. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  55. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  56. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  57. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  58. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  59. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  60. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  61. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/harness/web/index.html +0 -0
  62. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/hwid.py +0 -0
  63. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/hwid_reset.py +0 -0
  64. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/image.py +0 -0
  65. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/localproxy.py +0 -0
  66. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/mcp.py +0 -0
  67. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/miniconda.py +0 -0
  68. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/netcheck.py +0 -0
  69. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/ngrok.py +0 -0
  70. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/opencode.py +0 -0
  71. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/openvpn.py +0 -0
  72. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/plantuml.py +0 -0
  73. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/route/__init__.py +0 -0
  74. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/route/_dns.py +0 -0
  75. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/route/_dpi.py +0 -0
  76. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/route/_hosts.py +0 -0
  77. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/route/_page.py +0 -0
  78. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/route/_probe.py +0 -0
  79. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/route/check.py +0 -0
  80. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/route/probe.py +0 -0
  81. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/serp.py +0 -0
  82. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/site2s.py +0 -0
  83. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/ssh.py +0 -0
  84. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/storage.py +0 -0
  85. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/sysmon.py +0 -0
  86. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/tts.py +0 -0
  87. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/update.py +0 -0
  88. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/commands/wifi.py +0 -0
  89. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/console.py +0 -0
  90. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/credentials/__init__.py +0 -0
  91. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/credentials/doctor.py +0 -0
  92. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/credentials/google_oauth.py +0 -0
  93. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/credentials/migrate.py +0 -0
  94. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/credentials/oauth_flow.py +0 -0
  95. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/credentials/registry.py +0 -0
  96. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/credentials/store.py +0 -0
  97. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/credentials/sync.py +0 -0
  98. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/imaging/__init__.py +0 -0
  99. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/imaging/align.py +0 -0
  100. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/imaging/core.py +0 -0
  101. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/imaging/creds.py +0 -0
  102. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/imaging/errors.py +0 -0
  103. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/imaging/gemini.py +0 -0
  104. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/imaging/ncnn.py +0 -0
  105. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/mcp_registry.py +0 -0
  106. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/openvpn.py +0 -0
  107. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/serp/__init__.py +0 -0
  108. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/serp/client.py +0 -0
  109. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/serp/creds.py +0 -0
  110. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/serp/errors.py +0 -0
  111. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/serp/install.py +0 -0
  112. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/serp/render.py +0 -0
  113. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/tts/__init__.py +0 -0
  114. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/tts/chunking.py +0 -0
  115. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/tts/core.py +0 -0
  116. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/tts/creds.py +0 -0
  117. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/tts/errors.py +0 -0
  118. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/tts/gemini.py +0 -0
  119. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/tts/http.py +0 -0
  120. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/tts/openai.py +0 -0
  121. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/tts/player.py +0 -0
  122. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli/tts/vbee.py +0 -0
  123. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli.egg-info/dependency_links.txt +0 -0
  124. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli.egg-info/entry_points.txt +0 -0
  125. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli.egg-info/requires.txt +0 -0
  126. {evo_cli-0.36.2 → evo_cli-0.36.4}/evo_cli.egg-info/top_level.txt +0 -0
  127. {evo_cli-0.36.2 → evo_cli-0.36.4}/pyproject.toml +0 -0
  128. {evo_cli-0.36.2 → evo_cli-0.36.4}/setup.cfg +0 -0
  129. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/__init__.py +0 -0
  130. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/fake_evo_agents.py +0 -0
  131. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/fixtures/hub/contract-0.2.0.json +0 -0
  132. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/fixtures/hub/mirror-demo.yaml +0 -0
  133. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_agent_toy.py +0 -0
  134. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_claude_code.py +0 -0
  135. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_cli.py +0 -0
  136. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_console.py +0 -0
  137. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_cred.py +0 -0
  138. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_fix_claude.py +0 -0
  139. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_gdrive.py +0 -0
  140. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_gh.py +0 -0
  141. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_harness.py +0 -0
  142. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_harness_clone.py +0 -0
  143. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_harness_dag.py +0 -0
  144. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_harness_hub.py +0 -0
  145. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_harness_show.py +0 -0
  146. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_image.py +0 -0
  147. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_mcp.py +0 -0
  148. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_ngrok.py +0 -0
  149. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_opencode.py +0 -0
  150. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_openvpn.py +0 -0
  151. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_plantuml.py +0 -0
  152. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_serp.py +0 -0
  153. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_storage.py +0 -0
  154. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_sysmon.py +0 -0
  155. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_tts.py +0 -0
  156. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_update.py +0 -0
  157. {evo_cli-0.36.2 → evo_cli-0.36.4}/tests/test_wifi.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: evo_cli
3
- Version: 0.36.2
3
+ Version: 0.36.4
4
4
  Summary: Evolution CLI - a developer toolbox for setting up dev machines
5
5
  Author: maycuatroi
6
6
  Project-URL: Homepage, https://github.com/maycuatroi/evo-cli
@@ -0,0 +1 @@
1
+ 0.36.4
@@ -2,10 +2,12 @@ import datetime
2
2
  import importlib.util
3
3
  import json
4
4
  import os
5
+ import re
5
6
  import shutil
6
7
  import subprocess
7
8
  import sys
8
9
  import tempfile
10
+ import zipfile
9
11
  from pathlib import Path
10
12
  from urllib.parse import unquote, urlparse
11
13
 
@@ -30,6 +32,13 @@ CONTAINERS = ["mp4", "mkv", "webm", "auto"]
30
32
  BROWSERS = ["chrome", "edge", "firefox", "brave", "chromium", "opera", "vivaldi", "safari"]
31
33
  JS_RUNTIMES = ["deno", "bun", "node"]
32
34
  YTDLP_STALE_DAYS = 60
35
+ # The `default` extra pulls in yt-dlp-ejs, the script yt-dlp runs to solve
36
+ # YouTube's JS challenges. Without it YouTube hands back images only, even with
37
+ # node or deno on PATH.
38
+ YTDLP_PACKAGE = "yt-dlp[default]"
39
+ # pip writes this two-line shebang instead of `#!<python>` when the interpreter
40
+ # path has spaces or is too long for the kernel.
41
+ PIP_SH_SHEBANG = re.compile(r"^'''exec' (?:\"([^\"]+)\"|(\S+))")
33
42
  # Codecs an MP4 is actually expected to carry. Facebook reels and YouTube serve
34
43
  # their best streams as VP9 / AV1, and muxing those into MP4 gives a file that
35
44
  # QuickTime, Photos and iMovie open with sound but a black picture - the picture
@@ -346,8 +355,95 @@ def find_js_runtime():
346
355
  return None, None
347
356
 
348
357
 
358
+ def script_interpreter(exe):
359
+ """The Python a pip-installed `yt-dlp` script runs on, or None for a standalone build.
360
+
361
+ `evo download` runs whichever yt-dlp is first on PATH, which is rarely the
362
+ Python evo itself lives in (a uv tool venv with no pip), so updates have to
363
+ go to the interpreter that owns this script.
364
+ """
365
+ path = Path(os.path.realpath(exe))
366
+ if os.name == "nt":
367
+ for folder in (path.parent, path.parent.parent):
368
+ candidate = folder / "python.exe"
369
+ if candidate.is_file():
370
+ return str(candidate)
371
+ return None
372
+ # The official Unix release is a zipapp with `#!/usr/bin/env python3`: the
373
+ # shebang names a Python, but that Python does not own it.
374
+ if not path.is_file() or zipfile.is_zipfile(path):
375
+ return None
376
+ try:
377
+ with open(path, "rb") as handle:
378
+ head = [handle.readline(1024).decode("utf-8", "replace").strip() for _ in range(2)]
379
+ except OSError:
380
+ return None
381
+ if not head[0].startswith("#!"):
382
+ return None
383
+ parts = head[0][2:].split()
384
+ if not parts:
385
+ return None
386
+ if parts[0] == "/bin/sh":
387
+ match = PIP_SH_SHEBANG.match(head[1])
388
+ return (match.group(1) or match.group(2)) if match else None
389
+ if Path(parts[0]).name == "env":
390
+ return shutil.which(parts[1]) if len(parts) > 1 else None
391
+ return parts[0]
392
+
393
+
394
+ def has_pip(python):
395
+ try:
396
+ result = subprocess.run([python, "-m", "pip", "--version"], capture_output=True, check=False)
397
+ except OSError:
398
+ return False
399
+ return result.returncode == 0
400
+
401
+
402
+ def pip_install_command(python):
403
+ """How to install YTDLP_PACKAGE into `python`, or None when nothing can."""
404
+ uv = shutil.which("uv")
405
+ venv = Path(python).parent.parent
406
+ if uv and venv.name == "yt-dlp" and (venv / "uv-receipt.toml").is_file():
407
+ # A `uv tool install yt-dlp` venv: go through uv tool so the receipt
408
+ # keeps the extra and a later `uv tool upgrade` does not drop it.
409
+ return [uv, "tool", "install", "--upgrade", YTDLP_PACKAGE]
410
+ if has_pip(python):
411
+ return [python, "-m", "pip", "install", "-U", YTDLP_PACKAGE]
412
+ if uv:
413
+ return [uv, "pip", "install", "--python", python, "-U", YTDLP_PACKAGE]
414
+ return None
415
+
416
+
417
+ def ytdlp_install_command():
418
+ """The command that installs or updates the yt-dlp `evo download` runs."""
419
+ cmd = ytdlp_command()
420
+ if cmd is None:
421
+ uv = shutil.which("uv")
422
+ if uv:
423
+ return [uv, "tool", "install", "--upgrade", YTDLP_PACKAGE]
424
+ if has_pip(sys.executable):
425
+ return [sys.executable, "-m", "pip", "install", "-U", YTDLP_PACKAGE]
426
+ return None
427
+ if cmd[0] == sys.executable and cmd[1:] == ["-m", "yt_dlp"]:
428
+ return pip_install_command(sys.executable)
429
+ exe = cmd[0]
430
+ brew = shutil.which("brew")
431
+ if brew and "/Cellar/yt-dlp/" in os.path.realpath(exe).replace(os.sep, "/"):
432
+ return [brew, "upgrade", "yt-dlp"]
433
+ python = script_interpreter(exe)
434
+ if python is None:
435
+ return [exe, "-U"]
436
+ return pip_install_command(python)
437
+
438
+
349
439
  def install_ytdlp():
350
- run_command([sys.executable, "-m", "pip", "install", "-U", "yt-dlp"], status="Installing yt-dlp")
440
+ cmd = ytdlp_install_command()
441
+ if cmd is None:
442
+ raise click.ClickException(
443
+ "No pip or uv to install yt-dlp with. Install uv (https://docs.astral.sh/uv/), "
444
+ f'then run: uv tool install "{YTDLP_PACKAGE}"'
445
+ )
446
+ run_command(cmd, status="Installing yt-dlp")
351
447
 
352
448
 
353
449
  def detect_package_manager():
@@ -385,12 +481,14 @@ def ensure_ytdlp(assume_yes=False):
385
481
  warn_if_stale()
386
482
  return cmd
387
483
  warning("yt-dlp is not installed.")
388
- if not assume_yes and not click.confirm("Install yt-dlp now with pip?", default=True):
389
- raise click.ClickException("yt-dlp is required. Install it with: pip install -U yt-dlp")
484
+ if not assume_yes and not click.confirm("Install yt-dlp now?", default=True):
485
+ raise click.ClickException(f'yt-dlp is required. Install it with: uv tool install "{YTDLP_PACKAGE}"')
390
486
  install_ytdlp()
391
487
  cmd = ytdlp_command()
392
488
  if not cmd:
393
- raise click.ClickException("yt-dlp was installed but could not be found. Check your PATH.")
489
+ raise click.ClickException(
490
+ "yt-dlp was installed but is not on PATH. Run `uv tool update-shell`, open a new terminal, try again."
491
+ )
394
492
  return cmd
395
493
 
396
494
 
@@ -878,7 +976,10 @@ def formats_cmd(url, cookies, assume_yes):
878
976
  "install",
879
977
  context_settings={"help_option_names": ["-h", "--help"]},
880
978
  help=(
881
- "Install or update **yt-dlp** (via pip).\n\n"
979
+ "Install or update **yt-dlp**, with yt-dlp-ejs for YouTube's JS challenges.\n\n"
980
+ "It updates the copy `evo download` runs, where it was installed from: pip, "
981
+ "uv tool, Homebrew or a standalone build. With none on PATH it installs one "
982
+ "with `uv tool install`.\n\n"
882
983
  "With `--with-deps` it also installs **ffmpeg** using whichever package manager "
883
984
  "it detects (apt, dnf, pacman, brew, winget, choco)."
884
985
  ),
@@ -0,0 +1,6 @@
1
+ """Run by the com.evo.route.dns LaunchAgent: re-pick how the opened hosts resolve after a change of network."""
2
+
3
+ from evo_cli.commands.route import _spoofdpi
4
+
5
+ if __name__ == "__main__":
6
+ _spoofdpi.refresh()
@@ -5,23 +5,32 @@ TLS ClientHello, so the filter never reads the server name in one piece. It only
5
5
  does that for the hosts `evo route open` named: every other name passes through
6
6
  untouched and resolves with the system's DNS server (SpoofDPI's own resolver,
7
7
  which does not read /etc/resolver). The named hosts resolve over DoH instead,
8
- because a name the filter blocks usually has its DNS answer poisoned too.
8
+ because a name the filter blocks usually has its DNS answer poisoned too, except
9
+ on a network where the DoH endpoint does not answer: see `dns_mode`.
9
10
  """
10
11
 
11
12
  from __future__ import annotations
12
13
 
14
+ import base64
15
+ import http.client
13
16
  import json
14
17
  import os
15
18
  import plistlib
19
+ import re
16
20
  import shutil
17
21
  import socket
22
+ import struct
18
23
  import subprocess
24
+ import sys
19
25
  import time
26
+ import urllib.request
20
27
  from pathlib import Path
21
28
 
29
+ from evo_cli.commands.route import _dns
22
30
  from evo_cli.console import info, run_command
23
31
 
24
32
  LABEL = "com.evo.route.spoofdpi"
33
+ DNS_LABEL = "com.evo.route.dns"
25
34
  LISTEN_HOST = "127.0.0.1"
26
35
  # Off 8080, where development servers live.
27
36
  LISTEN_PORT = 18080
@@ -34,7 +43,25 @@ LISTEN_PORT = 18080
34
43
  SPLIT_MODE = "chunk"
35
44
  CHUNK_SIZE = 16
36
45
 
37
- CONFIG = f"""# Written by `evo route open`; the hosts it opened are listed in hosts.txt.
46
+ # SpoofDPI asks this one DoH endpoint and has no fallback, so a network that blocks
47
+ # it (an office network that keeps DNS to its own resolver, 2026-11) fails every
48
+ # opened host with a 502. There the opened hosts use the system's resolver.
49
+ DOH_URL = "https://dns.google/dns-query"
50
+ # SpoofDPI gives a whole lookup 3 seconds.
51
+ DOH_TIMEOUT = 2.5
52
+ # Resolves on any network that is up, the way macOS checks for a captive portal.
53
+ ONLINE_PROBE = "captive.apple.com"
54
+ RESOLVERS = {"https": f"DoH ({DOH_URL})", "system": "the system resolver"}
55
+
56
+ # macOS rewrites this file on every change of network.
57
+ DNS_SETTINGS = "/var/run/resolv.conf"
58
+ # Catches a network that was not answering yet when its settings arrived.
59
+ DNS_RECHECK_SECONDS = 120
60
+
61
+
62
+ def config(dns_mode):
63
+ """SpoofDPI's config, with the opened hosts resolving by ``dns_mode``: "https" or "system"."""
64
+ return f"""# Written by `evo route open`; the hosts it opened are listed in hosts.txt.
38
65
  [dns]
39
66
  mode = "system"
40
67
 
@@ -45,10 +72,11 @@ skip = true
45
72
  name = "evo route open"
46
73
  priority = 50
47
74
  match = {{ domains = ["file:hosts.txt"] }}
48
- dns = {{ mode = "https", cache = true }}
75
+ dns = {{ mode = "{dns_mode}", https-url = "{DOH_URL}", cache = true }}
49
76
  https = {{ skip = false, split-mode = "{SPLIT_MODE}", chunk-size = {CHUNK_SIZE} }}
50
77
  """
51
78
 
79
+
52
80
  # networksetup names both proxies by these words: -getwebproxy, -setsecurewebproxystate, ...
53
81
  PROXY_KINDS = ("webproxy", "securewebproxy")
54
82
 
@@ -69,14 +97,18 @@ def hosts_path():
69
97
  return home() / "hosts.txt"
70
98
 
71
99
 
72
- def agent_path():
73
- return Path.home() / "Library" / "LaunchAgents" / f"{LABEL}.plist"
100
+ def agent_path(label=LABEL):
101
+ return Path.home() / "Library" / "LaunchAgents" / f"{label}.plist"
74
102
 
75
103
 
76
104
  def log_path():
77
105
  return Path.home() / "Library" / "Logs" / "evo-route-spoofdpi.log"
78
106
 
79
107
 
108
+ def dns_log_path():
109
+ return Path.home() / "Library" / "Logs" / "evo-route-dns.log"
110
+
111
+
80
112
  def listen():
81
113
  return f"{LISTEN_HOST}:{LISTEN_PORT}"
82
114
 
@@ -126,27 +158,33 @@ def _program(exe):
126
158
  return [exe, "--config", str(config_path()), "--no-tui", "--listen-addr", listen()]
127
159
 
128
160
 
129
- def _write_agent(exe):
130
- """Write the LaunchAgent; True when its content changed."""
131
- plist = plistlib.dumps(
132
- {
133
- "Label": LABEL,
134
- "ProgramArguments": _program(exe),
135
- "RunAtLoad": True,
136
- "KeepAlive": True,
137
- "StandardOutPath": str(log_path()),
138
- "StandardErrorPath": str(log_path()),
139
- }
140
- )
141
- path = agent_path()
161
+ def _write_plist(label, job, log):
162
+ """Write a LaunchAgent; True when its content changed."""
163
+ plist = plistlib.dumps({"Label": label, **job, "StandardOutPath": str(log), "StandardErrorPath": str(log)})
164
+ path = agent_path(label)
142
165
  if path.exists() and path.read_bytes() == plist:
143
166
  return False
144
167
  path.parent.mkdir(parents=True, exist_ok=True)
145
- log_path().parent.mkdir(parents=True, exist_ok=True)
168
+ log.parent.mkdir(parents=True, exist_ok=True)
146
169
  path.write_bytes(plist)
147
170
  return True
148
171
 
149
172
 
173
+ def _write_agent(exe):
174
+ return _write_plist(LABEL, {"ProgramArguments": _program(exe), "RunAtLoad": True, "KeepAlive": True}, log_path())
175
+
176
+
177
+ def _write_dns_agent():
178
+ """The agent that runs `refresh` with this Python whenever the network changes, and every few minutes."""
179
+ job = {
180
+ "ProgramArguments": [sys.executable, "-m", "evo_cli.commands.route._dnswatch"],
181
+ "RunAtLoad": True,
182
+ "WatchPaths": [DNS_SETTINGS],
183
+ "StartInterval": DNS_RECHECK_SECONDS,
184
+ }
185
+ return _write_plist(DNS_LABEL, job, dns_log_path())
186
+
187
+
150
188
  def _launchctl(*args):
151
189
  return subprocess.run(["launchctl", *args], capture_output=True, text=True, stdin=subprocess.DEVNULL, check=False)
152
190
 
@@ -155,8 +193,8 @@ def _domain():
155
193
  return f"gui/{os.getuid()}"
156
194
 
157
195
 
158
- def _loaded():
159
- return _launchctl("print", f"{_domain()}/{LABEL}").returncode == 0
196
+ def _loaded(label=LABEL):
197
+ return _launchctl("print", f"{_domain()}/{label}").returncode == 0
160
198
 
161
199
 
162
200
  def _listening(timeout=0.5):
@@ -302,6 +340,86 @@ def browser_overrides(support=None):
302
340
  return found
303
341
 
304
342
 
343
+ def _doh_answers():
344
+ """Whether DOH_URL answers from this network, asked as SpoofDPI asks it: straight, never through a proxy."""
345
+ question = struct.pack(">HHHHHH", 0, 0x0100, 1, 0, 0, 0) + _dns._encode_qname(ONLINE_PROBE)
346
+ question += struct.pack(">HH", 1, 1)
347
+ query = base64.urlsafe_b64encode(question).rstrip(b"=").decode()
348
+ request = urllib.request.Request(f"{DOH_URL}?dns={query}", headers={"accept": "application/dns-message"})
349
+ opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
350
+ try:
351
+ with opener.open(request, timeout=DOH_TIMEOUT) as response:
352
+ reply = response.read()
353
+ except (OSError, ValueError, http.client.HTTPException):
354
+ return False
355
+ # RCODE 0: the endpoint read the question and answered it.
356
+ return len(reply) >= 12 and reply[3] & 0x0F == 0
357
+
358
+
359
+ def _online():
360
+ try:
361
+ socket.getaddrinfo(ONLINE_PROBE, 80, type=socket.SOCK_STREAM)
362
+ except OSError:
363
+ return False
364
+ return True
365
+
366
+
367
+ def dns_mode():
368
+ """How the opened hosts should resolve on the network the Mac is on now.
369
+
370
+ Over DoH where its endpoint answers, since a blocked name is often a poisoned one too. With the system
371
+ resolver where it does not, which is the resolver such a network means to be used. None while nothing
372
+ answers at all, offline or before the network is up, when there is nothing to choose between.
373
+ """
374
+ if _doh_answers():
375
+ return "https"
376
+ return "system" if _online() else None
377
+
378
+
379
+ def current_dns_mode():
380
+ """How the opened hosts resolve in the config SpoofDPI runs with; None before evo wrote one."""
381
+ try:
382
+ text = config_path().read_text(encoding="utf-8")
383
+ except FileNotFoundError:
384
+ return None
385
+ found = re.search(r'^dns = \{ mode = "(\w+)"', text, re.MULTILINE)
386
+ return found.group(1) if found else None
387
+
388
+
389
+ def _write_config(dns_mode):
390
+ """Write SpoofDPI's config; True when its content changed."""
391
+ text = config(dns_mode)
392
+ path = config_path()
393
+ if path.exists() and path.read_text(encoding="utf-8") == text:
394
+ return False
395
+ home().mkdir(parents=True, exist_ok=True)
396
+ path.write_text(text, encoding="utf-8")
397
+ return True
398
+
399
+
400
+ def refresh():
401
+ """Resolve the opened hosts the way the current network allows; restart SpoofDPI only when that changes.
402
+
403
+ The DNS agent runs this on every change of network. Returns the mode in use, None while the bypass is off.
404
+ """
405
+ if not opened() or not _loaded():
406
+ return None
407
+ mode = dns_mode()
408
+ if mode is None:
409
+ return current_dns_mode()
410
+ if _write_config(mode):
411
+ _start(reload=False)
412
+ print(f"{time.strftime('%Y-%m-%d %H:%M:%S')} opened hosts now resolve with {RESOLVERS[mode]}", flush=True)
413
+ return mode
414
+
415
+
416
+ def _watch_network():
417
+ """(Re)load the DNS agent; launchd runs it once on load, then on every change of network."""
418
+ if _write_dns_agent() or not _loaded(DNS_LABEL):
419
+ _launchctl("bootout", f"{_domain()}/{DNS_LABEL}")
420
+ _launchctl("bootstrap", _domain(), str(agent_path(DNS_LABEL)))
421
+
422
+
305
423
  def service_state():
306
424
  exe = executable()
307
425
  return {
@@ -311,6 +429,7 @@ def service_state():
311
429
  "reason": None,
312
430
  "hosts": opened(),
313
431
  "proxy": proxied_services(),
432
+ "dns": current_dns_mode(),
314
433
  }
315
434
 
316
435
 
@@ -320,11 +439,11 @@ def ensure(*hosts):
320
439
  if conflicts:
321
440
  raise RuntimeError(f"A proxy is already set on {', '.join(conflicts)}; evo will not replace it.")
322
441
  exe = executable() or install()
323
- home().mkdir(parents=True, exist_ok=True)
324
- config_path().write_text(CONFIG, encoding="utf-8")
442
+ _write_config(dns_mode() or current_dns_mode() or "https")
325
443
  _write_hosts([*opened(), *hosts])
326
444
  if not _start(reload=_write_agent(exe)):
327
445
  return service_state()
446
+ _watch_network()
328
447
  set_system_proxy()
329
448
  return service_state()
330
449
 
@@ -342,7 +461,8 @@ def forget(host):
342
461
  def remove():
343
462
  """Clear the system proxy first, so nothing points at a proxy that is gone, then stop and drop the agent."""
344
463
  clear_system_proxy()
345
- _launchctl("bootout", f"{_domain()}/{LABEL}")
346
- agent_path().unlink(missing_ok=True)
464
+ for label in (DNS_LABEL, LABEL):
465
+ _launchctl("bootout", f"{_domain()}/{label}")
466
+ agent_path(label).unlink(missing_ok=True)
347
467
  hosts_path().unlink(missing_ok=True)
348
468
  return True
@@ -76,6 +76,11 @@ def _apply_spoofdpi(host, dry_run):
76
76
  error(f"SpoofDPI would not start - see {_spoofdpi.log_path()}")
77
77
  sys.exit(1)
78
78
  success(f"DPI bypass is running on {_spoofdpi.listen()}, system proxy set on {', '.join(state['proxy'])}")
79
+ if state.get("dns") == "system":
80
+ info(
81
+ f"{_spoofdpi.DOH_URL} does not answer on this network, so the opened hosts resolve with the system "
82
+ "resolver; evo switches them back to DoH on a network where it answers"
83
+ )
79
84
  return state
80
85
 
81
86
 
@@ -70,6 +70,8 @@ def status(as_json):
70
70
  console.print(f" [dim]{dpi['args']}[/dim]")
71
71
  if dpi.get("hosts"):
72
72
  info(f"Hosts: {', '.join(dpi['hosts'])} - remove with `evo route close <host>`")
73
+ if dpi.get("hosts") and dpi.get("dns") in _spoofdpi.RESOLVERS:
74
+ info(f"They resolve with {_spoofdpi.RESOLVERS[dpi['dns']]}, re-picked on every change of network")
73
75
  if dpi.get("proxy"):
74
76
  info(f"System proxy set on {', '.join(dpi['proxy'])}")
75
77
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: evo_cli
3
- Version: 0.36.2
3
+ Version: 0.36.4
4
4
  Summary: Evolution CLI - a developer toolbox for setting up dev machines
5
5
  Author: maycuatroi
6
6
  Project-URL: Homepage, https://github.com/maycuatroi/evo-cli
@@ -80,6 +80,7 @@ evo_cli/commands/harness/web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.wo
80
80
  evo_cli/commands/harness/web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2
81
81
  evo_cli/commands/route/__init__.py
82
82
  evo_cli/commands/route/_dns.py
83
+ evo_cli/commands/route/_dnswatch.py
83
84
  evo_cli/commands/route/_dpi.py
84
85
  evo_cli/commands/route/_hosts.py
85
86
  evo_cli/commands/route/_page.py
@@ -1,5 +1,8 @@
1
1
  import datetime
2
+ import os
2
3
  import subprocess
4
+ import sys
5
+ import zipfile
3
6
  from pathlib import Path
4
7
 
5
8
  import pytest
@@ -434,3 +437,127 @@ def test_failure_on_fresh_ytdlp_keeps_the_formats_hint(monkeypatch, tmp_path):
434
437
  result = CliRunner().invoke(cli, ["download", YOUTUBE, "-o", str(tmp_path)])
435
438
  assert result.exit_code != 0
436
439
  assert "evo download formats" in result.output.replace("\n", "")
440
+
441
+
442
+ posix_only = pytest.mark.skipif(os.name == "nt", reason="shebang scripts are a POSIX install layout")
443
+ PKG = dl.YTDLP_PACKAGE
444
+
445
+
446
+ def fake_which(monkeypatch, **tools):
447
+ # A plain dict lookup, so other callers of shutil.which cannot use it up.
448
+ monkeypatch.setattr(dl.shutil, "which", lambda name: tools.get(name))
449
+
450
+
451
+ def write_script(path, first_lines):
452
+ path.parent.mkdir(parents=True, exist_ok=True)
453
+ path.write_text(first_lines + "import sys\nfrom yt_dlp import main\n")
454
+ return path
455
+
456
+
457
+ def test_install_pulls_in_the_js_challenge_solver():
458
+ assert PKG == "yt-dlp[default]"
459
+
460
+
461
+ @posix_only
462
+ def test_install_targets_the_python_that_owns_the_path_ytdlp(monkeypatch, tmp_path):
463
+ script = write_script(tmp_path / "bin" / "yt-dlp", "#!/opt/anaconda3/bin/python\n")
464
+ monkeypatch.setattr(dl, "ytdlp_command", lambda: [str(script)])
465
+ monkeypatch.setattr(dl, "has_pip", lambda python: python == "/opt/anaconda3/bin/python")
466
+ fake_which(monkeypatch, uv="/u/uv")
467
+ assert dl.ytdlp_install_command() == ["/opt/anaconda3/bin/python", "-m", "pip", "install", "-U", PKG]
468
+
469
+
470
+ @posix_only
471
+ def test_install_reads_the_sh_shebang_pip_writes_for_long_paths(monkeypatch, tmp_path):
472
+ python = "/Users/me/My Envs/yt/bin/python"
473
+ quotes = "'" * 3
474
+ shebang = f'#!/bin/sh\n{quotes}exec\' "{python}" "$0" "$@"\n\' {quotes}\n'
475
+ script = write_script(tmp_path / "yt-dlp", shebang)
476
+ monkeypatch.setattr(dl, "ytdlp_command", lambda: [str(script)])
477
+ monkeypatch.setattr(dl, "has_pip", lambda p: p == python)
478
+ fake_which(monkeypatch)
479
+ assert dl.ytdlp_install_command() == [python, "-m", "pip", "install", "-U", PKG]
480
+
481
+
482
+ def test_install_into_a_venv_without_pip_goes_through_uv(monkeypatch):
483
+ # evo as a uv tool: its venv has yt_dlp importable but no pip.
484
+ monkeypatch.setattr(dl, "ytdlp_command", lambda: [sys.executable, "-m", "yt_dlp"])
485
+ monkeypatch.setattr(dl, "has_pip", lambda python: False)
486
+ fake_which(monkeypatch, uv="/u/uv")
487
+ assert dl.ytdlp_install_command() == ["/u/uv", "pip", "install", "--python", sys.executable, "-U", PKG]
488
+
489
+
490
+ @posix_only
491
+ def test_install_updates_a_uv_tool_ytdlp_through_uv_tool(monkeypatch, tmp_path):
492
+ venv = tmp_path / "tools" / "yt-dlp"
493
+ (venv / "bin").mkdir(parents=True)
494
+ (venv / "uv-receipt.toml").write_text('[tool]\nrequirements = [{ name = "yt-dlp" }]\n')
495
+ script = write_script(venv / "bin" / "yt-dlp", f"#!{venv / 'bin' / 'python'}\n")
496
+ monkeypatch.setattr(dl, "ytdlp_command", lambda: [str(script)])
497
+ monkeypatch.setattr(dl, "has_pip", lambda python: pytest.fail("uv tool venvs are updated by uv"))
498
+ fake_which(monkeypatch, uv="/u/uv")
499
+ assert dl.ytdlp_install_command() == ["/u/uv", "tool", "install", "--upgrade", PKG]
500
+
501
+
502
+ @posix_only
503
+ def test_install_upgrades_a_homebrew_ytdlp_with_brew(monkeypatch, tmp_path):
504
+ real = write_script(tmp_path / "Cellar" / "yt-dlp" / "2026.10.26" / "bin" / "yt-dlp", "#!/x/libexec/bin/python\n")
505
+ link = tmp_path / "bin" / "yt-dlp"
506
+ link.parent.mkdir()
507
+ link.symlink_to(real)
508
+ monkeypatch.setattr(dl, "ytdlp_command", lambda: [str(link)])
509
+ fake_which(monkeypatch, brew="/opt/homebrew/bin/brew", uv="/u/uv")
510
+ assert dl.ytdlp_install_command() == ["/opt/homebrew/bin/brew", "upgrade", "yt-dlp"]
511
+
512
+
513
+ def test_install_self_updates_a_standalone_binary(monkeypatch, tmp_path):
514
+ exe = tmp_path / "yt-dlp"
515
+ exe.write_bytes(b"\x7fELF\x02\x01\x01" + b"\x00" * 64)
516
+ monkeypatch.setattr(dl, "ytdlp_command", lambda: [str(exe)])
517
+ fake_which(monkeypatch, uv="/u/uv")
518
+ assert dl.ytdlp_install_command() == [str(exe), "-U"]
519
+
520
+
521
+ @posix_only
522
+ def test_install_self_updates_the_zipapp_release(monkeypatch, tmp_path):
523
+ exe = tmp_path / "yt-dlp"
524
+ with open(exe, "wb") as handle:
525
+ handle.write(b"#!/usr/bin/env python3\n")
526
+ with zipfile.ZipFile(handle, "w") as archive:
527
+ archive.writestr("__main__.py", "print('hi')\n")
528
+ monkeypatch.setattr(dl, "ytdlp_command", lambda: [str(exe)])
529
+ fake_which(monkeypatch, python3="/usr/bin/python3", uv="/u/uv")
530
+ assert dl.ytdlp_install_command() == [str(exe), "-U"]
531
+
532
+
533
+ def test_missing_ytdlp_is_installed_as_a_uv_tool(monkeypatch):
534
+ monkeypatch.setattr(dl, "ytdlp_command", lambda: None)
535
+ fake_which(monkeypatch, uv="/u/uv")
536
+ assert dl.ytdlp_install_command() == ["/u/uv", "tool", "install", "--upgrade", PKG]
537
+
538
+
539
+ def test_missing_ytdlp_without_uv_falls_back_to_pip(monkeypatch):
540
+ monkeypatch.setattr(dl, "ytdlp_command", lambda: None)
541
+ monkeypatch.setattr(dl, "has_pip", lambda python: True)
542
+ fake_which(monkeypatch)
543
+ assert dl.ytdlp_install_command() == [sys.executable, "-m", "pip", "install", "-U", PKG]
544
+
545
+
546
+ def test_install_without_pip_or_uv_says_how(monkeypatch):
547
+ monkeypatch.setattr(dl, "ytdlp_command", lambda: None)
548
+ monkeypatch.setattr(dl, "has_pip", lambda python: False)
549
+ fake_which(monkeypatch)
550
+ result = CliRunner().invoke(cli, ["download", "install"])
551
+ assert result.exit_code != 0
552
+ assert "uv tool install" in result.output
553
+
554
+
555
+ def test_install_command_runs_what_it_resolved(monkeypatch):
556
+ ran = []
557
+ monkeypatch.setattr(dl, "ytdlp_install_command", lambda: ["/u/uv", "tool", "install", "--upgrade", PKG])
558
+ monkeypatch.setattr(dl, "run_command", lambda cmd, **kw: ran.append(cmd))
559
+ monkeypatch.setattr(dl, "report_environment", lambda: None)
560
+ monkeypatch.setattr(dl, "ytdlp_version", lambda: "2026.10.26")
561
+ result = CliRunner().invoke(cli, ["download", "install"])
562
+ assert result.exit_code == 0, result.output
563
+ assert ran == [["/u/uv", "tool", "install", "--upgrade", PKG]]