setup.pyサンプル1

2017/01/10

Python2.7.6, py2exe0.6.9

Python2.7でセットアップする際のデフォルト

# -*- coding: utf-8 -*-

from distutils.core import setup
import py2exe

import sys
sys.argv.append('py2exe')

DIST_DIR = r'C:\Temp\dist'
BUILD_DIR = r'C:\Temp\build'
DIST_FILE = 'script.py'

py2exe_options = {
    'compressed': False, #圧縮するかどうか
    'optimize': 2,
    'bundle_files': 3, # 1一つにまとめる 2python.dllが分かれる 3分かれる
    'dist_dir': DIST_DIR,
    #'includes': 'numpy',
    'excludes' : ['_gtkagg', '_ssl', '_tkagg', 'bsddb', 'curses', 'doctest',
    'email', 'pdb', 'pyreadline', 'pywin.debugger', 'pywin.debugger.dbgcon',
    'pywin.dialogs', 'tcl', 'Tkconstants', 'Tkinter','PyQt4'],
    'dll_excludes' : ['w9xpopen.exe'],
  }

setup(
    options = {'build': {'build_base': BUILD_DIR},
               'py2exe': py2exe_options},
    windows = [{'script' : DIST_FILE}],
    #console = [{'script' : DIST_FILE}],
    zipfile = 'lib/'+DIST_FILE[0:-3]+'.zip'
)