minor WEBGPU_PATH cleanup [pr] (#9552)

also mypy recognizes `sys.platform == 'win32'` but does not recognizes it if wrapped inside a helper...
This commit is contained in:
chenyu
2025-03-23 09:10:02 -04:00
committed by GitHub
parent 7ce7fe0574
commit d734e24c01
2 changed files with 3 additions and 8 deletions
+1 -2
View File
@@ -9,9 +9,8 @@ if sys.platform == 'win32':
raise FileNotFoundError('LLVM not found, you can install it with `winget install LLVM.LLVM` or point at a custom dll with LLVM_PATH')
elif OSX:
# Will raise FileNotFoundError if brew is not installed
brew_prefix = subprocess.check_output(['brew', '--prefix', 'llvm']).decode().strip()
# `brew --prefix` will return even if formula is not installed
if not os.path.exists(brew_prefix):
if not os.path.exists(brew_prefix:=subprocess.check_output(['brew', '--prefix', 'llvm']).decode().strip()):
raise FileNotFoundError('LLVM not found, you can install it with `brew install llvm`')
LLVM_PATH: str|None = os.path.join(brew_prefix, 'lib', 'libLLVM.dylib')
else:
+2 -6
View File
@@ -2,14 +2,10 @@ import ctypes, ctypes.util, os, subprocess
from tinygrad.helpers import OSX
if OSX:
brew_prefix = subprocess.check_output(['brew', '--prefix', 'dawn']).decode().strip()
if not os.path.exists(brew_prefix):
if not os.path.exists(brew_prefix:=subprocess.check_output(['brew', '--prefix', 'dawn']).decode().strip()):
raise FileNotFoundError('dawn library not found. Install it with `brew tap wpmed92/dawn && brew install dawn`')
WEBGPU_PATH: str|None = os.path.join(brew_prefix, 'lib', 'libwebgpu_dawn.dylib')
else:
WEBGPU_PATH = ctypes.util.find_library('webgpu_dawn')
if WEBGPU_PATH is None:
if (WEBGPU_PATH:=ctypes.util.find_library('webgpu_dawn')) is None:
raise FileNotFoundError("dawn library not found. " +
"Install it with `sudo curl -L https://github.com/wpmed92/pydawn/releases/download/v0.1.6/libwebgpu_dawn.so -o /usr/lib/libwebgpu_dawn.so`")