Skip to content

Commit

Permalink
Add PEP 723 script dependencies for examples that need 3rd party libr…
Browse files Browse the repository at this point in the history
…aries. [no ci]
  • Loading branch information
salt-die committed Feb 12, 2025
1 parent 9b7593f commit 3a3cbee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
15 changes: 8 additions & 7 deletions examples/advanced/rigid_body_physics.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""
A rigid body physics simulation in the terminal.
Requires `pymunk`
"""
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "pymunk",
# ]
# ///
"""A rigid body physics simulation in the terminal."""

import asyncio
from math import ceil, degrees
Expand Down Expand Up @@ -68,7 +70,7 @@ async def _run_simulation(self):
while True:
self.space.step(self.dt)
self._draw_space()
await asyncio.sleep(0)
await asyncio.sleep(1 / 60)

def _to_texture_coords(self, point: Vec2d) -> tuple[int, int]:
x, y = point
Expand Down Expand Up @@ -210,7 +212,6 @@ async def on_start(self):
dt=0.03,
size_hint={"height_hint": 1.0, "width_hint": 1.0},
)
space_renderer.run_simulation()

background = Image(
path=PATH_TO_BACKGROUND, size_hint={"height_hint": 1.0, "width_hint": 1.0}
Expand Down
8 changes: 7 additions & 1 deletion examples/advanced/stable_fluid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "scipy",
# ]
# ///
"""
Stable fluid simulation. Requires `scipy`.
Stable fluid simulation.
Click to add fluid.
"r" to reset.
Expand Down

0 comments on commit 3a3cbee

Please sign in to comment.