Created
July 16, 2014 20:52
-
-
Save DoctorMalboro/6895031bfb287cd978a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
import sys | |
from glob import glob # glob will help us search for files based on their extension or filename. | |
from distutils.core import setup # distutils sends the data py2exe uses to know which file compile | |
import py2exe | |
data_files = [ | |
# All the files that are not .py, .pyd or .pyc should be invoked so py2exe adds them to the compilation | |
("Microsoft.VC90.CRT", | |
glob(r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*')), # Adds the file to the compilation folder because it may broke inside the compilation | |
("static", | |
glob(r'C:\Users\You\Python\YourProgram\static\*.*')), # static files such like images, audios, videos, etc. | |
("static/audio", | |
glob(r'C:\Users\You\Python\YourProgram\static\traducciones\*.mp3')), # You can also specify which filetype you want by extension | |
] | |
setup( | |
name='Your Program', | |
windows=['main.py'], # 'windows' means it's a GUI, 'console' It's a console program, 'service' a Windows' service, 'com_server' is for a COM server | |
# You can add more and py2exe will compile them separately. | |
options={ # This is the list of options each module has, for example py2exe, but for example, PyQt or django could also contain specific options | |
'py2exe': { | |
'dist_dir': 'compilation/gui', # The output folder | |
'compressed': True, # If you want the program to be compressed to be as small as possible | |
'includes':['sys', 'glob', 'os', 'platform', 'datetime', 'webbrowser', | |
'PySide.QtGui', 'PySide.QtCore', 'psutil', 'modules', 'utils'], # All the modules you need to be included, I added packages such as PySide and psutil but also custom ones like modules and utils inside it because py2exe guesses which modules are being used by the file we want to compile, but not the imports, so if you import something inside main.py which also imports something, it might break. | |
} | |
}, | |
data_files=data_files # Finally, pass the | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment