Skip to content

Commit

Permalink
Allow disabling downloading lib when creating wheel (#669)
Browse files Browse the repository at this point in the history
* Allow disabling downloading lib when creating wheel

* Update tools/hatch_build.py

Co-authored-by: Mark Harfouche <[email protected]>

* lazy-import

* tweak

---------

Co-authored-by: Mark Harfouche <[email protected]>
  • Loading branch information
almarklein and hmaarrfk authored Jan 31, 2025
1 parent 11bb195 commit 63d70c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tools/download_wgpu_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import platform
from zipfile import ZipFile

import requests
# Import requests unless doing a noarch build
if os.getenv("WGPU_PY_BUILD_NOARCH", "").lower() not in ("1", "true"):
import requests


DEFAULT_UPSTREAM = "gfx-rs/wgpu-native"
Expand Down
5 changes: 4 additions & 1 deletion tools/hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ def initialize(self, version, build_data):
# We only do our thing when this is a wheel build from the repo.
# If this is an sdist build, or a wheel build from an sdist,
# we go pure-Python mode, and expect the user to set WGPU_LIB_PATH.
# We also allow building an arch-agnostic wheel explicitly, using an env var.

if self.target_name == "wheel" and is_git_repo():
if os.getenv("WGPU_PY_BUILD_NOARCH", "").lower() in ("1", "true"):
pass # Explicitly disable including the lib
elif self.target_name == "wheel" and is_git_repo():
# Prepare
check_git_status()
remove_all_libs()
Expand Down

0 comments on commit 63d70c0

Please sign in to comment.