Skip to content

Commit e810663

Browse files
committed
doc improvements
1 parent e9b2c8f commit e810663

14 files changed

+765
-647
lines changed

CHANGELOG.rst

+607
Large diffs are not rendered by default.

LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2007-2019 Victor Blomqvist
1+
Copyright (c) 2007-2020 Victor Blomqvist
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

README.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ using Chipmunk 7 rev 080c51480f018040b567e8f0440b121ae3acbae4 .
2525
Installation
2626
------------
2727

28-
In the normal case pymunk can be installed with pip::
28+
In the normal case pymunk can be installed from PyPI with pip::
2929

3030
> pip install pymunk
3131

@@ -86,7 +86,7 @@ It is (or is striving to be):
8686

8787
* **Easy to use** - It should be easy to use, no complicated code should be
8888
needed to add physics to your game or program.
89-
* **"Pythonic"** - It should not be visible that a c-library (chipmunk) is in
89+
* **"Pythonic"** - It should not be visible that a c-library (Chipmunk) is in
9090
the bottom, it should feel like a Python library (no strange naming, OO,
9191
no memory handling and more)
9292
* **Simple to build & install** - You shouldn't need to have a zillion of
@@ -116,8 +116,7 @@ Contact & Support
116116
https://github.com/viblo/pymunk/issues
117117

118118
Regardless of the method you use I will try to answer your questions as soon
119-
as I see them. (And if you ask on SO or the forum other people might help as
120-
well!)
119+
as I see them. (And if you ask on SO other people might help as well!)
121120

122121

123122
Dependencies / Requirements
@@ -131,7 +130,8 @@ possible, usually `pip install` will take care of everything for you.
131130
- CFFI (will be installed automatically by Pip)
132131
- Setuptools (should be included with Pip)
133132

134-
* GCC and friends (optional, you need it to compile Pymunk from source)
133+
* GCC and friends (optional, you need it to compile Pymunk from source. On
134+
windows Visual Studio is required to compile)
135135
* Pygame (optional, you need it to run the Pygame based demos)
136136
* Pyglet (optional, you need it to run the Pyglet based demos)
137137
* Matplotlib & Jupyter Notebook (optional, you need it to run the Matplotlib

docs/src/advanced.rst

+23-29
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ want a better understanding of Pymunk for example to extend it.
77

88
First off, Pymunk is a pythonic wrapper around the C-library Chipmunk.
99

10-
To wrap Chipmunk Pymunk uses CFFI. On top of the CFFI wrapping is a handmade
11-
pythonic layer to make it nice to use from Python code.
10+
To wrap Chipmunk Pymunk uses CFFI in API mode. On top of the CFFI wrapping is
11+
a handmade pythonic layer to make it nice to use from Python code.
1212

1313
Why CFFI?
1414
---------
@@ -23,7 +23,7 @@ Advantages (compared to ctypes):
2323
* Its an active project. The developers and users are active, there are new
2424
releases being made and its possible to ask and get answers within a day on
2525
the CFFI mailing list.
26-
* Its said to be the way forward for pypy, with promise of better performance
26+
* Its said to be the way forward for Pypy, with promise of better performance
2727
compares to ctypes.
2828
* A little easier than ctypes to wrap things since you can just copy-paste the
2929
c headers.
@@ -125,13 +125,11 @@ Code Layout
125125
Most of Pymunk should be quite straight forward.
126126

127127
Except for the documented API Pymunk has a couple of interesting parts. Low
128-
level bindings to Chipmunk, a custom library load function, a custom
129-
documentation generation extension and a customized setup.py file to allow
130-
compilation of Chipmunk.
128+
level bindings to Chipmunk, a custom documentation generation extension and a
129+
customized setup.py file to allow compilation of Chipmunk.
131130

132-
The low level chipmunk bindings are located in the two files _chipmunk_cffi.py
133-
and _chipmunk_cffi_abi.py. In order to locate and load the compiled chipmunk
134-
library file pymunk uses a custom load_library function in _libload.py
131+
The low level chipmunk bindings are located in the file
132+
pymunk_extension_build.py.
135133

136134
docs/src/ext/autoexample.py
137135
A Sphinx extension that scans a directory and extracts the toplevel
@@ -147,15 +145,11 @@ pymunk/_chipmkunk_cffi_abi.py
147145
This file contains the pure Cffi wrapping definitons. Bascially a giant
148146
string created by copy-paster from the relevant header files of Chipmunk.
149147

150-
pymunk/_libload.py
151-
This file contains the custom Cffi library load function that is used
152-
by the rest of pymunk to load the Chipmunk library file.
153-
154148
setup.py
155149
Except for the standard setup stuff this file also contain the custom
156150
build commands to build Chipmunk from source, using a build_ext extension.
157151

158-
tests/*
152+
pymunk/tests/*
159153
Collection of (unit) tests. Does not cover all cases, but most core
160154
things are there. The tests require a working chipmunk library file.
161155

@@ -180,7 +174,14 @@ argument. The matching is as broad as possible, so `UnitTest` matches all the
180174
unit tests, `test_arbiter` all tests in `test_arbiter.py` and
181175
`testResetitution` matches the exact `testRestitution` test case ::
182176

183-
> python -m pymunk.tests testRestitution
177+
> python -m pymunk.tests -f testRestitution
178+
179+
To see all options to the tests command use -h ::
180+
181+
> python -m pymunk.tests -h
182+
183+
Since the tests cover even the optional parts, you either have to make sure
184+
all the optional dependencies are installed, or filter out those tests.
184185

185186

186187
Working with non-wrapped parts of Chipmunk
@@ -194,7 +195,7 @@ wrapped by pymunk. The Chipmunk method to get this property is named
194195
cpBodyIsSleeping.
195196

196197
First we need to check if its included in the cdef definition in
197-
_chipmunk_cffi.abi.py. If its not just add it.
198+
pymunk_extension_build.py. If its not just add it.
198199

199200
`cpBool cpBodyIsSleeping(const cpBody *body);`
200201

@@ -206,20 +207,13 @@ Then to make it easy to use we want to create a python method that looks nice::
206207
Now we are ready with the mapping and ready to use our new method.
207208

208209

209-
Weak References and __del__ Methods
210+
Weak References and free Methods
210211
-----------------------------------
211212

212213
Internally Pymunk allocates structs from Chipmunk (the c library). For example a
213214
Body struct is created from inside the constructor method when a pymunk.Body is
214-
created. Because of this several Pymunk objects uses a __del__() method that
215-
cleans up the underlying c struct when the object is deleted.
216-
217-
Use of a __del__() method prevents the normal CPython GC (garbage collection)
218-
from handling cyclic references since it wont know in which order to run the
219-
__del__() methods. Some Pymunk objects naturally keeps cyclic references to each
220-
other to make them easier to use. One such example is the body and shape object.
221-
A shape is attached to a body, and a body has a set of all shapes that has been
222-
attached. To make it easier for the user of the library these cyclic references
223-
have been broken up so that the reference in one direction is weak and dont
224-
affect GC. Usually the user do not need to worry about this, but in the cases a
225-
reference is weak it is marked in the API documentation of the specific method.
215+
created. Because of this its important that the corresponding c side memory is
216+
deallocated properly when not needed anymore, usually when the Python side
217+
object is garbage collected. Most Pymunk objects use `ffi.gc` with a custom
218+
free function to do this. Note that the order of freeing is very important to
219+
avoid errors.

docs/src/benchmarks.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Benchmarks
22
==========
3+
.. _benchmark:
34

45
To get a grip of the actual performance of Pymunk this page contains a number
56
of benchmarks.
@@ -111,7 +112,7 @@ callback test using the collision handler::
111112

112113
s.step(0.01)
113114

114-
(see `pymunk-collision-callback.py and `cymunk-collision-callback.py`)
115+
(see `pymunk-collision-callback.py` and `cymunk-collision-callback.py`)
115116

116117
Results
117118
+++++++

docs/src/changelog.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. include:: ../../CHANGELOG.rst

docs/src/examples.rst

-5
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ Given that pymunk is installed where your python will find it::
5656

5757
>cd examples
5858
>python breakout.py
59-
60-
To run directly without installing anything. From the pymunk source folder::
61-
62-
>cd examples
63-
>python run.py breakout.py
6459
6560
Each example contains something unique. Not all of the examples use the same
6661
style. For example, some use the pymunk.pygame_util module to draw stuff,

docs/src/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Contents
66
.. toctree::
77
:maxdepth: 4
88

9-
news
9+
changelog
1010
installation
1111
overview
1212
pymunk
@@ -15,9 +15,9 @@ Contents
1515
tutorials
1616
benchmarks
1717
advanced
18+
Downloads <https://pypi.python.org/pypi/pymunk/>
1819
Issue Tracker <https://github.com/viblo/pymunk/issues>
1920
Source Repository <https://github.com/viblo/pymunk>
20-
Downloads <https://pypi.python.org/pypi/pymunk/>
2121
license
2222

2323
Indices and tables

docs/src/installation.rst

+3-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Pymunk can also be installed with conda install, from the conda-forge channel::
2222
Once Pymunk is installed you can verify that the installation works by running
2323
the tests::
2424

25-
> python -m pymunk.tests test
25+
> python -m pymunk.tests -f test
2626

2727
Sometimes on more uncommon platforms you will need to have a GCC-compatible
2828
c-compiler installed.
@@ -40,7 +40,7 @@ with::
4040
Examples & Documentation
4141
========================
4242

43-
Because of their size are the examples and documentation available in the
43+
Because of their size the examples and the documentation are available in the
4444
source distribution of Pymunk, but not the wheels. The source distribution is
4545
available from PyPI at https://pypi.org/project/pymunk/#files (Named
4646
pymunk-x.y.z.zip)
@@ -147,10 +147,6 @@ the path::
147147
sys.path.insert(1, 'pymunk')
148148
import pymunk
149149

150-
The same trick can be used to import pymunk for a script that is not in the
151-
direct parent folder, see for example `run.py` in the examples which update
152-
the path to simplify development.
153-
154150

155151
.. _compile-chipmunk:
156152

@@ -174,9 +170,7 @@ place in the source folder::
174170

175171
> python setup.py build_ext --inplace
176172

177-
On Windows you will need to use a gcc-compatible compiler. The pre-built version
178-
distributed with pymunk were compiled with the MinGW-w64 GCC compiler at
179-
https://www.msys2.org/
173+
On Windows you will need to use Visual Studio matching your Python version.
180174

181175
.. seealso::
182176

0 commit comments

Comments
 (0)