Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So, I've done the research, and i've done the try/catch process of almost getting things to work. . . almost.

I've read this chart: https://spreadsheets.google.com/pub?key=tZ42hjaRunvkObFq0bKxVdg&output=html and i've read this post: How can I distribute a native executable for a Python program?

I'm at that point where I'm looking for either just using an installer that can run a python installer, then run the installers for all the dependencies (modules) or just copy paste the modules into the proper python directories.

So my question is: Do you have any experience with this? If so, what are your success/fail stories? Would you want to build everything into an Exe with something like pyinstaller, or just use a custom installer that would require more time to learn (like: http://www.actualinstaller.com/)?

share|improve this question
    
A completely different approach would be to run it in NaCL? Or in Javascript via skulpt.org ? This is not straightforward, and you'd be treading a new path, but it might make your target audience much much bigger? –  Will Apr 18 '13 at 8:54
    
A single .exe is simpler for the user to use. –  Crowbeak Apr 26 '13 at 5:45
    
Yes it is, which is why I now have one! –  Eliot Leo Carney-Seim May 2 '13 at 19:40
add comment

3 Answers

You can just use py2exe. Congats.

share|improve this answer
    
The question was if you've had any experience or success with it, so do you? –  Eliot Leo Carney-Seim Apr 18 '13 at 20:35
    
My experience with py2exe was that I could get it to work, but had to manually copy over some files it had missed. –  Daniel Apr 19 '13 at 4:08
    
I've had success! Please read my answer below. –  Eliot Leo Carney-Seim May 2 '13 at 19:32
add comment

As mentioned on your links, pyInstaller has been a great tool so far because it attends what users usually want on a program: simplicity. With pyInstaller, you can put everything - compiled code and libraries - on a single file, and options like an icon to your executable. It's also multiplatform, which is a bonus these days. In fact, pyInstaller has many options for building your application, so you got the freedom to choose what's best for you.

share|improve this answer
    
Thanks for the response! See my answer to the question, i got it working! –  Eliot Leo Carney-Seim May 2 '13 at 19:40
add comment
up vote 1 down vote accepted

I GOT IT WORKING!! I'm going to put all the info here that you need to know, as it's incredibly simple once you get it working.

First i'll explain my directory setup:

So i have: src\game\main.py. in source, i have a music, graphics, game and data folder. I have all my .py files in the game folder, and the others are self explanatory. Also inside the source folder is a RGB.py (RGB is the name of my game) and ALL THIS DOES is execute main.py in the game folder. So it looks something like this: graphics> (images) games>main.py, stuff.py, etc.py src>music> (music) data> (log files and other stuff) RGB.py

Now, PyInstaller 2.0 lets you use a .spec file, which you will HAVE to use to get this to work. I'll show mine, then explain it:

`# -*- mode: python -*-

import os
import glob
import sys


base_path = 'C:\\RGB\\dist\\RGBpy'
sys.path.append('C:\\RGB\\dist\\RGBpy')
a = Analysis([os.path.join(base_path, 'RGB.py')],
             pathex=['C:\\RGB'],
             hiddenimports=['_codecs', 'encodings', 'encodings.aliases', 'encodings.codecs', 
             'encodings.encodings', 'encodings.__builtin__', 'encodings.utf_8'],
             hookspath=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=1,
          name=os.path.join('build\\pyi.win32\\RGB', 'RGB.exe'),
          debug=False,
          strip=None,
          upx=True,
          console=True )

pygame_files = [
    ('freesansbold.ttf', os.path.join(base_path, 'data', 'freesansbold.ttf'), 'DATA'),
]

game_files = []
with file(os.path.join(base_path, 'MANIFEST.in')) as f:
    for line in f.readlines():
        if line.startswith('include'):
            rest = line.split(' ')[1]
            base, pattern = os.path.split(rest)
            if base:
                for item in glob.glob(os.path.join(base_path, base, '*.*')):
                    _, name = os.path.split(item)
                    game_files.append((
                        os.path.join(base, name),
                        item,
                        'DATA'
                    ))
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas + pygame_files + game_files,
               strip=None,
               upx=True,
               name=os.path.join('dist', 'RGB'))`

Now, your .tff file is likely to not be detected, so thats where the pygame_files list comes in. My .tff file is in the data folder, so the 'data' you see is there for that. Ignore the 'DATA' in all caps.

The C:\RGB\dist\RGBpy you see is where my RGB.py is located and all the folders. I just renamed \src to \RGBpy. The location doesn't matter as long as the driver .py file (RGB.py) is in that location, along with everything else that you'll probably want imported.

Next is game_files, this is used as a workaround for manifest.in, which wouldn't work for me, but it might work for you, my manifest.in file is just a .txt file with .in on the end and it has

exclude .hgignore
include graphics/*.*
include music/*.*
include game/*.*
include data/*.*
include *.py
include *.txt

which should be pretty self explanatory.

Additional details include a pathex which is where the .exe will be unloaded. Which, when combined with name=os.path.join('dist', 'RGB'), you get the .exe in RGB\dist\RGB.

The rest should be pretty self explanatory. To properly run it, save the MANIFEST.in in both the pysintaller main directory AND besides your driver.py (RGB.py) and .spec in the pysintaller dir. Then execute the following in windows command: python pyinstaller .spec. If python isn't added to your system path: http://stackoverflow.com/questions/4621255/how-do-i-run-a-python-program-in-the-command-prompt-in-windows-7.

ONE FINAL RULE THAT I MUST WARN YOU OF!! .pyc files. Pyinstaller will choose those of the exist. remove them before running pyinstaller!! It'll force your file imports to be static, causing all kinds of issues! That was my major roadblock several times. DELETE YOUR .PYC FILES!!

And that is all there is to it!! Good luck!!

(credit goes to paul paterson of perpetualpyramid.com for helping)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.