From ec16e54c109d92fe827b2ae7213a26b869f2a74f Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 25 Jul 2025 08:32:26 +0000 Subject: [PATCH] =?UTF-8?q?fix(binaries):=20=F0=9F=90=9B=20Improve=20local?= =?UTF-8?q?=20binary=20search=20functionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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`. --- .gitignore | 1 - unshackle/binaries/placehere.txt | 0 unshackle/core/binaries.py | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 unshackle/binaries/placehere.txt diff --git a/.gitignore b/.gitignore index 1071854..3ae19a4 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,6 @@ device_cert device_client_id_blob device_private_key device_vmp_blob -binaries/ unshackle/cache/ unshackle/cookies/ unshackle/certs/ diff --git a/unshackle/binaries/placehere.txt b/unshackle/binaries/placehere.txt new file mode 100644 index 0000000..e69de29 diff --git a/unshackle/core/binaries.py b/unshackle/core/binaries.py index 20d11ba..aa46a53 100644 --- a/unshackle/core/binaries.py +++ b/unshackle/core/binaries.py @@ -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)