Skip to content

Commit d734e24

Browse files
authored
minor WEBGPU_PATH cleanup [pr] (tinygrad#9552)
also mypy recognizes `sys.platform == 'win32'` but does not recognizes it if wrapped inside a helper...
1 parent 7ce7fe0 commit d734e24

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

tinygrad/runtime/support/llvm.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
raise FileNotFoundError('LLVM not found, you can install it with `winget install LLVM.LLVM` or point at a custom dll with LLVM_PATH')
1010
elif OSX:
1111
# Will raise FileNotFoundError if brew is not installed
12-
brew_prefix = subprocess.check_output(['brew', '--prefix', 'llvm']).decode().strip()
1312
# `brew --prefix` will return even if formula is not installed
14-
if not os.path.exists(brew_prefix):
13+
if not os.path.exists(brew_prefix:=subprocess.check_output(['brew', '--prefix', 'llvm']).decode().strip()):
1514
raise FileNotFoundError('LLVM not found, you can install it with `brew install llvm`')
1615
LLVM_PATH: str|None = os.path.join(brew_prefix, 'lib', 'libLLVM.dylib')
1716
else:

tinygrad/runtime/support/webgpu.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22
from tinygrad.helpers import OSX
33

44
if OSX:
5-
brew_prefix = subprocess.check_output(['brew', '--prefix', 'dawn']).decode().strip()
6-
7-
if not os.path.exists(brew_prefix):
5+
if not os.path.exists(brew_prefix:=subprocess.check_output(['brew', '--prefix', 'dawn']).decode().strip()):
86
raise FileNotFoundError('dawn library not found. Install it with `brew tap wpmed92/dawn && brew install dawn`')
97
WEBGPU_PATH: str|None = os.path.join(brew_prefix, 'lib', 'libwebgpu_dawn.dylib')
108
else:
11-
WEBGPU_PATH = ctypes.util.find_library('webgpu_dawn')
12-
13-
if WEBGPU_PATH is None:
9+
if (WEBGPU_PATH:=ctypes.util.find_library('webgpu_dawn')) is None:
1410
raise FileNotFoundError("dawn library not found. " +
1511
"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`")

0 commit comments

Comments
 (0)