pymunk, a chipmunk python binding.

Share your projects and Chipmunk enhancements.

pymunk, a chipmunk python binding.

Postby viblo » Tue Aug 21, 2007 3:33 pm


For the latest release announcement, check this thread: viewtopic.php?f=6&t=1940


Today after much waiting pymunk 1.0.0 was released!

With this release pymunk has most features I wanted, follows the latest chipmunk version, has quite good api documentation and is fairly well tested and hopefully quite stable. As such I think it's about time the version is bumped to 1.0.0.

As this version is updated to include the new features in chipmunk, and also contain at least one breaking change it is not unlikely that it will break your code. On the other hand, now it has the newest callback system (see Space.add_collision_handler), new joints and other cool stuff that will make it easier and more fun to include 2d physics into your python program/game :)

Changes from the last release:
* Vec2d now uses radians instead of degrees for all default angle functions. This might break existing code!
* Upgraded to latest chipmunk. This means new system of callbacks and many other improvements
* Many unittests added.
* Better py3k compatibility (everything except for the setup script should work)
* Better 32/64 bit library handling
* and more

About
pymunk is a binding to chipmunk for use in python. (Big thanks for Chipmunk slembcke!) It puts a pythonic layer above chipmunk to make it easy to use for python programmers. You can now do stuff like:
Code: Select all
body = pymunk.Body(10,1000)
shape = pymunk.Circle(body, 10, (0,0))
space.add(body, shape)
# and also
def pre_solve(space, arb):
    print arb.shapes
    return True
space.add_collision_handler(0, 0, None, pre_solve, None, None)


It is (or striving to be):

* *Easy to use* It should be easy to use, no complicated stuff should be needed to add physics to your game/program.
* *"Pythonic"* It should not be visible that a c-library (chipmunk) is in the bottom, it should feel like a python library (no strange naming, OO, no memory handling and more)
* *Simple to build & install* You shouldnt need to have a zillion of libraries installed to make it install, or do a lot of command line trixs.
* *Multiplatform* Should work on both windows, nix and OSX.
* *Non-intrusive* It should not put restrictions on how you structure your program and not force you to use a special game loop, it should be possible to use with other libraries like pygame and pyglet.

I hope and believe that with the latest release these points are at least partly fulfilled and visible if you use pymunk.

Download
pymunk (source/svn, some screenshots and the latest packed release) can be found here: http://code.google.com/p/pymunk/
Last edited by viblo on Sun Dec 04, 2011 1:05 am, edited 15 times in total.
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
viblo
 
Posts: 205
Joined: Tue Aug 21, 2007 3:12 pm

Re: pymunk, a chipmunk python binding.

Postby viblo » Fri Dec 14, 2007 9:41 am

As some people have been asking if the project is dead or not, I will write a little update on this.

I have a svn at http://pymunk.googlecode.com/ with the current code. The low level stuff, i.e. more or less the same as in the first version is now updated to use the lastest version of Chipmunk, and there is a beginning of a more high level binging (big thanks to Mark, who sent me a start on this). Don't expect anything to be set in stone at this point, anything or everything might change.. If you don't like it, need unsupported functions, like low level more, or just want to do your own stuff, the _chipmunk.py file contain the low level (semi-)automatically generated binding.

Note: The automatic dll/so/dynlib loading function wasnt perfect and is now removed from the code until I fix it. Its hard coded for the windows version dll atm. You can copy paste from the old version if you want it back.

Edit: Replaced the old svn with the new googlecode page, to prevent confusing people.
Last edited by viblo on Sun Jan 27, 2008 4:26 pm, edited 1 time in total.
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
viblo
 
Posts: 205
Joined: Tue Aug 21, 2007 3:12 pm

Re: pymunk, a chipmunk python binding.

Postby Ezequiel » Sat Jan 19, 2008 1:38 pm

Thank you, I easily replace my custom engine with pymunk and now the bottleneck is in the AI! :roll:

Are you still maintaining this bindings?
Ezequiel
 
Posts: 8
Joined: Thu Jan 10, 2008 1:50 pm

Re: pymunk, a chipmunk python binding.

Postby viblo » Sun Jan 27, 2008 4:24 pm

Ezequiel wrote:Thank you, I easily replace my custom engine with pymunk and now the bottleneck is in the AI! :roll:

Are you still maintaining this bindings?


Yes, more or less :)

btw, as more people have showed interest in pymunk, I decided to switch to googlecode for the SVN, at http://pymunk.googlecode.com/ That should make it easier for people to find and access it.
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
viblo
 
Posts: 205
Joined: Tue Aug 21, 2007 3:12 pm

Re: pymunk, a chipmunk python binding.

Postby alecthomas » Tue Feb 05, 2008 7:36 am

I've written a trivial patch against pymunk SVN that adds a setup.py and allows pymunk to work on Linux (hopefully without breaking Windows/OS/X support!).

One other question, what tool did you use to auto-generate the ctypes code from the header?

Thanks for pymunk :)
alecthomas
 
Posts: 2
Joined: Tue Feb 05, 2008 7:14 am

Re: pymunk, a chipmunk python binding.

Postby viblo » Fri Feb 08, 2008 6:52 pm

alecthomas wrote:I've written a trivial patch against pymunk SVN that adds a setup.py and allows pymunk to work on Linux (hopefully without breaking Windows/OS/X support!).

Thanks for the patch. I have added the setup script (with slight modifications). The find library stuff was fixed by a load function contributed by Paul a couple of days ago, the find_library function had some problem last time I tried using it and thats why I removed it in the first place. Feel free to try svn version and tell me if it find the library on your setup.

alecthomas wrote:One other question, what tool did you use to auto-generate the ctypes code from the header?
Thanks for pymunk :)

There is a wrapper generator in svn now. It uses h2xml and xml2py found in ctypeslib. (The reason why it wasn't there before is that it didn't exist, i did the small modifications needed after xml2py by hand)
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
viblo
 
Posts: 205
Joined: Tue Aug 21, 2007 3:12 pm

Re: pymunk, a chipmunk python binding.

Postby alecthomas » Sun Feb 10, 2008 8:23 am

Hi,

Latest trunk works with changes for:

  • UNIX libraries have a "lib" prefix (eg. libchipmunk.so)
  • UNIX file-systems are case-sensitive, and libchipmunk.so is the default installed filename.

This patch works for me but you might want a cleaner implementation. What exactly about ctypes' load_library didn't work?

Code: Select all
Index: pymunk/_chipmunk.py
===================================================================
--- pymunk/_chipmunk.py   (revision 12)
+++ pymunk/_chipmunk.py   (working copy)
@@ -5,7 +5,7 @@
 from vec2d import vec2d
 cpVect = vec2d
 
-chipmunk_lib = load_library("Chipmunk")
+chipmunk_lib = load_library("chipmunk")
 if _lib_debug: print chipmunk_lib
 
 STRING = c_char_p

Code: Select all
Index: pymunk/ctload.py
===================================================================
--- pymunk/ctload.py   (revision 12)
+++ pymunk/ctload.py   (working copy)
@@ -55,6 +55,7 @@
         else:
             lib = name+'.so'
             ldenv = 'LD_LIBRARY_PATH'
+        lib = 'lib' + lib
         pathlist += [p for p in os.environ.get(ldenv,'').split(':') if p != '']
         pathlist += ['/usr/local/lib','/usr/lib']
alecthomas
 
Posts: 2
Joined: Tue Feb 05, 2008 7:14 am

Re: pymunk, a chipmunk python binding.

Postby viblo » Sun Feb 10, 2008 6:33 pm

The problem was that it didn't find the library ;) I don't know the exact problem (got most of the feedback after the pyweek competition), and maybe it was just the user putting the lib in strange places or the code looking for uppercase instead of lowercase or other issues, but I have also seen other reports that it isn't perfect (for example pyglet has a custom find_library() function)

Anyway I havn't had any problems myself with either find_library() or the ctload module used now, but Im on a windows machine... If you think find_library is the best maybe I should switch back? (I added your changes to svn but as you say, the find/load functionality needs some more work before it is perfect)
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
viblo
 
Posts: 205
Joined: Tue Aug 21, 2007 3:12 pm

Re: pymunk, a chipmunk python binding.

Postby viblo » Sat Mar 01, 2008 9:31 am

I made an update to the first post (and this post is just to bump to make the forum mark the thread for those who might be interested).
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
viblo
 
Posts: 205
Joined: Tue Aug 21, 2007 3:12 pm

Re: pymunk, a chipmunk python binding.

Postby crazy-chris » Tue Mar 04, 2008 3:50 am

I think pymunk is a great work -- thanks for making chipmunk accessible for us python developers! :) I'm currently supporting the OLPC European Developer Network and will try to port the engine and bindings to the XO laptop and see if I can get a few well running examples done.

I'd love to contribute to pymunk as well, if I anyhow could.
I'd suggest to setup some basic infrastructure for collaboration on pymunk:

* Wiki
* Forum (subforum here?)
* IRC Channel (#chipmunk or #pymunk on irc.freenode.net?)

I'd already have a few nice examples, i would like to post, and also a few questions to ask -- so some infrastructure could help a lot for sharing those as well :)

Chris

EDIT: I'll upload my pymunk examples to http://linuxuser.at/pymunk/
crazy-chris
 
Posts: 7
Joined: Tue Mar 04, 2008 3:40 am

Next

Return to Community Creations

Who is online

Users browsing this forum: No registered users and 0 guests

cron