예제 #1
0
    def ProcessOutputText(self):
        """ Process the result of the compilation steps. """

        self.project.hasBeenCompiled = True
        
        if self.compiler != "py2exe":
            # This is available only for py2exe
            return
        
        # Look for what py2exe thinks are the missing modules
        indx = self.fullText.rfind("The following modules")
        moduleText = self.fullText[indx:]
        # They are usually put inside square braces
        indx1, indx2 = moduleText.find("["), moduleText.find("]")
        if indx1 < 0 or indx2 < 0:
            missingModules = []
        else:
            missingModules = eval(moduleText[indx1:indx2+1])
            missingModules = [tuple(miss.split(".")) for miss in missingModules]

        # Look for what py2exe thinks are the binary dependencies
        binaryDependencies = []
        text = self.fullText
        indx = text.find("*** binary dependencies ***")
        text = text[indx:].split("\n")
        text = text[7:]
        # Here it's bit tricky, but it works
        for line in text:
            line = line.strip().split("-")
            dll, path = line[0], "".join(line[1:])
            if not dll:
                break
            binaryDependencies.append([dll.strip(), opj(path.strip())])

        self.project.SetCompilationData(missingModules, binaryDependencies)
예제 #2
0
    def ProcessOutputText(self):
        """ Process the result of the compilation steps. """

        self.project.hasBeenCompiled = True
        
        if self.compiler != "py2exe":
            # This is available only for py2exe
            return
        
        # Look for what py2exe thinks are the missing modules
        indx = self.fullText.rfind("The following modules")
        moduleText = self.fullText[indx:]
        # They are usually put inside square braces
        indx1, indx2 = moduleText.find("["), moduleText.find("]")
        if indx1 < 0 or indx2 < 0:
            missingModules = []
        else:
            missingModules = eval(moduleText[indx1:indx2+1])
            missingModules = [tuple(miss.split(".")) for miss in missingModules]

        # Look for what py2exe thinks are the binary dependencies
        binaryDependencies = []
        text = self.fullText
        indx = text.find("*** binary dependencies ***")
        text = text[indx:].split("\n")
        text = text[7:]
        # Here it's bit tricky, but it works
        for line in text:
            line = line.strip().split("-")
            dll, path = line[0], "".join(line[1:])
            if not dll:
                break
            binaryDependencies.append([dll.strip(), opj(path.strip())])

        self.project.SetCompilationData(missingModules, binaryDependencies)
예제 #3
0
    def Destroy(self):
        """ Destroy the process. """

        # Ok, this line is commented because if I leave it as it is Python
        # bombs with the classical Windows error dialog
        self.process.Destroy()
        
        self.MainFrame.process = None

        if self.compiler != "vendorid":        
            # Close the temporary file
            os.close(self.tmpFileName[0])

        # Remove the temporary file from the compilation directory
        if os.path.isfile(opj(self.tmpFileName[1])):
            try:
                os.remove(opj(self.tmpFileName[1]))
            except:
                # Something is keeping it open... skip for now
                pass

        # Returns to the installation directory            
        os.chdir(self.MainFrame.installDir)
예제 #4
0
    def Destroy(self):
        """ Destroy the process. """

        # Ok, this line is commented because if I leave it as it is Python
        # bombs with the classical Windows error dialog
        self.process.Destroy()
        
        self.MainFrame.process = None

        if self.compiler != "vendorid":        
            # Close the temporary file
            os.close(self.tmpFileName[0])

        # Remove the temporary file from the compilation directory
        if os.path.isfile(opj(self.tmpFileName[1])):
            try:
                os.remove(opj(self.tmpFileName[1]))
            except:
                # Something is keeping it open... skip for now
                pass

        # Returns to the installation directory            
        os.chdir(self.MainFrame.installDir)
예제 #5
0
    def Start(self):
        """ Starts the compilation process. """

        # Change the directory to the compilation folder
        os.chdir(opj(self.buildDir))
        # Verify if it is a dry-run or a real compilation
        dryRun = (self.run and [""] or ["--dry-run"])[0]

        # Create a temporary file that we will delete later
        if self.compiler == "PyInstaller":
            suffix = ".spec"
        elif self.compiler == "vendorid":
            if wx.Platform == "__WXMSW__":
                suffix = ".bat"
            else:
                suffix = ".sh"
        else:
            suffix = ".py"

        # Run the setup.py optimized, if the user chose to
        configuration = self.project[self.compiler]
        optimize = ""
        if "optimize" in configuration:
            value = int(configuration["optimize"])
            if value > 0:
                optimize = "-" + "O"*value

        setupScript = self.setupScript
        fd, tmpFileName = tempfile.mkstemp(suffix=suffix, dir=self.buildDir)

        if wx.Platform == "__WXMSW__":
            separator = "&"
        else:
            separator = ";"
            
        # Build the compilation command
        if self.compiler == "py2exe":
            cmd = '%s %s -u "%s" %s %s'%(self.pythonVersion, optimize, tmpFileName, self.compiler, dryRun)
            
        elif self.compiler == "cx_Freeze":
            distDir = configuration["dist_dir"]
            distChoice = configuration["dist_dir_choice"]
            if not distDir.strip() or not distChoice:
                distDir = "dist"
            cmd = '%s %s -u "%s" %s%s'%(self.pythonVersion, optimize, tmpFileName, "build --build-exe=", distDir)

        elif self.compiler == "bbfreeze":
            cmd = '%s %s -u "%s"'%(self.pythonVersion, optimize, tmpFileName)

        elif self.compiler == "PyInstaller":
            pyInstallerPath = self.MainFrame.GetPyInstallerPath()
            build = os.path.normpath(pyInstallerPath + "/Build.py")
            cmd = '%s %s -u "%s" "%s"'%(self.pythonVersion, optimize, build, tmpFileName)

        elif self.compiler == "py2app":
            cmd = '%s %s -u "%s" %s'%(self.pythonVersion, optimize, tmpFileName, self.compiler)

        elif self.compiler == "vendorid":
            sibPath, makeOrNmake = self.MainFrame.GetVendorIDPath()
            sibString = self.setupScript.split(separator)
            setupScript = '%s %s -u %s %s\n'%(self.pythonVersion, optimize, sibPath, sibString[0])
            for strs in sibString[1:]:
                setupScript += strs + "\n"

            if wx.Platform == "__WXMSW__":
                cmd = '%s'%tmpFileName
            else:
                cmd = 'chmod +x %s; ./%s'%(tmpFileName, tmpFileName)

        # Write the setup script string in the temporary file
        fid = open(tmpFileName, "wt")
        fid.write(setupScript)            
        fid.close()

        # Store the temporary file data
        self.tmpFileName = (fd, tmpFileName)

        if self.compiler == "vendorid":
            os.close(fd)
            
        # Monitor the elapsed time
        self.startTime = time.time()
            
        # Start the process, redirecting the output to catch stdio
        self.process = wx.Process(self.MainFrame)
        self.process.Redirect()
        # We want the process to be asynchronous
        self.pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process)
예제 #6
0
    def Start(self):
        """ Starts the compilation process. """

        # Change the directory to the compilation folder
        os.chdir(opj(self.buildDir))
        # Verify if it is a dry-run or a real compilation
        dryRun = (self.run and [""] or ["--dry-run"])[0]

        # Create a temporary file that we will delete later
        if self.compiler == "PyInstaller":
            suffix = ".spec"
        elif self.compiler == "vendorid":
            if wx.Platform == "__WXMSW__":
                suffix = ".bat"
            else:
                suffix = ".sh"
        else:
            suffix = ".py"

        # Run the setup.py optimized, if the user chose to
        configuration = self.project[self.compiler]
        optimize = ""
        if "optimize" in configuration:
            value = int(configuration["optimize"])
            if value > 0:
                optimize = "-" + "O"*value

        setupScript = self.setupScript
        fd, tmpFileName = tempfile.mkstemp(suffix=suffix, dir=self.buildDir)

        if wx.Platform == "__WXMSW__":
            separator = "&"
        else:
            separator = ";"
            
        # Build the compilation command
        if self.compiler == "py2exe":
            cmd = '%s %s -u "%s" %s %s'%(self.pythonVersion, optimize, tmpFileName, self.compiler, dryRun)
            
        elif self.compiler == "cx_Freeze":
            distDir = configuration["dist_dir"]
            distChoice = configuration["dist_dir_choice"]
            if not distDir.strip() or not distChoice:
                distDir = "dist"
            cmd = '%s %s -u "%s" %s%s'%(self.pythonVersion, optimize, tmpFileName, "build --build-exe=", distDir)

        elif self.compiler == "bbfreeze":
            cmd = '%s %s -u "%s"'%(self.pythonVersion, optimize, tmpFileName)

        elif self.compiler == "PyInstaller":
            pyInstallerPath = self.MainFrame.GetPyInstallerPath()
            build = os.path.normpath(pyInstallerPath + "/Build.py")
            cmd = '%s %s -u "%s" "%s"'%(self.pythonVersion, optimize, build, tmpFileName)

        elif self.compiler == "py2app":
            cmd = '%s %s -u "%s" %s'%(self.pythonVersion, optimize, tmpFileName, self.compiler)

        elif self.compiler == "vendorid":
            sibPath, makeOrNmake = self.MainFrame.GetVendorIDPath()
            sibString = self.setupScript.split(separator)
            setupScript = '%s %s -u %s %s\n'%(self.pythonVersion, optimize, sibPath, sibString[0])
            for strs in sibString[1:]:
                setupScript += strs + "\n"

            if wx.Platform == "__WXMSW__":
                cmd = '%s'%tmpFileName
            else:
                cmd = 'chmod +x %s; ./%s'%(tmpFileName, tmpFileName)

        # Write the setup script string in the temporary file
        fid = open(tmpFileName, "wt")
        fid.write(setupScript)            
        fid.close()

        # Store the temporary file data
        self.tmpFileName = (fd, tmpFileName)

        if self.compiler == "vendorid":
            os.close(fd)
            
        # Monitor the elapsed time
        self.startTime = time.time()
            
        # Start the process, redirecting the output to catch stdio
        self.process = wx.Process(self.MainFrame)
        self.process.Redirect()
        # We want the process to be asynchronous
        self.pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process)