extensions.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. # Copyright 2026 The HuggingFace Team. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """Contains helper utilities for hf CLI extensions."""
  15. import errno
  16. import json
  17. import os
  18. import re
  19. import shutil
  20. import subprocess
  21. import venv
  22. from dataclasses import asdict, dataclass
  23. from datetime import datetime, timezone
  24. from pathlib import Path
  25. from typing import Annotated, Literal
  26. import typer
  27. from huggingface_hub.errors import CLIError, CLIExtensionInstallError, ConfirmationError
  28. from huggingface_hub.utils import StatusLine, get_session, logging
  29. from ._cli_utils import FormatWithAutoOpt, typer_factory
  30. from ._output import OutputFormatWithAuto, out
  31. DEFAULT_EXTENSION_OWNER = "huggingface"
  32. EXTENSIONS_ROOT = Path("~/.local/share/hf/extensions")
  33. MANIFEST_FILENAME = "manifest.json"
  34. EXTENSIONS_HELP = (
  35. "Manage hf CLI extensions.\n\n"
  36. "Security Warning: extensions are third-party executables or Python packages. "
  37. "Install only from sources you trust."
  38. )
  39. extensions_cli = typer_factory(help=EXTENSIONS_HELP)
  40. _EXTENSIONS_DEFAULT_BRANCH = "main" # Fallback when the GitHub API is unreachable.
  41. _EXTENSIONS_GITHUB_TOPIC = "hf-extension"
  42. _EXTENSIONS_DOWNLOAD_TIMEOUT = 10
  43. _EXTENSIONS_PIP_INSTALL_TIMEOUT = 300
  44. logger = logging.get_logger(__name__)
  45. @dataclass
  46. class ExtensionManifest:
  47. owner: str
  48. repo: str
  49. repo_id: str
  50. short_name: str
  51. executable_name: str
  52. executable_path: str
  53. type: Literal["binary", "python"]
  54. installed_at: datetime
  55. source: str
  56. description: str | None = None
  57. @classmethod
  58. def load(cls, path: Path) -> "ExtensionManifest":
  59. manifest_path = path / MANIFEST_FILENAME
  60. if not manifest_path.is_file():
  61. raise CLIError(f"Manifest file not found at {manifest_path}. Your extension may be corrupted.")
  62. data = json.loads(manifest_path.read_text())
  63. data["installed_at"] = datetime.fromisoformat(data["installed_at"])
  64. return ExtensionManifest(**data)
  65. def save(self, path: Path) -> None:
  66. manifest_path = path / MANIFEST_FILENAME
  67. manifest_path.parent.mkdir(parents=True, exist_ok=True)
  68. data = asdict(self)
  69. data["installed_at"] = self.installed_at.isoformat()
  70. manifest_path.write_text(json.dumps(data, indent=2, sort_keys=True))
  71. @extensions_cli.command(
  72. "install",
  73. examples=[
  74. "hf extensions install hf-claude",
  75. "hf extensions install hanouticelina/hf-claude",
  76. "hf extensions install alvarobartt/hf-mem",
  77. ],
  78. )
  79. def extension_install(
  80. ctx: typer.Context,
  81. repo_id: Annotated[
  82. str,
  83. typer.Argument(help="GitHub extension repository in `[OWNER/]hf-<name>` format."),
  84. ],
  85. force: Annotated[bool, typer.Option("--force", help="Overwrite if already installed.")] = False,
  86. ) -> None:
  87. """Install an extension from a public GitHub repository.
  88. Security warning: this installs a third-party executable or Python package.
  89. Install only from sources you trust.
  90. """
  91. owner, repo_name, short_name = _normalize_repo_id(repo_id)
  92. root_ctx = ctx.find_root()
  93. reserved_commands = set(getattr(root_ctx.command, "commands", {}).keys())
  94. if short_name in reserved_commands:
  95. raise CLIError(
  96. f"Cannot install extension '{short_name}' because it conflicts with an existing `hf {short_name}` command."
  97. )
  98. extension_dir = _get_extension_dir(short_name)
  99. extension_exists = extension_dir.exists()
  100. if extension_exists and not force:
  101. raise CLIError(f"Extension '{short_name}' is already installed. Use --force to overwrite.")
  102. branch, description = _resolve_github_repo_info(owner=owner, repo_name=repo_name)
  103. if extension_exists:
  104. shutil.rmtree(extension_dir)
  105. manifest = _install_extension_from_github(
  106. owner=owner,
  107. repo_name=repo_name,
  108. short_name=short_name,
  109. extension_dir=extension_dir,
  110. branch=branch,
  111. description=description,
  112. )
  113. ext_type = manifest.type.capitalize()
  114. print(f"{ext_type} extension installed successfully from {owner}/{repo_name}.")
  115. print(f"Run it with: hf {short_name}")
  116. @extensions_cli.command(
  117. "exec",
  118. context_settings={"allow_extra_args": True, "allow_interspersed_args": False, "ignore_unknown_options": True},
  119. examples=[
  120. "hf extensions exec claude -- --help",
  121. "hf extensions exec claude --model zai-org/GLM-5",
  122. ],
  123. )
  124. def extension_exec(
  125. ctx: typer.Context,
  126. name: Annotated[
  127. str,
  128. typer.Argument(help="Extension name (with or without `hf-` prefix)."),
  129. ],
  130. ) -> None:
  131. """Execute an installed extension."""
  132. short_name = _normalize_extension_name(name)
  133. executable_path = _resolve_installed_executable_path(short_name)
  134. if not executable_path.is_file():
  135. raise CLIError(f"Extension '{short_name}' is not installed.")
  136. exit_code = _execute_extension_binary(executable_path=executable_path, args=list(ctx.args))
  137. raise typer.Exit(code=exit_code)
  138. @extensions_cli.command("list | ls", examples=["hf extensions list"])
  139. def extension_list(format: FormatWithAutoOpt = OutputFormatWithAuto.auto) -> None:
  140. """List installed extension commands."""
  141. rows = [
  142. {
  143. "command": f"hf {manifest.short_name}",
  144. "source": str(manifest.repo_id),
  145. "type": str(manifest.type),
  146. "installed": manifest.installed_at.strftime("%Y-%m-%d"),
  147. "description": manifest.description,
  148. }
  149. for manifest in _list_installed_extensions()
  150. ]
  151. out.table(rows, id_key="command")
  152. @extensions_cli.command("search", examples=["hf extensions search"])
  153. def extension_search(format: FormatWithAutoOpt = OutputFormatWithAuto.auto) -> None:
  154. """Search extensions available on GitHub (tagged with 'hf-extension' topic)."""
  155. response = get_session().get(
  156. "https://api.github.com/search/repositories",
  157. params={"q": f"topic:{_EXTENSIONS_GITHUB_TOPIC}", "sort": "stars", "order": "desc", "per_page": 100},
  158. follow_redirects=True,
  159. timeout=_EXTENSIONS_DOWNLOAD_TIMEOUT,
  160. )
  161. response.raise_for_status()
  162. data = response.json()
  163. installed = {m.short_name for m in _list_installed_extensions()}
  164. rows = []
  165. for repo in data.get("items", []):
  166. repo_name = repo["name"]
  167. short_name = repo_name[3:] if repo_name.startswith("hf-") else repo_name
  168. rows.append(
  169. {
  170. "name": short_name,
  171. "repo": repo["full_name"],
  172. "stars": repo.get("stargazers_count", 0),
  173. "description": repo.get("description") or "",
  174. "installed": "yes" if short_name in installed else "",
  175. }
  176. )
  177. out.table(rows, id_key="repo", alignments={"stars": "right"})
  178. @extensions_cli.command("remove | rm", examples=["hf extensions remove claude"])
  179. def extension_remove(
  180. name: Annotated[
  181. str,
  182. typer.Argument(help="Extension name to remove (with or without `hf-` prefix)."),
  183. ],
  184. ) -> None:
  185. """Remove an installed extension."""
  186. short_name = _normalize_extension_name(name)
  187. extension_dir = _get_extension_dir(short_name)
  188. if not extension_dir.is_dir():
  189. raise CLIError(f"Extension '{short_name}' is not installed.")
  190. shutil.rmtree(extension_dir)
  191. print(f"Removed extension '{short_name}'.")
  192. ### HELPER FUNCTIONS
  193. def _list_installed_extensions() -> list[ExtensionManifest]:
  194. """Return manifests for all validly-installed extensions, sorted by directory name."""
  195. root_dir = EXTENSIONS_ROOT.expanduser()
  196. if not root_dir.is_dir():
  197. return []
  198. manifests = []
  199. for extension_dir in sorted(root_dir.iterdir()):
  200. if not extension_dir.is_dir() or not extension_dir.name.startswith("hf-"):
  201. continue
  202. try:
  203. manifests.append(ExtensionManifest.load(extension_dir))
  204. except Exception as e:
  205. logger.debug(f"Failed to load manifest for extension '{extension_dir.name}': {e}")
  206. continue
  207. return manifests
  208. def list_installed_extensions_for_help() -> list[tuple[str, str]]:
  209. entries = []
  210. for manifest in _list_installed_extensions():
  211. tag = f"[extension {manifest.repo_id}]"
  212. help_text = f"{manifest.description} {tag}" if manifest.description is not None else tag
  213. entries.append((manifest.short_name, help_text))
  214. return entries
  215. def dispatch_unknown_top_level_extension(args: list[str], known_commands: set[str]) -> int | None:
  216. if not args:
  217. return None
  218. command_name = args[0]
  219. if command_name.startswith("-"):
  220. return None
  221. all_known = {a.strip() for cmd in known_commands for a in cmd.split("|")}
  222. if command_name in all_known:
  223. return None
  224. short_name = command_name[3:] if command_name.startswith("hf-") else command_name
  225. if not short_name:
  226. return None
  227. executable_path: Path | None = None
  228. try:
  229. executable_path = _resolve_installed_executable_path(short_name)
  230. except Exception:
  231. executable_path = _auto_install_official_extension(short_name)
  232. if executable_path is None or not executable_path.is_file():
  233. return None
  234. return _execute_extension_binary(executable_path=executable_path, args=list(args[1:]))
  235. def _auto_install_official_extension(short_name: str) -> Path | None:
  236. """Try to auto-install huggingface/hf-<name>. Returns executable path or None."""
  237. owner, repo_name = DEFAULT_EXTENSION_OWNER, f"hf-{short_name}"
  238. try:
  239. extension_dir = _get_extension_dir(short_name)
  240. except Exception:
  241. return None
  242. if extension_dir.exists():
  243. return None
  244. try:
  245. response = get_session().get(
  246. f"https://api.github.com/repos/{owner}/{repo_name}",
  247. follow_redirects=True,
  248. timeout=_EXTENSIONS_DOWNLOAD_TIMEOUT,
  249. )
  250. if response.status_code == 404:
  251. return None
  252. response.raise_for_status()
  253. branch = response.json()["default_branch"]
  254. except Exception:
  255. return None
  256. try:
  257. out.confirm(f"'{short_name}' is an official Hugging Face extension ({owner}/{repo_name}). Install it?")
  258. except ConfirmationError:
  259. return None
  260. try:
  261. manifest = _install_extension_from_github(
  262. owner=owner, repo_name=repo_name, short_name=short_name, extension_dir=extension_dir, branch=branch
  263. )
  264. return Path(manifest.executable_path).expanduser()
  265. except Exception:
  266. shutil.rmtree(extension_dir, ignore_errors=True)
  267. return None
  268. def _install_extension_from_github(
  269. *,
  270. owner: str,
  271. repo_name: str,
  272. short_name: str,
  273. extension_dir: Path,
  274. branch: str,
  275. description: str | None = None,
  276. ) -> ExtensionManifest:
  277. """Fetch, install (binary or Python), and save manifest for a GitHub extension."""
  278. try:
  279. binary = _fetch_remote_binary(owner=owner, repo_name=repo_name, branch=branch, short_name=short_name)
  280. except Exception:
  281. binary = None
  282. if binary is not None:
  283. manifest = _install_binary_extension(
  284. owner=owner, repo_name=repo_name, short_name=short_name, extension_dir=extension_dir, binary=binary
  285. )
  286. else:
  287. manifest = _install_python_extension(
  288. owner=owner, repo_name=repo_name, short_name=short_name, extension_dir=extension_dir, branch=branch
  289. )
  290. manifest.description = _try_fetch_remote_description(
  291. owner=owner, repo_name=repo_name, branch=branch, candidate_description=description
  292. )
  293. manifest.save(extension_dir)
  294. return manifest
  295. def _fetch_remote_binary(owner: str, repo_name: str, branch: str, short_name: str) -> bytes:
  296. executable_name = _get_executable_name(short_name)
  297. raw_url = f"https://raw.githubusercontent.com/{owner}/{repo_name}/refs/heads/{branch}/{executable_name}"
  298. response = get_session().get(raw_url, follow_redirects=True, timeout=_EXTENSIONS_DOWNLOAD_TIMEOUT)
  299. response.raise_for_status()
  300. return response.content
  301. def _install_binary_extension(
  302. *, owner: str, repo_name: str, short_name: str, extension_dir: Path, binary: bytes
  303. ) -> ExtensionManifest:
  304. # Save extension binary
  305. executable_name = _get_executable_name(short_name)
  306. extension_dir.mkdir(parents=True, exist_ok=False)
  307. executable_path = extension_dir / executable_name
  308. executable_path.write_bytes(binary)
  309. # Make it executable
  310. if os.name != "nt":
  311. os.chmod(executable_path, 0o755)
  312. # Create manifest
  313. return ExtensionManifest(
  314. owner=owner,
  315. repo=repo_name,
  316. repo_id=f"{owner}/{repo_name}",
  317. short_name=short_name,
  318. executable_name=executable_name,
  319. executable_path=str(executable_path),
  320. type="binary",
  321. installed_at=datetime.now(timezone.utc),
  322. source=f"https://github.com/{owner}/{repo_name}",
  323. )
  324. def _install_python_extension(
  325. *, owner: str, repo_name: str, short_name: str, extension_dir: Path, branch: str
  326. ) -> ExtensionManifest:
  327. source_url = f"https://github.com/{owner}/{repo_name}/archive/refs/heads/{branch}.zip"
  328. venv_dir = extension_dir / "venv"
  329. installed = False
  330. status = StatusLine()
  331. try:
  332. status.update(f"Creating virtual environment in {venv_dir}")
  333. if extension_dir.exists():
  334. shutil.rmtree(extension_dir, ignore_errors=True)
  335. extension_dir.mkdir(parents=True, exist_ok=False)
  336. uv_path = shutil.which("uv")
  337. venv_python = _get_venv_python_path(venv_dir)
  338. if uv_path:
  339. subprocess.run([uv_path, "venv", str(venv_dir)], check=True)
  340. status.done(f"Virtual environment created in {venv_dir}")
  341. status.update(f"Installing package from {source_url}")
  342. subprocess.run(
  343. [uv_path, "pip", "install", "--python", str(venv_python), source_url],
  344. check=True,
  345. timeout=_EXTENSIONS_PIP_INSTALL_TIMEOUT,
  346. )
  347. else:
  348. venv.EnvBuilder(with_pip=True).create(str(venv_dir))
  349. status.done(f"Virtual environment created in {venv_dir}")
  350. status.update(f"Installing package from {source_url}")
  351. subprocess.run(
  352. [
  353. str(venv_python),
  354. "-m",
  355. "pip",
  356. "install",
  357. "--disable-pip-version-check",
  358. "--no-input",
  359. source_url,
  360. ],
  361. check=True,
  362. timeout=_EXTENSIONS_PIP_INSTALL_TIMEOUT,
  363. )
  364. status.done(f"Package installed from {source_url}")
  365. executable_name = _get_executable_name(short_name)
  366. venv_executable = _get_venv_extension_executable_path(venv_dir, short_name)
  367. if not venv_executable.is_file():
  368. raise CLIError(
  369. f"Installed package from '{owner}/{repo_name}' does not expose the required console script "
  370. f"'{executable_name}'."
  371. )
  372. manifest = ExtensionManifest(
  373. owner=owner,
  374. repo=repo_name,
  375. repo_id=f"{owner}/{repo_name}",
  376. short_name=short_name,
  377. executable_name=executable_name,
  378. executable_path=str(venv_executable.resolve()),
  379. type="python",
  380. installed_at=datetime.now(timezone.utc),
  381. source=f"https://github.com/{owner}/{repo_name}",
  382. )
  383. installed = True
  384. return manifest
  385. except CLIError:
  386. raise
  387. except subprocess.TimeoutExpired as e:
  388. raise CLIExtensionInstallError(
  389. f"Pip install timed out after {_EXTENSIONS_PIP_INSTALL_TIMEOUT}s for '{owner}/{repo_name}'. "
  390. "See pip output above for details."
  391. ) from e
  392. except subprocess.CalledProcessError as e:
  393. raise CLIExtensionInstallError(
  394. f"Failed to install pip package from '{owner}/{repo_name}' (exit code {e.returncode}). "
  395. "See pip output above for details."
  396. ) from e
  397. except Exception as e:
  398. raise CLIExtensionInstallError(f"Failed to set up pip extension from '{owner}/{repo_name}': {e}") from e
  399. finally:
  400. if not installed:
  401. shutil.rmtree(extension_dir, ignore_errors=True)
  402. def _try_fetch_remote_description(
  403. owner: str, repo_name: str, branch: str, candidate_description: str | None
  404. ) -> str | None:
  405. """Try to fetch project description either from:
  406. - manifest.json
  407. - pyproject.toml
  408. Only best effort, no error handling.
  409. """
  410. # from manifest.json
  411. try:
  412. response = get_session().get(
  413. f"https://raw.githubusercontent.com/{owner}/{repo_name}/refs/heads/{branch}/{MANIFEST_FILENAME}",
  414. follow_redirects=True,
  415. )
  416. response.raise_for_status()
  417. data = response.json()
  418. description = data.get("description")
  419. if isinstance(description, str):
  420. return description
  421. except Exception:
  422. pass
  423. # from pyproject.toml
  424. try:
  425. response = get_session().get(
  426. f"https://raw.githubusercontent.com/{owner}/{repo_name}/refs/heads/{branch}/pyproject.toml",
  427. follow_redirects=True,
  428. )
  429. response.raise_for_status()
  430. # Weak parser but ok for "best effort"
  431. for line in response.text.splitlines():
  432. line = line.strip()
  433. if line.startswith("description"):
  434. _, _, value = line.partition("=")
  435. return value.strip().strip("\"'")
  436. except Exception:
  437. pass
  438. # fallback to value fetched from GH API directly
  439. return candidate_description
  440. def _get_extensions_root() -> Path:
  441. root_dir = EXTENSIONS_ROOT.expanduser()
  442. root_dir.mkdir(parents=True, exist_ok=True)
  443. return root_dir
  444. def _get_extension_dir(short_name: str) -> Path:
  445. safe_name = _validate_extension_short_name(short_name, original_input=short_name)
  446. root = _get_extensions_root().resolve()
  447. target = (root / f"hf-{safe_name}").resolve()
  448. if root not in target.parents:
  449. raise CLIError(f"Invalid extension name '{short_name}'.")
  450. return target
  451. def _resolve_github_repo_info(owner: str, repo_name: str) -> tuple[str, str | None]:
  452. try:
  453. response = get_session().get(
  454. f"https://api.github.com/repos/{owner}/{repo_name}",
  455. follow_redirects=True,
  456. timeout=_EXTENSIONS_DOWNLOAD_TIMEOUT,
  457. )
  458. response.raise_for_status()
  459. data = response.json()
  460. return data["default_branch"], data.get("description")
  461. except Exception:
  462. return _EXTENSIONS_DEFAULT_BRANCH, None
  463. def _get_executable_name(short_name: str) -> str:
  464. name = f"hf-{short_name}"
  465. if os.name == "nt":
  466. name += ".exe"
  467. return name
  468. def _resolve_installed_executable_path(short_name: str) -> Path:
  469. extension_dir = _get_extension_dir(short_name)
  470. manifest = ExtensionManifest.load(extension_dir)
  471. return Path(manifest.executable_path).expanduser()
  472. def _get_venv_python_path(venv_dir: Path) -> Path:
  473. if os.name == "nt":
  474. return venv_dir / "Scripts" / "python.exe"
  475. return venv_dir / "bin" / "python"
  476. def _get_venv_extension_executable_path(venv_dir: Path, short_name: str) -> Path:
  477. executable_name = _get_executable_name(short_name)
  478. if os.name == "nt":
  479. return venv_dir / "Scripts" / executable_name
  480. return venv_dir / "bin" / executable_name
  481. _ALLOWED_EXTENSION_NAME = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]*$")
  482. def _validate_extension_short_name(short_name: str, *, original_input: str) -> str:
  483. name = short_name.strip()
  484. if not name:
  485. raise CLIError("Extension name cannot be empty.")
  486. if any(sep in name for sep in ("/", "\\")):
  487. raise CLIError(f"Invalid extension name '{original_input}'.")
  488. if ".." in name or ":" in name:
  489. raise CLIError(f"Invalid extension name '{original_input}'.")
  490. if not _ALLOWED_EXTENSION_NAME.fullmatch(name):
  491. raise CLIError(
  492. f"Invalid extension name '{original_input}'. Allowed characters: letters, digits, '.', '_' and '-'."
  493. )
  494. return name
  495. def _normalize_repo_id(repo_id: str) -> tuple[str, str, str]:
  496. if "://" in repo_id:
  497. raise CLIError("Only GitHub repositories in `[OWNER/]hf-<name>` format are supported.")
  498. parts = repo_id.split("/")
  499. if len(parts) == 1:
  500. owner = DEFAULT_EXTENSION_OWNER
  501. repo_name = parts[0]
  502. elif len(parts) == 2 and all(parts):
  503. owner, repo_name = parts
  504. else:
  505. raise CLIError(f"Expected `[OWNER/]REPO` format, got '{repo_id}'.")
  506. if not repo_name.startswith("hf-"):
  507. raise CLIError(f"Extension repository name must start with 'hf-', got '{repo_name}'.")
  508. short_name = repo_name[3:]
  509. if not short_name:
  510. raise CLIError("Invalid extension repository name 'hf-'.")
  511. _validate_extension_short_name(short_name, original_input=repo_id)
  512. return owner, repo_name, short_name
  513. def _normalize_extension_name(name: str) -> str:
  514. candidate = name.strip()
  515. if not candidate:
  516. raise CLIError("Extension name cannot be empty.")
  517. normalized = candidate[3:] if candidate.startswith("hf-") else candidate
  518. return _validate_extension_short_name(normalized, original_input=name)
  519. def _execute_extension_binary(executable_path: Path, args: list[str]) -> int:
  520. try:
  521. return subprocess.call([str(executable_path)] + args)
  522. except OSError as e:
  523. if os.name == "nt" or e.errno != errno.ENOEXEC:
  524. raise
  525. return subprocess.call(["sh", str(executable_path)] + args)