fix: 7-ZipがPATH未登録でも標準インストール場所から見つけるように対応
実機実行時、7-ZipはインストールされているがPATHに7zコマンドが無くFileNotFoundErrorで失敗したため、 C:\Program Files\7-Zip\7z.exe 等へのフォールバック探索を追加。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
ed33892f08
commit
913b4f5431
@ -105,6 +105,24 @@ def setup_python(script_dst: Path, tmp_dir: Path) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
SEVEN_ZIP_FALLBACK_PATHS = (
|
||||||
|
r"C:\Program Files\7-Zip\7z.exe",
|
||||||
|
r"C:\Program Files (x86)\7-Zip\7z.exe",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def find_7zip_exe() -> str:
|
||||||
|
found = shutil.which("7z")
|
||||||
|
if found:
|
||||||
|
return found
|
||||||
|
for candidate in SEVEN_ZIP_FALLBACK_PATHS:
|
||||||
|
if Path(candidate).exists():
|
||||||
|
return candidate
|
||||||
|
raise RuntimeError(
|
||||||
|
"7-Zip(7z.exe)が見つかりません。PATHに通すか、標準的な場所にインストールしてください。"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_tesseract(script_dst: Path, tmp_dir: Path) -> None:
|
def setup_tesseract(script_dst: Path, tmp_dir: Path) -> None:
|
||||||
tools_dst = script_dst / "tools" / "tesseract"
|
tools_dst = script_dst / "tools" / "tesseract"
|
||||||
tools_dst.mkdir(parents=True)
|
tools_dst.mkdir(parents=True)
|
||||||
@ -112,10 +130,11 @@ def setup_tesseract(script_dst: Path, tmp_dir: Path) -> None:
|
|||||||
installer_path = tmp_dir / "tesseract-setup.exe"
|
installer_path = tmp_dir / "tesseract-setup.exe"
|
||||||
download(TESSERACT_INSTALLER_URL, installer_path)
|
download(TESSERACT_INSTALLER_URL, installer_path)
|
||||||
|
|
||||||
|
seven_zip_exe = find_7zip_exe()
|
||||||
extract_dir = tmp_dir / "tesseract-extract"
|
extract_dir = tmp_dir / "tesseract-extract"
|
||||||
extract_dir.mkdir()
|
extract_dir.mkdir()
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["7z", "x", str(installer_path), f"-o{extract_dir}", "-y"],
|
[seven_zip_exe, "x", str(installer_path), f"-o{extract_dir}", "-y"],
|
||||||
check=True,
|
check=True,
|
||||||
)
|
)
|
||||||
for item in extract_dir.iterdir():
|
for item in extract_dir.iterdir():
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user