Hello,
I've been experimenting with the idea of distributing a local copy of
ABvin (both 32 and 64 bit) with my games in Linux, in the same way I do
with py2exe.
With py2exe I include the AVbin version I know works best with my game
(well, it is actually the latest alpha of version 11), and there's no
need for the user to install anything.
So I got libavbin.so.11 both 32 and 64 bit version and I put the in a
lib directory in my game, in this way:
$ tree lib
lib
|-- 32bit
| |-- COPYING.LESSER
| `-- libavbin.so.11
`-- 64bit
|-- COPYING.LESSER
`-- libavbin.so.11
And I monkeypatch ctypes.util.find_library, so pyglet will load my local
AVbin version instead of the one on the system (if any!).
def find_local_library(path, fn):
"""Load libraries for a local path"""
LOCAL = { "avbin": r"%s/lib/%s/libavbin.so.11" }
bits = "64bit" if sys.maxsize > 2**32 else "32bit"
if path in LOCAL:
return LOCAL[path] % (pyglet.resource.get_script_home(), bits)
return fn(path)
_find_library = ctypes.util.find_library
ctypes.util.find_library = lambda path: find_local_library(path,
_find_library)
Note the forward slashes for the path. This code is only used in Linux
so I didn't bother doing it portable. Mind if you use this idea in other
platforms!
I know it's a simple hack, but it works like a charm. I've used this
idea to include AVbin in my last two PyWeek games* when building
Debian/Ubuntu packages and it's great.
Potentially you can include any python-only dependency with your game
(ie. pyglet) and add to LOCAL dict any library you're distributing with
the game. Then it would be unzip and run!
This could be used in Mac too, but I don't have a Mac to test to any
comments would be welcome!
Regards,
Juan
* http://www.usebox.net/jjm/lunar/
* http://www.usebox.net/jjm/for-science/
--
jjm's home: http://www.usebox.net/jjm/
blackshell: http://blackshell.usebox.net/
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/groups/opt_out.