Please note:The SCons wiki is in read-only mode due to ongoing spam/DoS issues. Also, new account creation is currently disabled. We are looking into alternative wiki hosts.

Attachment 'reference.html'


SCons tool “cpython” - Reference

Dirk Baechle



This reference lists all the variables that are used within the “cpython” tool, and the available builders. It is intended for SCons tool developers and core programmers, as a normal user you should read the manual instead.

1. Interna

Internally, the builder is based on the Install/InstallAs methods from SCons.Tool.install. It makes use of the basic builder's functions: installFunc(), and add_targets_to_INSTALLED_FILES().

2. Builders

2.1. InstallPython

The “InstallPython” method creates .pyc or .pyo files for .py source files and adds them to the list of targets along with the source files. They are later copied to the destination (target) directory.


env = Environment()
hello = File('')
env.InstallPython('/usr/local/bin/', hello)
env.Alias('install', '/usr/local/bin/')

3. Variables


Default value is 1, which means that the Python source files get compiled to .pyc files. Set this variable to 0 in order to get optimized .pyo files, parallel to your installed sources.


The path to the external Python executable, used for creating optimized .pyo files. Default value is 'python'.


Additional flags for compiling optimized Python files (.pyo). The default is '-O'.


The command arguments for compiling optimized Python files (.pyo). The default value is '-c 'import sys,py_compile; [py_compile.compile(i) for i in sys.argv[1:]]''.


The command line for compiling optimized Python files (.pyo). Default is '$CPYTHON_EXE $CPYTHON_PYO_FLAGS $CPYTHON_PYO_CMD'.


The message string for the 'CPYTHON_PYCOM' command. Default is 'Install file: "$SOURCE" as "$TARGET"'.


Default value is '.py'. The suffix for Python source files.

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.