Skip to content

Commit b4ffe52

Browse files
authored
Merge pull request #285 from viblo/pymunk7
Pymunk7
2 parents 7c00c77 + 92f6e5c commit b4ffe52

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2226
-1681
lines changed

.github/workflows/wheels.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ jobs:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
11+
os:
12+
[ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-14]
1213

1314
steps:
1415
- uses: actions/checkout@v4
@@ -21,10 +22,10 @@ jobs:
2122
python3 -c "import pathlib,glob;pathlib.Path('GITHUB_ENV').write_text('SDIST_PATH' + glob.glob('dist/*.tar.gz')[0])"
2223
2324
- name: Build wheels
24-
uses: pypa/cibuildwheel@v2.22.0
25+
uses: pypa/cibuildwheel@v2.23.1
2526
env:
2627
CIBW_BUILD:
27-
"cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* pp39-* pp310-*"
28+
"cp39-* cp310-* cp311-* cp312-* cp313-* pp310-* pp311-*"
2829
# "cp38-* cp39-* cp310-* cp311-* cp312-* cp313-*"
2930
CIBW_TEST_COMMAND: "python -m pymunk.tests"
3031
# CIBW_BUILD_VERBOSITY: 3
@@ -56,7 +57,7 @@ jobs:
5657
- uses: actions/checkout@v4
5758
with:
5859
submodules: true
59-
- uses: pypa/cibuildwheel@v2.22.0
60+
- uses: pypa/cibuildwheel@v2.23.2
6061
env:
6162
CIBW_PLATFORM: pyodide
6263
PYMUNK_BUILD_SLIM: 1

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "Chipmunk2D"]
2-
path = Chipmunk2D
3-
url = git@github.com:viblo/Chipmunk2D.git
1+
[submodule "Munk2D"]
2+
path = Munk2D
3+
url = git@github.com:viblo/Munk2D.git

.readthedocs.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ build:
1212

1313
# Build documentation in the docs/ directory with Sphinx
1414
sphinx:
15-
configuration: docs/src/conf.py
15+
configuration: docs/src/conf.py
1616

1717
# Optionally build your docs in additional formats such as PDF
1818
formats:
19-
- pdf
19+
- pdf
2020

2121
# Optionally set the version of Python and requirements required to build your docs
2222
python:
23-
install:
24-
- requirements: docs/requirements.txt
23+
install:
24+
- requirements: docs/requirements.txt
2525

2626
# Do not include the Chipmunk2D submodule. It it not needed for docs.
2727
submodules:
28-
exclude: all
28+
exclude: all

CHANGELOG.rst

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,106 @@
22
Changelog
33
=========
44

5+
Pymunk 7.0.0 (2025-05-28)
6+
-------------------------
7+
8+
**Many improvements and breaking changes!**
9+
10+
This is a big cleanup release with several breaking changes. If you upgrade
11+
from an older version, make sure to pay attention, especially the
12+
``Space.bodies``, ``Space.shapes`` and ``Space.constraints`` updates can break silently!
13+
14+
Extra thanks for Github user aatle for a number of suggestions and feedback
15+
for this Pymunk release!
16+
17+
18+
The biggest changes relates to collision handlers:
19+
20+
- The ``begin``, ``pre_step`` and ``separate`` methods will now always be
21+
called. ``post_solve`` will continue to only be called if the collision were
22+
actually processed.
23+
- You no longer return a ``bool`` from ``begin`` or ``pre_step`` to control if the
24+
collision should be processed. Instead, there is a property on the ``Arbiter``,
25+
``process_collision``, that can be set to ``False``.
26+
- The ``process_collision`` property is stable but updatable, e.g if set to
27+
``False`` in a ``begin`` callback it will be ``False`` in the ``pre_step``,
28+
which in turn can toggle it back to ``True``.
29+
- The ``CollisionHandler`` class itself is no longer public. The ``Space`` has
30+
a new ``on_collision()`` method that takes the callbacks as arguments without
31+
returning anything.
32+
33+
In addition to the above (which will be easy to spot), there is also a more
34+
subtle change:
35+
36+
- ``Space.shapes``, ``Space.bodies`` and ``Space.constraints`` now return a
37+
``KeysView``. That means that the returned collection is no longer a copy,
38+
instead if you hold a ref to it and if you for example add an object to the
39+
``Space`` it will update. To get the old behavior, you can convert to a list
40+
manually, e.g ``list(Space.shapes)``.
41+
42+
Additional breaking changes:
43+
44+
- Unified all ``Space.query`` methods to include sensor shapes. Previously
45+
the nearest methods filtered them out.
46+
- At least one of the two bodies attached to a constraint/joint must be
47+
dynamic.
48+
- ``Vec2d`` now supports ``bool`` to test if zero. (
49+
``bool(Vec2d(2,3) == True``).
50+
- Added ``Vec2d.length_squared``, and deprecated ``Vec2d.get_length_sqrd()``
51+
- Added ``Vec2d.get_distance_squared()``, and deprecated
52+
``Vec2d.get_dist_sqrd()``
53+
- A dynamic body must have non-zero mass when calling ``Space.step()`` (either
54+
from ``Body.mass``, or by setting ``mass`` or ``density`` on a Shape
55+
attached to the ``Body``). It is not valid to set ``mass`` to ``0`` on a
56+
dynamic body attached to a ``Space``.
57+
- Deprecated ``matplotlib_util``. If you think this is a useful module, and
58+
you use it, please create an issue on the Pymunk issue tracker at
59+
https://github.com/viblo/pymunk/issues
60+
- Dropped support for Python 3.8
61+
- Changed ``Body.constraints`` to return a ``KeysView`` of the Constraints
62+
attached to the ``Body``. Note that its still weak references to the
63+
Constraints.
64+
- Reversed the dependency between bodies and shapes. Now the ``Body`` owns the
65+
connection, and the ``Shape`` only keeps a weak ref to the ``Body``. That
66+
means that if you remove a ``Body``, then any shapes not referenced
67+
anywhere else will also be removed.
68+
- Changed ``Body.shapes`` to return a ``KeysView`` instead of a set of the shapes.
69+
- Changed ``Shape.segment_query`` to return None in case the query did not
70+
hit the shape.
71+
- Changed ``ContactPointSet.points`` to be a ``tuple`` and not ``list`` to
72+
make it clear its length is fixed.
73+
- Added default ``empty_callback``, that can be used to efficiently reset
74+
any callback to default.
75+
76+
New non-breaking features:
77+
78+
- Switched from using Chipmunk to the new Munk2D fork of Chipmunk (see
79+
https://github.com/viblo/Munk2D for details).
80+
- Added ``Arbiter.bodies`` shorthand to get the shapes' bodies in the ``Arbiter``.
81+
- New method ``ShapeFilter.rejects_collision()`` that checks if the filter
82+
would reject a collision with another filter.
83+
- New method ``Vec2d.polar_tuple`` that return the vector as polar coordinates
84+
- Changed type of ``PointQueryInfo.shape``, ``SegmentQueryInfo.shape`` and
85+
``ShapeQueryInfo.shape`` to not be ``Optional``, they will always have a shape.
86+
- Build and publish wheels for Linux ARM and Pypy 3.11
87+
88+
89+
Other improvements:
90+
91+
- Optimized ``Vec2d.angle`` and ``Vec2d.angle_degrees``. Note that the
92+
optimized versions treat ``0`` length vectors with ``x`` and/or ``y`` equal
93+
to ``-0`` slightly differently.
94+
- Fixed issue with accessing ``Body.space`` after the ``space`` is deleted and
95+
GCed.
96+
- Improved documentation in many places (``Vec2d``, ``Poly``, ``Shape`` and
97+
more)
98+
- Improved assert for ``body.mass`` sanity check (``0 < mass < math.inf``) for
99+
dynamic bodies added to a space.
100+
- Improved assert for ``body.moment`` sanity check (``0 < moment``) for dynamic
101+
bodies added to a space.
102+
- Internal cleanup of code
103+
104+
5105
Pymunk 6.11.1 (2025-02-09)
6106
--------------------------
7107

@@ -11,6 +111,7 @@ This is a patch update to Pymunk that removes debug logging. This should an
11111
issue with GC on Python 3.13.
12112

13113
Changes:
114+
14115
- Remove debug logging
15116

16117

@@ -25,8 +126,9 @@ does not work anymore. The release also adds back pre-built wheels for Pypy
25126
with a workaround until Pypy make a new release.
26127

27128
Changes:
28-
- Support Pyglet 2.1.x (this means Pyglet 2.0.x wont work)
29-
- Readded Pypy pre-built wheels
129+
130+
- Support Pyglet 2.1.x (this means Pyglet 2.0.x wont work)
131+
- Readded Pypy pre-built wheels
30132

31133

32134
Pymunk 6.10.0 (2024-12-22)

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ authors:
55
given-names: "Victor"
66
title: "Pymunk"
77
abstract: "A easy-to-use pythonic rigid body 2d physics library"
8-
version: 6.11.1
9-
date-released: 2025-02-09
8+
version: 7.0.0
9+
date-released: 2025-05-28
1010
url: "https://pymunk.org"

Chipmunk2D

Lines changed: 0 additions & 1 deletion
This file was deleted.

MANIFEST.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ prune additional_examples/dist
1919
recursive-include pymunk/examples *.png
2020
recursive-include pymunk/examples *.wav
2121
#chipmunk src
22-
recursive-include Chipmunk2D/src *
23-
recursive-include Chipmunk2D/include/chipmunk *
24-
include Chipmunk2D/*.txt
22+
recursive-include Munk2D/src *
23+
recursive-include Munk2D/include/chipmunk *
24+
include Munk2D/*.txt
2525
recursive-include pymunk_cffi *
2626
#tools
2727
recursive-include tools *.py

Munk2D

Submodule Munk2D added at 5ef7498

README.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Pymunk
55

66
Pymunk is an easy-to-use pythonic 2D physics library that can be used whenever
77
you need 2D rigid body physics from Python. Perfect when you need 2D physics
8-
in your game, demo or simulation! It is built on top of the very
9-
capable 2D physics library `Chipmunk2D <http://chipmunk-physics.net>`_.
8+
in your game, demo or simulation! It is built on top of Munk2D, a fork of the
9+
very capable 2D physics library `Chipmunk2D <http://chipmunk-physics.net>`_.
1010

1111
The first version was released in 2007 and Pymunk is still actively developed
1212
and maintained today, more than 15 years of active development!
@@ -18,8 +18,8 @@ the Pymunk webpage for some examples.
1818

1919
2007 - 2025, Victor Blomqvist - vb@viblo.se, MIT License
2020

21-
This release is based on the latest Pymunk release (6.11.1),
22-
using Chipmunk2D 7 rev dfc2fb8ca023ce6376fa2cf4a7f91c92ee08a970.
21+
This release is based on the latest Pymunk release (7.0.0),
22+
using Munk2D 2.0 rev 5ef7498946f0e956f294cb3fea283626921e4128.
2323

2424

2525
Installation
@@ -152,7 +152,8 @@ Older Pythons
152152

153153
- Support for Python 2 (and Python 3.0 - 3.5) was dropped with Pymunk 6.0.
154154
- Support for Python 3.6 was dropped with Pymunk 6.5.2.
155-
- Support for Python 3.7 was dropped with Pymunk 6.9.0
155+
- Support for Python 3.7 was dropped with Pymunk 6.9.0.
156+
- Support for Python 3.8 was dropped with Pymunk 7.0.0.
156157

157158
If you use any of these legacy versions of Python, please use an older
158159
Pymunk version. (It might work on newer Pymunks as well, but it's not tested,

TODO.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ v6.x
4444
- Add Canvas util module (after pyodide)
4545
- Use https://diataxis.fr/ method of organizing docs (tutorials, how-to, explanation, reference)
4646
- Make sure cffi extensions included in wheel and zip!
47-
- Catch error when NaN in debugdraw, suggest doublecheck mass=0. https://github.com/viblo/pymunk/issues/226 and https://github.com/viblo/pymunk/issues/267
4847
- Make benchmark between pymunk and pybullet. 2d bullet inspiration: https://github.com/bulletphysics/bullet3/blob/2.83/examples/Planar2D/Planar2D.cpp
4948
- After a couple of versions / time passed, re-evaluate if batch api should be separate or merged in to space.
5049
- Think about the copyright notice in some files. Keep / put everywere / remove?
@@ -54,6 +53,10 @@ v6.x
5453
- Remove support for pyglet 1.5 in debug draw. Should be fine now that 2.x has been out for a long time.
5554
- Think about if Pymunk should assert things that Chipmunk already asserts, like if a body can sleep when calling Body.sleep()?
5655

56+
v7
57+
---
58+
- Require at least one body on constraint to be dynamic.
59+
5760
v7+ (all potentially breaking changes)
5861
---
5962
- Think about split between pymunk.util and pymunk modules

0 commit comments

Comments
 (0)