Differences between revisions 1 and 13 (spanning 12 versions)
Revision 1 as of 2005-10-04 22:22:44
Size: 333
Editor: host18
Comment:
Revision 13 as of 2009-11-04 16:59:32
Size: 3799
Editor: FlorianHoech
Comment: Documented possibility to set zipfile to None and also valid values for bundle_files.
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Currently the py2exe home page doesn’t include a complete list of configuration keywords. You can see the list of options and keywords that py2exe supports by doing: ==== 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 ||




==== 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 ||
||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'. If {{{zipfile}}} is set to {{{None}}}, the files will be bundled within the executable instead of '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.
||<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 ||
||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 values for {{{bundle_files}}} are: 3 = don't bundle (default) 2 = bundle everything but the Python interpreter 1 = bundle everything, including the Python interpreter ||
||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:
Line 4: Line 48:
>>> import py2exe
>>> help(py2exe)
setup(
        windows=['trypyglet.py'],
        options={
                "py2exe":{
                        "unbuffered": True,
                        "optimize": 2,
                        "excludes": ["email"]
                }
        }
)
Line 7: Line 59:
For more information enter the following at the python command line:
Line 8: Line 61:
In addition, the [http://docs.python.org/dist/dist.html distutils documentation] explains other useful keywords. {{{
>>> from distutils.core import 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'. If zipfile is set to None, the files will be bundled within the executable instead of '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 values for bundle_files are: 3 = don't bundle (default) 2 = bundle everything but the Python interpreter 1 = bundle everything, including the Python interpreter

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)