How to distribute a python game to OS X users? - python

I recently finished up a small game I wrote in python, using pygame, at the request of some of my friends. Currently, I have the .pyw game file, and an assets folder containing all files used in the program. I used py2exe to distribute the game, which worked fine, although it still does not seem very user friendly to people downloading the game. One of my friends requested a mac version of it, and although I know about py2app, I am unsure of how to use it, and whether or not it is the best way to package my game.
Basically, I want a single file that I can send to any mac user, so they can easily use the program I have made, while preferably not seeing the source code.
I have googled around for a simple solution, but have not found one. If anyone could give a very simple explanation of how to easily do this, that would be great. Please keep in mind I am fairly new to programming, and may not understand all the programming lingo, so if you could keep it simple, I would appreciate it.
Thanks in advance.

The answer to How can I distribute python programs? suggests Pyinstaller which looks promising, although I have not tried it myself.
See this tutorial by Irwin Kwan to see how Pyinstaller can actually be used with Pygame. He describes a procedure for preparing a Windows executable as well as one for OS X.

Related

Python Pyinstaller - How to Patch Program That I Have Built?

I have built a keyword search tool in Python, and then converted it into an .exe format with Pyinstaller, so people at my workplace could use it without having to install Python.
I have sent this around to everyone by e-mail in a RAR file which they have then saved to their desktops.
I am thinking of some potential tweaks I might make to it, but I do not want to have to keep on sending them the full program every time I decide I want to change something.
So, the question is, is there a way that I can send a patch file to upgrade the program instead? What should I be looking at?
Thanks in advance!
You just can't. Compiling a program freezes it, meaning that it cannot be modified.

Sharing pygame/python withought using any compiler

I have tried many times to use a compiler like cx_freeze and other programs, but for some reason nothing seems to be working. I made a little game which I want to send to a friend, but he needs python installed.
Can't I just put python.exe and pygame into the folder that I will send my friend and won't python be installed then, and all he needs to do is run the program .py and it will work? Sorry if I'm not being clear.. I'm just trying to find a simple way to compile my code to let users not waste time on downloading pygame and python.
py2exe allows you to package python applications for Windows. Right now it supports everything from 2.4 - 3.1 of python. You do however need to be able to redistribute MSVCR90.dll.
There are a range of distribution tools and you can find a list here.
Since you've had difficultly with several tools now updating your question with error codes and speific problems will yeild better responses.
From my knowledge, just putting a bunch of your stuff in one folder and sending doesn't work. It would be easier to make a .exe
That way your stuff will be protected, and users can easily start it. Otherwise idk. Try using pyinstaller again. It should work if you have a python.x
CX_Freeze is known for having many bugs and problems, Pyg.exe is new to me also. Your best bet is just keep trying until you find a solution.
Putting python.exe and your script together in a folder will not work for distribution. You require all Python dependencies - at best your would need to include all of your Python folder, and it still might not work. The best method would be compilation or packaging with programs such as py2exe, cx_freeze, Cython, pyg.exe, etc.

AVBin in cxfreeze

I'm having a bit of trouble in Python 3 lately.
i have a program that uses Pyglet and AVBin to play sound into my game. It's one of my socket tests, so I want to test the game with someone that doesn't even own python. I used to use cx_Freeze for all of my projects, but Im having a huge problem with this one, because of pyglet and especially AVBin. I would appreciate it if anyone can give an answer to this question in a very simple manner. I've seen this answered a few times, but didn't get anything the people said.
Compiling for Windows 7, Python 3. AVBin and Pyglet required.
The question:
How do I compile a Python 3 script that uses AvBin and Pyglet into a Windows Executable, using cx_Freeze?
Since this was my first time on Stack Exchange, I couldn't really describe the question as good as it should be. But, I researched for a few hours, and got it working! I had to upload the Pyglet library with the executable the cx_Freeze made, and also include the AVBin DLL with the executable.
I'm really sorry for asking this question in the first place. I'll make sure my next questions are more detailed.

Including python and other files

All of the python I've written so far have been fine on my own computer, but now I'd like to send some programs to friends to have them test certain features. Suppose I wrote an application in python with wxpython. Assuming people I send code to will not have either installed, what is the best way to include both python, and the wxpython library so the other person isn't struggling to get it running? I've never had to do this at this point in my learning and would love some feedback!
Thanks.
You can create a bundle using py2exe and installer using NSIS and ship it as executable so that your friend will get the complete working executable. But mind you, this will increase the size of the file enormously and I have often found it easier to ask them to install via README.txt files.
There are lots of binary builders: py2exe, cx_freeze, bbfreeze, PyInstaller, GUI2Exe. I have a whole slew of articles on these:
http://www.blog.pythonlibrary.org/2010/08/31/another-gui2exe-tutorial-build-a-binary-series/
http://www.blog.pythonlibrary.org/2010/07/31/a-py2exe-tutorial-build-a-binary-series/
http://www.blog.pythonlibrary.org/2010/08/19/a-bbfreeze-tutorial-build-a-binary-series/
http://www.blog.pythonlibrary.org/2010/08/12/a-cx_freeze-tutorial-build-a-binary-series/
http://www.blog.pythonlibrary.org/2010/08/10/a-pyinstaller-tutorial-build-a-binary-series/
Unless they are going to develop with Python too, then I don't see any reason for them to want to install a bunch of multi-megabyte installers versus your own. You can read about how to use Inno Setup to create an installer here:
http://www.blog.pythonlibrary.org/2008/08/27/packaging-wxpymail-for-distribution/

Playing and controlling mp3 files in Python?

First things first, I am a Python beginner, with a typical C++/Java background for object oriented stuff.
I was convinced to try Python for this current endeavor I am working on, and so far I like it. One issue I am having though is finding a good mp3 module.
I have tried TkSnack, which installed and ran fine with no errors(as long as my audio device wasn't busy) but it could never actually produce a sound, it just did nothing... I went online for help, and was disappointed with the amount of documentation.
So I decided to switch. I tried PyMad because it is in the standard repositories for Ubuntu as well. There was even less documentation on this, but I could make it play a sound. The only problem is that it requires a loop to constantly write/play the audio buffer. This makes it particularly hairy to handle playback control(in my opinion) cause I would have to run this in a separate thread or process, and somehow control the seek position for pause and such. This is a little too low level for why I am using Python. I liked the simplicity of TkSnack for its easy commands like "mysound.play()" or "mysound.pause()" rather than controlling a loop.
I also looked at pyMedia, which looks like it is the most up to date with documentation, but I can't get it to install on my machine. I get a "gcc exited with value 1" error or something like that when running the "python setup.py build" command.
So I am looking for any suggestions or help on one of these modules, or a completely different one, that is high level and easy to use for mp3s(and preferably other formats too) I am trying to have basic playback control(pause, stop, skip, seek) and I may also be streaming files too eventually(if I ever get there).
EDIT: I like the python bindings for Gstreamer, but is this a cross-platform solution?? I forgot to mention that as a requirement. But I always just associated GStreamer with Linux, would this work on other OSs?
EDIT: Wikipedia says yes.
Sorry I can't help you with PyMad or pyMedia, but I have other suggestions.
Existing music players written in Python:
Exaile
FUPlayer
Listen
All of the above use the Python bindings for the GStreamer multimedia framework. Docs for the bindings are scarce, but check here, here, here, and examples from the source distribution here.
I just had to deal with this, and from my research I think your best bets are pyglet and pygame. They're interface packages with built-in a/v support.

Categories