Skip to content

Commit

Permalink
Cleanup __init__.py files
Browse files Browse the repository at this point in the history
  • Loading branch information
Vipitis committed Jan 4, 2024
1 parent a4dd555 commit 5cc459f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 62 deletions.
20 changes: 0 additions & 20 deletions wgpu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,8 @@
The wgpu library is a Python implementation of WebGPU.
"""

from ._coreutils import logger # noqa: F401,F403
from ._diagnostics import diagnostics # noqa: F401,F403
from .flags import * # noqa: F401,F403
from .enums import * # noqa: F401,F403
from .classes 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.13.2"
version_info = tuple(map(int, __version__.split(".")))


# The API entrypoint, from wgpu.classes - gets replaced when a backend loads.
gpu = GPU() # noqa: F405


# Temporary stub to help transitioning
def request_adapter(*args, **kwargs):
"""Deprecated!"""
raise DeprecationWarning(
"wgpu.request_adapter() is deprecated! Use wgpu.gpu.request_adapter() instead."
)
42 changes: 0 additions & 42 deletions wgpu/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,42 +0,0 @@
"""
Higher level utilities. Must be explicitly imported from ``wgpu.utils.xx``.
"""

# The purpose of wgpu-py is to provide a Pythonic wrapper around
# wgpu-native. In principal, a higher-level API is not within the scope
# of the project. However, by providing a few utility functions, other
# projects can use wgpu without having to keep track of changes in wgpu
# itself.
#
# We should be conservative here: functionality added here should have
# an unopinionated API, providing tools that are still low-level (follow
# GPU/wgpu semantics), but without using low level details of the wgpu
# API itself.

# The get_default_device() is so small and generally convenient that we import it by default.
from .device import get_default_device # noqa: F401


class _StubModule:
def __init__(self, module):
self._module = module
self.must_be_explicitly_imported = True

def __getattr__(self, *args, **kwargs):
raise RuntimeError(f"wgpu.utils.{self._module} must be explicitly imported.")

def __repr__(self):
return f"<Stub for wgpu.utils.{self._module} - {self._module} must be explicitly imported>"


# Create stubs


def compute_with_buffers(*args, **kwargs):
raise DeprecationWarning(
"wgpu.utils.compute_with_buffers() must now be imported from wgpu.utils.compute"
)


compute = _StubModule("compute")
shadertoy = _StubModule("shadertoy")

0 comments on commit 5cc459f

Please sign in to comment.