Skip to content

Commit

Permalink
Add warning about pip when binary is missing on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Oct 12, 2023
1 parent f3a0bdf commit b29b9a6
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion wgpu/backends/rs_ffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ def get_wgpu_lib_path():
# Note that this can be a false positive, e.g. ARM linux.
embedded_path = get_resource_filename(lib_filename)
if not os.path.isfile(embedded_path): # no-cover
download_hint = _maybe_get_hint_on_download_script()
pip_hint = _maybe_get_pip_hint()
raise RuntimeError(
f"Could not find WGPU library in {embedded_path}. {_maybe_get_hint_on_download_script()}"
f"Could not find WGPU library in {embedded_path}. {download_hint} {pip_hint}"
)
else:
return embedded_path
Expand All @@ -103,6 +105,29 @@ def _maybe_get_hint_on_download_script():
return ""


def _maybe_get_pip_hint():
if not sys.platform.startswith("linux"):
return ""

# Get pip version
pip_version = ()
try:
import pip # noqa

parts = []
for x in pip.__version__.split("."):
if not x.isnumeric():
break
parts.append(int(x))
pip_version = tuple(parts)
except Exception:
pass

if pip_version < (20, 3):
return "If you install wgpu with pip, pip needs to be at least version 20.3 or the wgpu-native binary may not be included."
return ""


# Configure cffi and load the dynamic library
# NOTE: `import wgpu.backends.rs` is used in pyinstaller tests to verify
# that we can load the DLL after freezing
Expand Down

0 comments on commit b29b9a6

Please sign in to comment.