Differences between revisions 4 and 12 (spanning 8 versions)
Revision 4 as of 2008-11-25 22:21:45
Size: 2341
Editor: ChrisBarker
Comment:
Revision 12 as of 2009-08-14 19:12:22
Size: 3550
Editor: ciphergoth
Comment: missing parenthesis
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
In addition to the[[http://docs.python.org/dist/module-distutils.core.html|standard distutils setup keywords]], the following py2exe keywords specify what and how to build: ==== What you need to understand about Distutils: ====
The Distutils module is part of the standard python distribution. Distutils is used by python module developers to package and distribute new modules. The setup syntax py2exe uses is inherited from distutils. (If you choose the default Windows installation for python, distutils can be found at: C:/Program Files/Python##/Lib/distutils/). The setup function of Distutil [[http://docs.python.org/dist/module-distutils.core.html|recognizes specific keywords]], which are also available when running py2exe. The following is a list of some more useful distutils keywords
||<tablewidth="820px" tableheight="48px">'''keyword''' ||'''description''' ||
|| [[data_files]] || list of "data" files that you are going to need to run your executable such as .pngs, .jpgs ||
Line 3: Line 6:
||<tablewidth="820px" tableheight="86px">console ||list of scripts to convert into console exes ||


==== Py2exe extends Distutils setup keywords ====
In addition to the standard distutils setup keywords, the following py2exe keywords specify what and how to build.
||<tablewidth="820px" tableheight="198px">'''keyword''' ||'''description''' ||
||console ||list of scripts to convert into console exes ||
Line 12: Line 21:
The following options dictionary entries are available:
Line 14: Line 22:
||<tablewidth="820px" tableheight="227px">unbuffered ||if true, use unbuffered binary stdout and stderr ||
||optimize     || string or int of optimization level (0, 1, or 2) ||
||includes     || list of module names to include ||
||packages     || list of packages to include with subpackages ||
||ignores      || list of modules to ignore if they are not found ||
||excludes     || list of module names to exclude ||

==== The options dictionary of py2exe ====
The option keyword takes the following set of dictionary key: value pairs. The dictionary "key" names and the "value" types are listed in the table below.
||<tablewidth="820px" tableheight="227px">'''key''' || '''value''' ||
||
unbuffered ||if true, use unbuffered binary stdout and stderr ||
||optimize || string or int of optimization level (0, 1, or 2) 0 = don’t optimize (generate .pyc) 1 = normal optimization (like python -O) 2 = extra optimization (like python -OO) See http://docs.python.org/distutils/apiref.html#module-distutils.util for more info. ||
||includes || list of module names to include ||
||packages || list of packages to include with subpackages ||
||ignores || list of modules to ignore if they are not found ||
||excludes || list of module names to exclude ||
Line 21: Line 33:
||dist_dir     || directory in which to build the final files ||
||typelibs     || list of gen_py generated typelibs to include ||
||compressed   ||(boolean) create a compressed zipfile ||
|| xref        ||(boolean) create and show a module cross reference ||
||bundle-files || bundle dlls in the zipfile or the exe. Valid levels are 1, 2, or 3 (default) ||
||skip-archive ||(boolean) do not place Python bytecode files in an archive, put them directly in the file system||
|| ascii ||(boolean) do not automatically include encodings and codecs ||
||dist_dir || directory in which to build the final files ||
||typelibs || list of gen_py generated typelibs to include ||
||compressed ||(boolean) create a compressed zipfile ||
||xref ||(boolean) create and show a module cross reference ||
||bundle_files || bundle dlls in the zipfile or the exe. Valid levels are 1, 2, or 3 (default) ||
||skip_archive ||(boolean) do not place Python bytecode files in an archive, put them directly in the file system ||
||ascii ||(boolean) do not automatically include encodings and codecs ||
Line 29: Line 41:


Line 48: Line 63:
>>> help(setup}}} >>> help(setup)
}}}

What you need to understand about Distutils:

The Distutils module is part of the standard python distribution. Distutils is used by python module developers to package and distribute new modules. The setup syntax py2exe uses is inherited from distutils. (If you choose the default Windows installation for python, distutils can be found at: C:/Program Files/Python##/Lib/distutils/). The setup function of Distutil recognizes specific keywords, which are also available when running py2exe. The following is a list of some more useful distutils keywords

keyword

description

data_files

list of "data" files that you are going to need to run your executable such as .pngs, .jpgs

Py2exe extends Distutils setup keywords

In addition to the standard distutils setup keywords, the following py2exe keywords specify what and how to build.

keyword

description

console

list of scripts to convert into console exes

windows

list of scripts to convert into GUI exes

service

list of module names containing win32 service classes

com_server

list of module names containing com server classes

ctypes_com_server

list of module names containing com server classes

zipfile

name of shared zipfile to generate; may specify a subdirectory; defaults to 'library.zip'

options

dictionary { "py2exe": { "opt1": val1, "opt2": val2, ... } }

The options dictionary of py2exe

The option keyword takes the following set of dictionary key: value pairs. The dictionary "key" names and the "value" types are listed in the table below.

key

value

unbuffered

if true, use unbuffered binary stdout and stderr

optimize

string or int of optimization level (0, 1, or 2) 0 = don’t optimize (generate .pyc) 1 = normal optimization (like python -O) 2 = extra optimization (like python -OO) See http://docs.python.org/distutils/apiref.html#module-distutils.util for more info.

includes

list of module names to include

packages

list of packages to include with subpackages

ignores

list of modules to ignore if they are not found

excludes

list of module names to exclude

dll_excludes

list of dlls to exclude

dist_dir

directory in which to build the final files

typelibs

list of gen_py generated typelibs to include

compressed

(boolean) create a compressed zipfile

xref

(boolean) create and show a module cross reference

bundle_files

bundle dlls in the zipfile or the exe. Valid levels are 1, 2, or 3 (default)

skip_archive

(boolean) do not place Python bytecode files in an archive, put them directly in the file system

ascii

(boolean) do not automatically include encodings and codecs

custom-boot-script

Python file that will be run when setting up the runtime environment

Example:

setup(
        windows=['trypyglet.py'],
        options={
                "py2exe":{
                        "unbuffered": True,
                        "optimize": 2,
                        "excludes": ["email"]
                }
        }
)

For more information enter the following at the python command line:

>>> from distutils.core import setup
>>> help(setup)

ListOfOptions (last edited 2009-11-04 16:59:32 by FlorianHoech)