Skip to main content

WindowsExecutables_Py2Exe — wiki

How to make a windows executable.


py2exe is a Python distutils extension which converts python scripts into executable windows programs, able to run without requiring a python installation.

# This is an example file
# run it from the windows command line like so:
# > C:\Python2.4\python.exe py2exe

from distutils.core import setup

import py2exe, glob

opts = { 
 "py2exe": { 
   # if you import .py files from subfolders of your project, then those are
   # submodules.  You'll want to declare those in the "includes"


  #this is the file that is run when you start the game from the command line.  

  #options as defined above

  #data files - these are the non-python files, like images and sounds
  #the glob module comes in handy here.
  data_files = [
    ("data", glob.glob("data\\*.png") + glob.glob("data\\*.ogg")),
    ("data/glarf", glob.glob("data\\glarf\\*.*")) ,
    ("data/level1", glob.glob("data\\level1\\*.*")) 

  #this will pack up a zipfile instead of having a glut of files sitting
  #in a folder.


TODO: An example nsis script for making an installer.