0

I have heard of some things like py2exe, etc. but I have read some unclear stuff on how it works with downloaded libraries like pygame, numpy, or pyglet & cocos2d. Do you have to copy the whole module into the top of your main game .pyw in order to get the exe (or .app, or whatever) to be a single file? Seems messy and prone to error.

The ideal is having a folder for resources with background images, sprites, music, etc., a folder for save files, and a lone executable that functions well. How achievable is this? I'm using pygame to learn and do demos/test right now and am planning on using cocos2D when we start the real game.

Our ultimate goal would be to distribute on Steam for Windows, Mac, and Linux. We don't want people to have to have python installed to play our game even if it never gets picked up for anything. However I heard some of these application creation utilities are not compatible with previous versions of Windows, which is too bad. I use 7 but I'd like anyone with XP or Vista to be able to play.

(It would be even more dreamy to have a Playstation Vita version or something, but I imagine that's a whole other ballgame, right? Probably have to recode the entire project to be compatible?)

Using Python 2.7 by the way, if it matters.

dogboydog
  • 1
  • 2
  • I recommend reading the site faq – Andrew Barber Jan 23 '12 at 02:43
  • I did read it before posting, sorry if it is too open. It tends to happen to me whenever I type stuff up. But my real question is is there an effective way to distribute games written in python with downloaded libraries to platforms without Python installed. I couldn't find an answer I understood anywhere else. The rest is just extra things I was wondering. – dogboydog Jan 23 '12 at 03:17
  • You should edit your question down to the important parts. Rambling will just get your question closed as "not a real question", since it's difficult to tell what you are asking. – Andrew Barber Jan 23 '12 at 03:19
  • I'm fairly sure it's possible to use py2exe and such with certain libraries, but I don't know all the details. – thedaian Jan 23 '12 at 04:28

1 Answers1

0

When you distribute a game, you can use something like py2exe or py2app to compile your Python application. During this process, everything your application needs to run is copied into the final executable. This means that, no, you do NOT have to copy libraries into your local folder, and no, clients do NOT need Python installed to run.

The only caveat is that doing this can be tricky. You'll likely want to:

  • Be sure that you bundle up your files (so you don't have a lot of helper files cluttering up your directory).
  • Make sure you redistribute .dlls, etc. that your application needs (for example, SDL.dll). You'll have to check with your libraries for legal issues.
  • Occasionally libraries have other issues (e.g., PyGame has default fonts, and PyOpenGL needs special attention). Generally, these are workable, but it's not always nice.
geometrian
  • 14,775
  • 10
  • 56
  • 132
  • Excellent, thank you. Bundling up files was something I was wondering about as well. A lot of games have things like "Images.something" that seems to contain every resource for the game. How can you do something like that with Pythong? Thank you very much – dogboydog Feb 16 '12 at 13:26
  • Haven't used Pythong, but what's wrong with just having a data/ directory in your release? Most programs do this anyway. – geometrian Feb 16 '12 at 19:23
  • Well, it makes it easier for people to post images online without permission. And plus it's cool to just have one big file – dogboydog Feb 17 '12 at 02:24
  • Hate to tell ya, but a lot of data can be easily ripped out of compiled executables anyway. For example, strings of data. This is because they are stored in a "data segment". Generally, this is stuff like the string data in "const char* a = "hello";", but it can be more complicated. This is one reason why passwords cannot be safely hardcoded. – geometrian Feb 17 '12 at 05:40
  • Because Python is an interpreted language, the executable will just be a loose wrapper around a Python interpreter and your data, which will make your application even less secure. Depending, it might be as easy as just opening your .exe in notepad, and copy+pasting. – geometrian Feb 17 '12 at 05:43
  • Anyway, wrapping up your files isn't hard. I know py2exe can do it. I'd assume Pythong can. It's a pretty common thing to do (though it's usually stuff like .dlls, and point is always to make it easier on the user, not security). – geometrian Feb 17 '12 at 05:43
  • Well, the security thing is really minor. It's more like it slightly discourages ripping the images from the game since they're bundled up, not that it's impenetrable or something. I just think it would be neater to have a sounds.whatever, backgrounds.whatever, etc instead of branching folders with each individual file viewable. Having individual files is kind of less romantic to me for some reason too, like it demystifies the idea of a game. I just would prefer to be able to wrap them up, but I guess if I can't, no big deal. Thanks, I'll check out my options when the time comes. – dogboydog Feb 17 '12 at 07:10