fix(binaries): 🐛 Improve local binary search functionality

* Added logic to check for executables in a local `binaries` directory.
* Enhanced Windows support by checking for `.exe` extensions.
* Removed unnecessary `binaries/` entry from `.gitignore`.
This commit is contained in:
Andy
2025-07-25 08:32:26 +00:00
parent eaa5943b8e
commit ec16e54c10
3 changed files with 17 additions and 1 deletions

1
.gitignore vendored
View File

@@ -18,7 +18,6 @@ device_cert
device_client_id_blob
device_private_key
device_vmp_blob
binaries/
unshackle/cache/
unshackle/cookies/
unshackle/certs/

View File

View File

@@ -8,7 +8,24 @@ __shaka_platform = {"win32": "win", "darwin": "osx"}.get(sys.platform, sys.platf
def find(*names: str) -> Optional[Path]:
"""Find the path of the first found binary name."""
# Get the directory containing this file to find the local binaries folder
current_dir = Path(__file__).parent.parent
local_binaries_dir = current_dir / "binaries"
for name in names:
# First check local binaries folder
if local_binaries_dir.exists():
local_path = local_binaries_dir / name
if local_path.is_file() and local_path.stat().st_mode & 0o111: # Check if executable
return local_path
# Also check with .exe extension on Windows
if sys.platform == "win32":
local_path_exe = local_binaries_dir / f"{name}.exe"
if local_path_exe.is_file():
return local_path_exe
# Fall back to system PATH
path = shutil.which(name)
if path:
return Path(path)