Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Nov 13, 2023
1 parent 851616f commit 456fb64
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
20 changes: 17 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ def test_basic_api():
assert code1.co_varnames[:nargs1] == code2.co_varnames


def test_api_subpackages_are_there():
code = "import wgpu; x = [wgpu.resources, wgpu.utils, wgpu.backends, wgpu.gui]; print('ok')"
result = subprocess.run(
[sys.executable, "-c", code],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
out = result.stdout.rstrip()
assert out.endswith("ok")
assert "traceback" not in out.lower()


def test_logging():
level = [-1]

Expand Down Expand Up @@ -100,11 +113,12 @@ def test_backend_is_selected_automatically():
result = subprocess.run(
[sys.executable, "-c", code],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
assert "GPUAdapter object at" in result.stdout
assert "traceback" not in result.stderr.lower()
out = result.stdout.rstrip()
assert "GPUAdapter object at" in out
assert "traceback" not in out.lower()


def test_that_we_know_how_our_api_differs():
Expand Down
2 changes: 2 additions & 0 deletions wgpu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from .base import * # noqa: F401,F403
from .gui import WgpuCanvasInterface # noqa: F401,F403
from . import utils # noqa: F401,F403
from . import backends # noqa: F401,F403
from . import resources # noqa: F401,F403


__version__ = "0.11.0"
Expand Down
25 changes: 13 additions & 12 deletions wgpu/__pyinstaller/hook-wgpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@
datas = []
binaries = []

# Include the resources subpackage and its contents.
hiddenimports += ["wgpu.resources"]
# Include our resource data and binaries
datas += collect_data_files("wgpu", subdir="resources")
binaries += collect_dynamic_libs("wgpu")

# Include backends. Make sure all our backend code is present,
# and let PyInstaller resolve imports/dependencies for some.
datas += collect_data_files(
"wgpu", subdir="backends", include_py_files=True, excludes=["__pycache__"]
)
# Include the modules that we want to include (PyInstall will trace imports)
hiddenimports += ["wgpu.backends.auto", "wgpu.backends.rs"]
hiddenimports += ["wgpu.gui.auto"]

# Include gui backends. Dito.
collect_data_files(
"wgpu", subdir="gui", include_py_files=True, excludes=["__pycache__"]
)
hiddenimports += ["wgpu.gui", "wgpu.gui.offscreen"]
# Note that the resources, utils, backends, and gui subpackages are imported by default.

# We have multiple subpackages for which the modules are not imported
# by default. We make sure that PyInstaller adds them anyway. Strictly
# speaking this would not be necessary, but it won't hurt, and it covers
# cases like e.g. downstream libs doing dynamic imports of gui backends.
for subpackage in ["utils", "backends", "gui"]:
datas += collect_data_files(
"wgpu", subdir=subpackage, include_py_files=True, excludes=["__pycache__"]
)

# For good measure, we include GLFW if we can, so that code that just
# uses `from wgpu.gui.auto import ..` just works. The glfw library is really
Expand Down
6 changes: 3 additions & 3 deletions wgpu/__pyinstaller/test_wgpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# The test part
if "is_test" in sys.argv:
included_modules = [
"wgpu.backends.auto"
"wgpu.backends.auto",
"wgpu.backends.rs",
"wgpu.gui",
"wgpu.gui.offscreen",
"wgpu.gui.auto",
"wgpu.gui.glfw",
"wgpu.utils.compute",
]
excluded_modules = [
"PySide6",
Expand Down

0 comments on commit 456fb64

Please sign in to comment.