示例#1
0
    def __init__(
        self, htmlDir, outputDir, namespace, virtualFolder, filterName, filterAttributes, title, createCollection
    ):
        """
        Constructor
        
        @param htmlDir directory containing the HTML files (string)
        @param outputDir output directory for the files (string)
        @param namespace namespace to be used (string)
        @param virtualFolder virtual folder to be used (string)
        @param filterName name of the custom filter (string)
        @param filterAttributes ':' separated list of filter attributes
            (string)
        @param title title to be used for the generated help (string)
        @param createCollection flag indicating the generation of the
            collection files (boolean)
        """
        self.htmlDir = htmlDir
        self.outputDir = outputDir
        self.namespace = namespace
        self.virtualFolder = virtualFolder
        self.filterName = filterName
        self.filterAttributes = filterAttributes and filterAttributes.split(":") or []
        self.relPath = relpath(self.htmlDir, self.outputDir)
        self.title = title
        self.createCollection = createCollection

        self.packages = {"00index": {"subpackages": {}, "modules": {}}}
        self.remembered = False
        self.keywords = []
示例#2
0
    def __init__(self, htmlDir, outputDir, namespace, virtualFolder,
                 filterName, filterAttributes, title, createCollection):
        """
        Constructor
        
        @param htmlDir directory containing the HTML files (string)
        @param outputDir output directory for the files (string)
        @param namespace namespace to be used (string)
        @param virtualFolder virtual folder to be used (string)
        @param filterName name of the custom filter (string)
        @param filterAttributes ':' separated list of filter attributes
            (string)
        @param title title to be used for the generated help (string)
        @param createCollection flag indicating the generation of the
            collection files (boolean)
        """
        self.htmlDir = htmlDir
        self.outputDir = outputDir
        self.namespace = namespace
        self.virtualFolder = virtualFolder
        self.filterName = filterName
        self.filterAttributes = (filterAttributes
                                 and filterAttributes.split(':') or [])
        self.relPath = relpath(self.htmlDir, self.outputDir)
        self.title = title
        self.createCollection = createCollection

        self.packages = {"00index": {"subpackages": {}, "modules": {}}}
        self.remembered = False
        self.keywords = []
示例#3
0
    def BuildTargetClass(self, configuration, project, manifestFile, customCode, postCompile):
        """ Builds the PyInstaller compilation script file, returning it as a string. """

        # A couple of dictionaries to populate the setup string        
        setupDict, importDict = {}, {}
        configuration = dict(configuration)

        pyFile = self.scriptsList.GetItem(0, 1).GetText()
        buildDir = os.path.split(pyFile)[0]

        includeTk = self.includeTkCheck.GetValue()
        oneDir = self.oneDirRadio.GetValue()
        ascii = self.asciiCheck.GetValue()
        normpath = os.path.normpath

        useRelPath = self.MainFrame.relativePaths
        scriptFile = pyFile
        
        # Loop over all the keys, values of the configuration dictionary        
        for key, item in configuration.items():
            if key.startswith("option"):
                continue
            if isinstance(self.FindWindowByName(key), wx.CheckBox):
                item = bool(int(item))

            if key == "create_manifest_file":
                continue
            
            if type(item) == ListType and item:
                # Terrible hack to setup correctly the string to be included
                # in the setup file
                if key not in ["hookspath", "scripts", "excludes", "pathex"]:
                    tmp = []
                    for data in item:
                        data = data + (_pyInstallerTOC[key],)
                        tmp.append(data)
                    item = tmp
                elif key == "pathex":
                    if buildDir not in item:
                        item.append(buildDir)
                elif key == "scripts":
                    continue

                item = setupString(key, item, True, useRelPath=useRelPath, mainScript=scriptFile)

            if key == "exename" and not item.strip() and not oneDir:
                item = os.path.splitext(os.path.split(pyFile)[1])[0] + ".exe"
            if key == "dist_dir" and not item.strip() and oneDir:
                item = normpath(os.path.split(pyFile)[0] + "/dist")
            if key in ["icon", "version"]:
                if not item.strip():
                    item = None
                else:
                    if useRelPath:
                        item = 'r"%s"'%(relpath(item, os.path.split(scriptFile)[0]))
                    else:
                        item = "r'%s'"%item
            
            setupDict[key] = item

        # Set up the obscure options
        otherOptions = []
        for indx, checks in enumerate(self.optionsCheckBoxes):
            if checks.GetValue():
                otherOptions.append(_pyInstallerOptions[indx])

        setupDict["options"] = otherOptions

        # Depending on the various choices in the interface, PyInstaller
        # includes/excludes some Python source file located in
        # PyInstaller_Path/support/

        pyInstallerPath = self.MainFrame.GetPyInstallerPath()
        if not pyInstallerPath or pyInstallerPath == "None":
            msg = _("PyInstaller path has not been set.\n\nPlease set the PyInstaller" \
                    "path using the menu Options ==> Set PyInstaller path.")
            self.MainFrame.RunError(2, msg)
            return

        items = configuration["scripts"][:]
        pyInstallerPath += "/support/"

        if setupDict["level"] != "0":
            # Include zlib as user wants compression
            items.append(normpath(pyInstallerPath + "_mountzlib.py").encode())
        
        if includeTk:
            # That's a bit of a mess, but PyInstaller is not exactly user-friendly...
            if oneDir:
                items.append(normpath(pyInstallerPath + "useTK.py").encode())
            else:
                items.extend([normpath(pyInstallerPath + "unpackTK.py").encode(),
                              normpath(pyInstallerPath + "useTK.py").encode(),
                              normpath(pyInstallerPath + "removeTK.py").encode()])

        if not ascii:
            # Using unicode
            items.append(normpath(pyInstallerPath + "useUnicode.py").encode())
            
        items.append(items[0])
        items.pop(0)
        
        setupDict["scripts"] = setupString("scripts", items, True)
        
        # Add the custom code (if any)
        setupDict["customcode"] = (customCode and [customCode.strip()] or ["# No custom code added"])[0]

        # Add the post-compilation code (if any)
        setupDict["postcompilecode"] = (postCompile and [postCompile.strip()] or ["# No post-compilation code added"])[0]
        
        # Include the GUI2Exe version in the setup script
        importDict["gui2exever"] = self.MainFrame.GetVersion()

        # Populate the "import" section
        setupScript = _pyInstaller_imports % importDict

        if oneDir:
            target = _pyInstaller_target_onedir
            if includeTk:
                setupDict["TkPKG"] = "TkTree(),"
            else:
                setupDict["TkPKG"] = ""
        else:
            target = _pyInstaller_target_onefile
            if includeTk:
                setupDict["TkPKG"] = "TkPKG(),"
            else:
                setupDict["TkPKG"] = ""
            
        # Populate the main section of the setup script            
        setupScript += target % setupDict

        # Send a message to out fancy bottom log window
        transdict = dict(projectName=project.GetName())
        self.MainFrame.SendMessage(0, _('Setup script for "%(projectName)s" succesfully created')%transdict)
        return setupScript, buildDir
示例#4
0
    def BuildTargetClass(self, configuration, project, manifestFile):
        """ Builds the VendorID compilation options, returning it as a string. """

        # A couple of dictionaries to populate the setup string
        configuration = dict(configuration)
        distChoice = self.distChoice.GetValue()
        instChoice = self.instChoice.GetValue()

        pythonName = os.path.split(os.path.splitext(self.scriptPicker.GetPath())[0])[1]
        optionString = ""

        useRelPath = self.MainFrame.relativePaths
        mainFile = self.scriptPicker.GetPath()

        # Loop over all the keys, values of the configuration dictionary
        for key, item in configuration.items():
            if key in ["build_dir_choice", "install_dir_choice"]:
                continue
            if key == "script":
                buildDir, scriptFile = os.path.split(item)
            elif key == "build_dir":
                if not item.strip() or not distChoice:
                    outputDir = os.path.normpath(buildDir + "/build_%s" % pythonName)
                    if distChoice:
                        self.MainFrame.SendMessage(
                            1, _('Empty build_dir option. Using default value "build_%s"' % pythonName)
                        )
                else:
                    optionString += " -d %s " % item.strip()
                    outputDir = os.path.normpath(buildDir + "/" + item.strip())

            elif key == "install":
                if not item.strip() or not instChoice:
                    if instChoice:
                        self.MainFrame.SendMessage(
                            1, _('Empty install_dir option. Using default value "sys.exec_prefix"')
                        )
                else:
                    optionString += " -t %s " % item.strip()

            elif key == "iconfile":
                if item.strip():
                    if useRelPath:
                        optionString += " -i %s " % relpath(item.strip(), os.path.split(mainFile)[0])
                    else:
                        optionString += " -i %s " % item.strip()

            elif key == "exename":
                if item.strip():
                    optionString += " -n %s " % item.strip()

            elif key == "prefix":
                if item.strip():
                    optionString += " -p %s " % item.strip()

            if isinstance(self.FindWindowByName(key), wx.CheckBox):
                item = bool(int(item))
                if key == "verbose" and item:
                    optionString += " -v "
                elif key == "signed" and not item:
                    optionString += " -u "
                elif key == "console" and item:
                    optionString += " -c "
                elif key == "runmake":
                    runMakeInstall = item

            if type(item) == ListType:
                # Loop over all the included packages and modules
                for pkg in item:
                    optionString += " -m %s " % pkg

        # Send a message to out fancy bottom log window
        transdict = dict(projectName=project.GetName())

        if wx.Platform == "__WXMSW__":
            separator = "&"
        else:
            separator = ";"

        # Get the user preference for GNU make or MS nmake
        vendorIDPath = self.MainFrame.GetVendorIDPath()
        if not vendorIDPath:
            makeOrNmake = "make"
        else:
            sibPath, makeOrNmake = vendorIDPath

        optionString = optionString + " " + self.scriptPicker.GetPath().strip()
        optionString += " " + separator + "cd %s " % outputDir + separator + "%s " % makeOrNmake
        if runMakeInstall:
            optionString += separator + "cd %s " % outputDir + separator + "%s install" % makeOrNmake

        self.MainFrame.SendMessage(0, _('Setup script for "%(projectName)s" succesfully created') % transdict)
        return optionString, buildDir
示例#5
0
    def BuildTargetClass(self, configuration, project, customCode, postCompile):
        """ Builds the cx_Freeze compilation script file, returning it as a string. """

        # A couple of dictionaries to populate the setup string
        setupDict, importDict = {}, {}
        configuration = dict(configuration)
        # Delete the keys we don't need
        distChoice = self.distChoice.GetValue()
        del configuration["dist_dir_choice"]

        extension = ""
        if wx.Platform == "__WXMSW__":
            extension = ".exe"

        useRelPath = self.MainFrame.relativePaths
        scriptFile = self.multipleExe.GetItem(0, 2).GetText()

        # Loop over all the keys, values of the configuration dictionary
        for key, item in configuration.items():
            if key == "initScript" and not item:
                # I don't know how often this option is used
                item = ""

            elif isinstance(self.FindWindowByName(key), wx.CheckBox):
                item = bool(int(item))

            if key in ["create_manifest_file", "multipleexe"]:
                # Skip these 2 options, we'll take care of them later...
                continue

            if isinstance(item, basestring) and key != "compress":
                if key == "dist_dir":
                    if not item.strip() or not distChoice:
                        item = "dist"
                        if distChoice:
                            self.MainFrame.SendMessage(1, _('Empty dist_dir option. Using default value "dist"'))
                if not item.strip():
                    item = None
                else:
                    if useRelPath and key in ["initScript", "icon"]:
                        item = 'r"%s"' % (relpath(item, os.path.split(scriptFile)[0]))
                    else:
                        item = 'r"%s"' % item

            if type(item) == ListType:
                # Terrible hack to setup correctly the string to be included
                # in the setup file
                item = setupString(key, item, useRelPath=useRelPath, mainScript=scriptFile)

            setupDict[key] = item

        baseName = "GUI2Exe_Target_%d"
        targetclass = ""
        executables = "["

        # Loop over all the Python scripts used
        for indx in xrange(self.multipleExe.GetItemCount()):
            # Add the target class
            tupleMultiple = (baseName % (indx + 1),)
            scriptFile = self.multipleExe.GetItem(indx, 2).GetText()
            buildDir, scriptFile = os.path.split(scriptFile)
            # Add the Python script file
            tupleMultiple += (scriptFile,)
            # Add the init script
            tupleMultiple += (setupDict["initScript"],)
            consoleOrWindows = self.multipleExe.GetItem(indx, 1).GetText()
            # Check if it is a GUI app and if it runs on Windows
            if consoleOrWindows == "windows" and sys.platform == "win32":
                tupleMultiple += ("'Win32GUI'",)
            else:
                tupleMultiple += (None,)
            # Add the distribution directory
            tupleMultiple += (setupDict["dist_dir"],)
            targetName = self.multipleExe.GetItem(indx, 3).GetText()

            if not targetName.strip():
                # Missing executable name? Use the Python script file name
                targetName = os.path.splitext(scriptFile)[0]
                self.MainFrame.SendMessage(1, _("Empty Executable Name option. Using Python script name"))

            # Add the executable name
            tupleMultiple += (targetName + extension,)
            # Add the remaining keys
            tupleMultiple += (
                bool(setupDict["compress"]),
                setupDict["copy_dependent_files"],
                setupDict["append_script_toexe"],
                setupDict["append_script_tolibrary"],
                setupDict["icon"],
            )

            # Build the target classes
            targetclass += _cx_Freeze_class % tupleMultiple
            # Save the executables in a list to be processed by cx_Freeze
            executables += tupleMultiple[0] + ", "

        keys = setupDict.keys()
        for key in keys:
            # Remove the keys we have already used
            if key not in ["includes", "excludes", "packages", "path"]:
                setupDict.pop(key)

        # Add the custom code (if any)
        setupDict["customcode"] = (customCode and [customCode.strip()] or ["# No custom code added"])[0]

        # Add the post-compilation code (if any)
        setupDict["postcompilecode"] = (postCompile and [postCompile.strip()] or ["# No post-compilation code added"])[
            0
        ]

        # Add the target classes and the executables list
        setupDict["targetclasses"] = targetclass
        setupDict["executables"] = executables.rstrip(", ") + "]"

        # Include the GUI2Exe version in the setup script
        importDict["gui2exever"] = self.MainFrame.GetVersion()

        # Populate the "import" section
        setupScript = _cx_Freeze_imports % importDict

        globalSetup = ["version", "description", "author", "name"]
        for col in xrange(4, self.multipleExe.GetColumnCount()):
            item = self.multipleExe.GetItem(indx, col).GetText()
            setupDict[globalSetup[col - 4]] = '"%s"' % item.strip()

        # Populate the main section of the setup script
        setupScript += _cx_Freeze_target % setupDict

        # Send a message to out fancy bottom log window
        transdict = dict(projectName=project.GetName())
        self.MainFrame.SendMessage(0, _('Setup script for "%(projectName)s" succesfully created') % transdict)
        return setupScript, buildDir
示例#6
0
    def BuildTargetClass(self, configuration, project, customCode,
                         postCompile):
        """ Builds the cx_Freeze compilation script file, returning it as a string. """

        # A couple of dictionaries to populate the setup string
        setupDict, importDict = {}, {}
        configuration = dict(configuration)
        # Delete the keys we don't need
        distChoice = self.distChoice.GetValue()
        del configuration["dist_dir_choice"]

        extension = ""
        if wx.Platform == "__WXMSW__":
            extension = ".exe"

        useRelPath = self.MainFrame.relativePaths
        scriptFile = self.multipleExe.GetItem(0, 2).GetText()

        # Loop over all the keys, values of the configuration dictionary
        for key, item in configuration.items():
            if key == "initScript" and not item:
                # I don't know how often this option is used
                item = ""

            elif isinstance(self.FindWindowByName(key), wx.CheckBox):
                item = bool(int(item))

            if key in ["create_manifest_file", "multipleexe"]:
                # Skip these 2 options, we'll take care of them later...
                continue

            if isinstance(item, basestring) and key != "compress":
                if key == "dist_dir":
                    if not item.strip() or not distChoice:
                        item = "dist"
                        if distChoice:
                            self.MainFrame.SendMessage(
                                1,
                                _('Empty dist_dir option. Using default value "dist"'
                                  ))
                if not item.strip():
                    item = None
                else:
                    if useRelPath and key in ["initScript", "icon"]:
                        item = 'r"%s"' % (relpath(
                            item,
                            os.path.split(scriptFile)[0]))
                    else:
                        item = 'r"%s"' % item

            if type(item) == ListType:
                # Terrible hack to setup correctly the string to be included
                # in the setup file
                item = setupString(key,
                                   item,
                                   useRelPath=useRelPath,
                                   mainScript=scriptFile)

            setupDict[key] = item

        baseName = "GUI2Exe_Target_%d"
        targetclass = ""
        executables = "["

        # Loop over all the Python scripts used
        for indx in xrange(self.multipleExe.GetItemCount()):
            # Add the target class
            tupleMultiple = (baseName % (indx + 1), )
            scriptFile = self.multipleExe.GetItem(indx, 2).GetText()
            buildDir, scriptFile = os.path.split(scriptFile)
            # Add the Python script file
            tupleMultiple += (scriptFile, )
            # Add the init script
            tupleMultiple += (setupDict["initScript"], )
            consoleOrWindows = self.multipleExe.GetItem(indx, 1).GetText()
            # Check if it is a GUI app and if it runs on Windows
            if consoleOrWindows == "windows" and sys.platform == "win32":
                tupleMultiple += ("'Win32GUI'", )
            else:
                tupleMultiple += (None, )
            # Add the distribution directory
            tupleMultiple += (setupDict["dist_dir"], )
            targetName = self.multipleExe.GetItem(indx, 3).GetText()

            if not targetName.strip():
                # Missing executable name? Use the Python script file name
                targetName = os.path.splitext(scriptFile)[0]
                self.MainFrame.SendMessage(
                    1,
                    _('Empty Executable Name option. Using Python script name')
                )

            # Add the executable name
            tupleMultiple += (targetName + extension, )
            # Add the remaining keys
            tupleMultiple += (bool(setupDict["compress"]),
                              setupDict["copy_dependent_files"],
                              setupDict["append_script_toexe"],
                              setupDict["append_script_tolibrary"],
                              setupDict["icon"])

            # Build the target classes
            targetclass += _cx_Freeze_class % tupleMultiple
            # Save the executables in a list to be processed by cx_Freeze
            executables += tupleMultiple[0] + ", "

        keys = setupDict.keys()
        for key in keys:
            # Remove the keys we have already used
            if key not in ["includes", "excludes", "packages", "path"]:
                setupDict.pop(key)

        # Add the custom code (if any)
        setupDict["customcode"] = (customCode and [customCode.strip()]
                                   or ["# No custom code added"])[0]

        # Add the post-compilation code (if any)
        setupDict["postcompilecode"] = (
            postCompile and [postCompile.strip()]
            or ["# No post-compilation code added"])[0]

        # Add the target classes and the executables list
        setupDict["targetclasses"] = targetclass
        setupDict["executables"] = executables.rstrip(", ") + "]"

        # Include the GUI2Exe version in the setup script
        importDict["gui2exever"] = self.MainFrame.GetVersion()

        # Populate the "import" section
        setupScript = _cx_Freeze_imports % importDict

        globalSetup = ["version", "description", "author", "name"]
        for col in xrange(4, self.multipleExe.GetColumnCount()):
            item = self.multipleExe.GetItem(indx, col).GetText()
            setupDict[globalSetup[col - 4]] = '"%s"' % item.strip()

        # Populate the main section of the setup script
        setupScript += _cx_Freeze_target % setupDict

        # Send a message to out fancy bottom log window
        transdict = dict(projectName=project.GetName())
        self.MainFrame.SendMessage(
            0,
            _('Setup script for "%(projectName)s" succesfully created') %
            transdict)
        return setupScript, buildDir
示例#7
0
    def BuildTargetClass(self, configuration, project, manifestFile):
        """ Builds the VendorID compilation options, returning it as a string. """

        # A couple of dictionaries to populate the setup string
        configuration = dict(configuration)
        distChoice = self.distChoice.GetValue()
        instChoice = self.instChoice.GetValue()

        pythonName = os.path.split(
            os.path.splitext(self.scriptPicker.GetPath())[0])[1]
        optionString = ""

        useRelPath = self.MainFrame.relativePaths
        mainFile = self.scriptPicker.GetPath()

        # Loop over all the keys, values of the configuration dictionary
        for key, item in configuration.items():
            if key in ["build_dir_choice", "install_dir_choice"]:
                continue
            if key == "script":
                buildDir, scriptFile = os.path.split(item)
            elif key == "build_dir":
                if not item.strip() or not distChoice:
                    outputDir = os.path.normpath(buildDir +
                                                 "/build_%s" % pythonName)
                    if distChoice:
                        self.MainFrame.SendMessage(
                            1,
                            _('Empty build_dir option. Using default value "build_%s"'
                              % pythonName))
                else:
                    optionString += " -d %s " % item.strip()
                    outputDir = os.path.normpath(buildDir + "/" + item.strip())

            elif key == "install":
                if not item.strip() or not instChoice:
                    if instChoice:
                        self.MainFrame.SendMessage(
                            1,
                            _('Empty install_dir option. Using default value "sys.exec_prefix"'
                              ))
                else:
                    optionString += " -t %s " % item.strip()

            elif key == "iconfile":
                if item.strip():
                    if useRelPath:
                        optionString += " -i %s " % relpath(
                            item.strip(),
                            os.path.split(mainFile)[0])
                    else:
                        optionString += " -i %s " % item.strip()

            elif key == "exename":
                if item.strip():
                    optionString += " -n %s " % item.strip()

            elif key == "prefix":
                if item.strip():
                    optionString += " -p %s " % item.strip()

            if isinstance(self.FindWindowByName(key), wx.CheckBox):
                item = bool(int(item))
                if key == "verbose" and item:
                    optionString += " -v "
                elif key == "signed" and not item:
                    optionString += " -u "
                elif key == "console" and item:
                    optionString += " -c "
                elif key == "runmake":
                    runMakeInstall = item

            if type(item) == ListType:
                # Loop over all the included packages and modules
                for pkg in item:
                    optionString += " -m %s " % pkg

        # Send a message to out fancy bottom log window
        transdict = dict(projectName=project.GetName())

        if wx.Platform == "__WXMSW__":
            separator = "&"
        else:
            separator = ";"

        # Get the user preference for GNU make or MS nmake
        vendorIDPath = self.MainFrame.GetVendorIDPath()
        if not vendorIDPath:
            makeOrNmake = "make"
        else:
            sibPath, makeOrNmake = vendorIDPath

        optionString = optionString + " " + self.scriptPicker.GetPath().strip()
        optionString += " " + separator + "cd %s " % outputDir + separator + "%s " % makeOrNmake
        if runMakeInstall:
            optionString += separator + "cd %s " % outputDir + separator + "%s install" % makeOrNmake

        self.MainFrame.SendMessage(
            0,
            _('Setup script for "%(projectName)s" succesfully created') %
            transdict)
        return optionString, buildDir