Source

cx_Freeze / MakeFrozenBases.py

"""Make the frozen base executables."""

import distutils.sysconfig
import os
import sys

CC = os.environ.get("CC", "gcc")

# define function for building a base executable
def BuildBase(name, linkerFlags = "", sharedLib = False):
    vars = distutils.sysconfig.get_config_vars()
    sourceName = name + ".c"
    objectName = name + ".o"
    targetName = name
    if sharedLib:
        if sys.platform == "win32":
            targetName += ".dll"
        else:
            targetName += vars["SO"]
        linkerFlags = "-shared %s" % linkerFlags
    else:
        targetName += vars["EXE"]
    compilerFlags = "-c -I. -I%s -I%s" % \
            (distutils.sysconfig.get_python_inc(),
             distutils.sysconfig.get_python_inc(1))
    linkerFlags += " -s"
    if sys.platform == "win32":
        import win32api
        linkerFlags += " " + win32api.GetModuleFileName(sys.dllhandle)
    else:
        linkerFlags += " %s %s -L%s" % \
                (vars["LDFLAGS"], vars["LINKFORSHARED"], vars["LIBPL"])
        if sys.platform == "hp-ux11":
            linkerFlags += " -lcl"
        linkerFlags += " -lpython%d.%d" % sys.version_info[:2]
        linkerFlags += " %s %s %s %s" % \
                (vars["LIBS"], vars["LIBM"], vars["LOCALMODLIBS"],
                 vars["BASEMODLIBS"])
    command = "%s %s -o %s %s" % (CC, compilerFlags, objectName, sourceName)
    print command
    if os.system(command) != 0:
        raise "Failed to compile %s" % sourceName
    command = "%s -o %s %s %s" % \
            (CC, os.path.join("bases", targetName), objectName, linkerFlags)
    print command
    if os.system(command) != 0:
        raise "Failed to link %s" % sourceName
    os.unlink(objectName)

# create the directory, if necessary
if not os.path.exists("bases"):
    os.mkdir("bases")

# build the base executables
BuildBase("Console")
BuildBase("ConsoleKeepPath")
if sys.platform == "win32":
    BuildBase("Win32GUI", "-mwindows")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.