From b8843aaa3bcb733af162449a36e9a343d0de3645 Mon Sep 17 00:00:00 2001 From: Darren Eberly Date: Fri, 26 Dec 2025 20:42:22 -0500 Subject: [PATCH 1/2] Make pymunk optional --- arcade/__init__.py | 4 +++- arcade/hitbox/__init__.py | 10 ++++++---- pyproject.toml | 8 ++++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/arcade/__init__.py b/arcade/__init__.py index e10cf5a079..dbf9f2bad7 100644 --- a/arcade/__init__.py +++ b/arcade/__init__.py @@ -192,10 +192,12 @@ def configure_logging(level: int | None = None): from .tilemap import load_tilemap from .tilemap import TileMap -if sys.platform != "emscripten": +try: from .pymunk_physics_engine import PymunkPhysicsEngine from .pymunk_physics_engine import PymunkPhysicsObject from .pymunk_physics_engine import PymunkException +except ImportError: + pass from .version import VERSION diff --git a/arcade/hitbox/__init__.py b/arcade/hitbox/__init__.py index d8881c4bff..01086e7a9b 100644 --- a/arcade/hitbox/__init__.py +++ b/arcade/hitbox/__init__.py @@ -1,7 +1,6 @@ from PIL.Image import Image from arcade.types import Point2List -from arcade.utils import is_pyodide from .base import HitBox, HitBoxAlgorithm, RotatableHitBox from .bounding_box import BoundingHitBoxAlgorithm @@ -10,12 +9,15 @@ #: The simple hit box algorithm. algo_simple = SimpleHitBoxAlgorithm() -#: The detailed hit box algorithm. -if not is_pyodide(): +#: The detailed hit box algorithm. This depends on pymunk and will fallback to the simple algorithm. +try: from .pymunk import PymunkHitBoxAlgorithm - algo_detailed = PymunkHitBoxAlgorithm() +except ImportError: + print("WARNING: Running without PyMunk. The detailed hitbox algorithm will fallback to simple") + algo_detailed = SimpleHitBoxAlgorithm() + #: The bounding box hit box algorithm. algo_bounding_box = BoundingHitBoxAlgorithm() diff --git a/pyproject.toml b/pyproject.toml index ec18226f4f..6fa4ab7580 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,6 @@ classifiers = [ dependencies = [ "pyglet==3.0.dev1", "pillow~=12.0.0", - "pymunk~=7.2.0", "pytiled-parser~=2.2.9", ] dynamic = ["version"] @@ -36,6 +35,9 @@ Source = "https://github.com/pythonarcade/arcade" Book = "https://learn.arcade.academy" [dependency-groups] +extras = [ + "pymunk~=7.2.0" +] # Used for dev work dev = [ "sphinx==8.1.3", # April 2024 | Updated 2024-07-15, 7.4+ is broken with sphinx-autobuild @@ -62,8 +64,10 @@ dev = [ "click==8.1.7", # Temp fix until we bump typer "typer==0.12.5", # Needed for make.py "wheel", - "bottle" # Used for web testing playground + "bottle", # Used for web testing playground + {include-group = "extras"} ] + # Testing only testing_libraries = ["pytest", "pytest-mock", "pytest-cov", "pyyaml==6.0.1"] From 4feaeb1822fa123f6b53db84fc0b7a5c618976c3 Mon Sep 17 00:00:00 2001 From: Darren Eberly Date: Fri, 26 Dec 2025 21:08:16 -0500 Subject: [PATCH 2/2] Some more dependency cleanup for WASM environment --- pyproject.toml | 2 +- webplayground/example.tpl | 7 +++---- webplayground/server.py | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6fa4ab7580..dc46ffefff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ classifiers = [ ] dependencies = [ "pyglet==3.0.dev1", - "pillow~=12.0.0", + "pillow>=11.3.0", "pytiled-parser~=2.2.9", ] dynamic = ["version"] diff --git a/webplayground/example.tpl b/webplayground/example.tpl index 1288c96c7e..1c686f9e61 100644 --- a/webplayground/example.tpl +++ b/webplayground/example.tpl @@ -4,7 +4,7 @@ % title = name.split(".")[-1] {{title}} - + @@ -13,9 +13,8 @@ let pyodide = await loadPyodide(); await pyodide.loadPackage("micropip"); const micropip = pyodide.pyimport("micropip"); - await pyodide.loadPackage("pillow"); // Arcade needs Pillow - await micropip.install("pyglet==3.0.dev1", pre=true) - await micropip.install("http://localhost:8000/static/{{arcade_wheel}}"); + await pyodide.loadPackage("pillow"); + await micropip.install("http://localhost:8000/static/{{arcade_wheel}}", pre=true); // We are importing like this because some example files have numbers in the name, and you can't use those in normal import statements pyodide.runPython(` diff --git a/webplayground/server.py b/webplayground/server.py index 4aba5090f7..1a4b1c7566 100644 --- a/webplayground/server.py +++ b/webplayground/server.py @@ -61,7 +61,7 @@ def main(): # Go to arcade and build a wheel os.chdir(path_arcade) - subprocess.run(["python", "-m", "build", "--wheel", "--outdir", "dist"]) + subprocess.run(["uv", "build"]) os.chdir(here) shutil.copy(path_arcade_wheel, f"./{arcade_wheel_filename}")