I'm quite new to programming. I've recently made a simple snake game using python and pygame. Of course, I can play my game easily by running the .py script, but in wanting to share it with my less computer literate friends, I went on to try to figure out how to compile my code into a single .exe to make it easy for them.
I've tried py2exe and cx_Freeze, both giving me a dist or build directory with an .exe and several other files (dependencies). This does work, since I'm able to zip up the whole folder and distribute via .zip, but it's not ideal. I want to be able to wrap it all up in one file.
So I started googling 'how to compile python into a single exe'. However, unlike many of the programming problems I have tried googling before, I just can't get a straight, reliable answer. So far the most recent reliable answer I've tried gives me this setup.py script:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
windows = ['snek.py'],
zipfile = None
)
# Python 3.4.4, py2exe 0.9.2.2; modules used: pygame, random
Still, it gives me a whole folder instead of a single .exe, which the program cannot run without.
So, I come to you, the all-knowing, the great, stackoverflow, with two questions.
Just in case I missed anything: how do you suggest I achieve my single .exe dream?
And: why the hell is this so difficult?