MCPcopy
hub / github.com/pex-tool/pex / ensure_pagefind

Function ensure_pagefind

scripts/build-docs.py:82–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80
81
82def ensure_pagefind() -> PurePath:
83 pagefind_exe_path = PEX_DEV_DIR / pagefind_executable()
84 if pagefind_exe_path.is_file() and os.access(pagefind_exe_path, os.R_OK | os.X_OK):
85 return pagefind_exe_path
86
87 tmp_dir = PEX_DEV_DIR / ".tmp"
88 tmp_dir.mkdir(parents=True, exist_ok=True)
89 download_dir = Path(tempfile.mktemp(prefix="download-pagefind.", dir=tmp_dir))
90 atexit.register(shutil.rmtree, str(download_dir), ignore_errors=True)
91
92 tarball_url = (
93 f"https://github.com/CloudCannon/pagefind/releases/download/v{PAGEFIND_VERSION}/"
94 f"{PAGEFIND_NAME}-v{PAGEFIND_VERSION}-{target_triple()}.tar.gz"
95 )
96 out_path = download_dir / PurePath(unquote(urlparse(tarball_url).path)).name
97 out_path.parent.mkdir(parents=True, exist_ok=True)
98 with httpx.stream("GET", tarball_url, follow_redirects=True) as response, out_path.open(
99 "wb"
100 ) as out_fp:
101 for chunk in response.iter_bytes():
102 out_fp.write(chunk)
103 pagefind_exe = CURRENT_PLATFORM.binary_name(PAGEFIND_NAME)
104 with tarfile.open(out_path) as tf:
105 tf.extract(pagefind_exe, path=str(download_dir))
106 (download_dir / pagefind_exe).rename(pagefind_exe_path)
107
108 return pagefind_exe_path
109
110
111def execute_pagefind(args: Iterable[str]) -> None:

Callers 1

execute_pagefindFunction · 0.85

Calls 8

pagefind_executableFunction · 0.85
target_tripleFunction · 0.85
mktempMethod · 0.80
openMethod · 0.80
extractMethod · 0.80
registerMethod · 0.45
writeMethod · 0.45
binary_nameMethod · 0.45

Tested by

no test coverage detected