From 0e151ba3962a3aec041ca1c0dd3308b85aec403b Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Mon, 30 Sep 2024 15:52:48 +0200 Subject: [PATCH] Remove stuff that's been deprecated for a while (#607) * Remove stuff that's been deprecated for a while * fix docs * codegen * fix autodoc full name --- docs/conf.py | 3 +++ docs/utils.rst | 2 +- tests/test_api.py | 6 ------ wgpu/__init__.py | 8 -------- wgpu/_classes.py | 14 -------------- wgpu/backends/rs.py | 12 ------------ wgpu/backends/wgpu_native/__init__.py | 1 - wgpu/backends/wgpu_native/extras.py | 5 ----- wgpu/resources/codegen_report.md | 4 ++-- wgpu/utils/__init__.py | 24 ------------------------ 10 files changed, 6 insertions(+), 73 deletions(-) delete mode 100644 wgpu/backends/rs.py diff --git a/docs/conf.py b/docs/conf.py index b8ab0e26..d1117b29 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,7 +21,10 @@ os.environ["WGPU_FORCE_OFFSCREEN"] = "true" + +# Load wgpu so autodoc can query docstrings import wgpu # noqa: E402 +import wgpu.utils.compute # noqa: E402 # -- Tests ------------------------------------------------------------------- diff --git a/docs/utils.rst b/docs/utils.rst index c240c4bf..60c82e2c 100644 --- a/docs/utils.rst +++ b/docs/utils.rst @@ -64,5 +64,5 @@ Compute with buffers from wgpu.utils.compute import compute_with_buffers -.. autofunction:: wgpu.utils.compute_with_buffers +.. autofunction:: wgpu.utils.compute.compute_with_buffers diff --git a/tests/test_api.py b/tests/test_api.py index 22551366..19131e7d 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -170,12 +170,6 @@ def test_do_not_import_utils_submodules(): assert "Error" not in out assert "function get_default_device" in out - # FAIL: use something from utils that's not imported - code = "import wgpu; print(wgpu.utils.compute.compute_with_buffers)" - out = get_output_from_subprocess(code) - assert "Error" in out - assert "must be explicitly imported" in out and "utils" in out - # Also, no numpy code = "import sys, wgpu.utils; print('numpy' in sys.modules)" out = get_output_from_subprocess(code) diff --git a/wgpu/__init__.py b/wgpu/__init__.py index 745bc4b3..d9783205 100644 --- a/wgpu/__init__.py +++ b/wgpu/__init__.py @@ -21,11 +21,3 @@ # 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_sync() instead." - ) diff --git a/wgpu/_classes.py b/wgpu/_classes.py index a4e06288..d5443ef0 100644 --- a/wgpu/_classes.py +++ b/wgpu/_classes.py @@ -1436,20 +1436,6 @@ def write_mapped(self, data, buffer_offset=None, size=None): def get_mapped_range(self, offset=0, size=None): raise NotImplementedError("The Python API differs from WebGPU here") - @apidiff.add("Deprecated but still here to raise a warning") - def map_read(self, offset=None, size=None, iter=None): - """Deprecated.""" - raise DeprecationWarning( - "map_read() is deprecated, use map() and read_mapped() instead." - ) - - @apidiff.add("Deprecated but still here to raise a warning") - def map_write(self, data): - """Deprecated.""" - raise DeprecationWarning( - "map_read() is deprecated, use map() and write_mapped() instead." - ) - # IDL: undefined destroy(); def destroy(self): """Destroy the buffer. diff --git a/wgpu/backends/rs.py b/wgpu/backends/rs.py deleted file mode 100644 index 3b0ef542..00000000 --- a/wgpu/backends/rs.py +++ /dev/null @@ -1,12 +0,0 @@ -# Termporaty alias for backwards compatibility. - -from .wgpu_native import gpu # noqa: F401 - -_deprecation_msg = """ -WARNING: wgpu.backends.rs is deprecated. Instead you can use: -- import wgpu.backends.wgpu_native to use the backend by its new name. -- import wgpu.backends.auto to do the same, but simpler and more future proof. -- simply use wgpu.gpu.request_adapter_sync() to auto-load the backend. -""".strip() - -print(_deprecation_msg) diff --git a/wgpu/backends/wgpu_native/__init__.py b/wgpu/backends/wgpu_native/__init__.py index 9e202fc3..87b38033 100644 --- a/wgpu/backends/wgpu_native/__init__.py +++ b/wgpu/backends/wgpu_native/__init__.py @@ -20,5 +20,4 @@ gpu = GPU() # noqa: F405 _register_backend(gpu) -from .extras import enumerate_adapters from .extras import request_device_sync, request_device diff --git a/wgpu/backends/wgpu_native/extras.py b/wgpu/backends/wgpu_native/extras.py index 2fd772cc..4b363439 100644 --- a/wgpu/backends/wgpu_native/extras.py +++ b/wgpu/backends/wgpu_native/extras.py @@ -9,11 +9,6 @@ # need to be able to load wgpu-native. -def enumerate_adapters(): - """Deprecated.""" - raise RuntimeError("Deprecated: use wgpu.gpu.enumerate_adapters_sync() instead.") - - def request_device_sync( adapter, trace_path, diff --git a/wgpu/resources/codegen_report.md b/wgpu/resources/codegen_report.md index d29d8407..8c866e77 100644 --- a/wgpu/resources/codegen_report.md +++ b/wgpu/resources/codegen_report.md @@ -13,12 +13,12 @@ * Diffs for GPUCanvasContext: add get_preferred_format, add present * Diffs for GPUAdapter: add summary * Diffs for GPUDevice: add adapter, add create_buffer_with_data, hide import_external_texture, hide lost_async, hide lost_sync, hide onuncapturederror, hide pop_error_scope_async, hide pop_error_scope_sync, hide push_error_scope -* Diffs for GPUBuffer: add map_read, add map_write, add read_mapped, add write_mapped, hide get_mapped_range +* Diffs for GPUBuffer: add read_mapped, add write_mapped, hide get_mapped_range * Diffs for GPUTexture: add size * Diffs for GPUTextureView: add size, add texture * Diffs for GPUBindingCommandsMixin: change set_bind_group * Diffs for GPUQueue: add read_buffer, add read_texture, hide copy_external_image_to_texture -* Validated 37 classes, 126 methods, 46 properties +* Validated 37 classes, 124 methods, 46 properties ### Patching API for backends/wgpu_native/_api.py * Validated 37 classes, 105 methods, 0 properties ## Validating backends/wgpu_native/_api.py diff --git a/wgpu/utils/__init__.py b/wgpu/utils/__init__.py index a8803595..491fa6b7 100644 --- a/wgpu/utils/__init__.py +++ b/wgpu/utils/__init__.py @@ -19,27 +19,3 @@ # The get_default_device() is so small and generally convenient that we import it by default. from .device import get_default_device - - -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"" - - -# 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")