Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning about pip when binary is missing on linux #376

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading