Sun, 09 Apr 2017 19:41:35 +0200
Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
--- a/Globals/__init__.py Sun Apr 09 16:46:35 2017 +0200 +++ b/Globals/__init__.py Sun Apr 09 19:41:35 2017 +0200 @@ -182,6 +182,40 @@ return "" +def getPyQtToolsPath(version=5): + """ + Module function to get the path of the PyQt tools. + + @param version PyQt major version + @type int + @return path to the PyQt tools + @rtype str + """ + import Preferences + + path = "" + + # step 1: check, if the user has configured a tools path + path = Preferences.getQt("PyQtToolsDir") + + # step 2: determine from used Python interpreter (pyrcc is test object) + if not path: + program = "pyrcc{0}".format(version) + if isWindowsPlatform(): + program += ".exe" + dirName = os.path.dirname(sys.executable) + if os.path.exists(os.path.join(dirName, program)): + path = dirName + elif os.path.exists(os.path.join(dirName, "Scripts", program)): + path = os.path.join(dirName, "Scripts") + else: + dirName = os.path.dirname(sys.executable) + if os.path.exists(os.path.join(dirName, program)): + path = dirName + + return path + + def getQtBinariesPath(): """ Module function to get the path of the Qt binaries. @@ -244,8 +278,8 @@ "C:\\Python27", "C:\\Python28"] posixVersionsList = ["2.5", "2.6", "2.7", "2.8"] else: - winPathList = ["C:\\Python3{0}".format(x) for x in range(5)] - posixVersionsList = ["3.{0}".format(x) for x in range(5)] + winPathList = ["C:\\Python3{0}".format(x) for x in range(11)] + posixVersionsList = ["3.{0}".format(x) for x in range(11)] posixPathList = ["/usr/bin", "/usr/local/bin"] interpreters = []
--- a/Preferences/ProgramsDialog.py Sun Apr 09 16:46:35 2017 +0200 +++ b/Preferences/ProgramsDialog.py Sun Apr 09 19:41:35 2017 +0200 @@ -134,41 +134,38 @@ self.tr("Qt Assistant"), exe, version=version) # 2. do the PyQt programs - # 2a. Translation Extractor PyQt4 + # 2.1 do the PyQt4 programs + # 2.1a. Translation Extractor PyQt4 self.__createProgramEntry( self.tr("Translation Extractor (Python, PyQt4)"), - Utilities.isWindowsPlatform() and - Utilities.getWindowsExecutablePath("pylupdate4") or "pylupdate4", + Utilities.generatePyQtToolPath("pylupdate4"), '-version', 'pylupdate', -1) - # 2b. Forms Compiler PyQt4 + # 2.1b. Forms Compiler PyQt4 self.__createProgramEntry( self.tr("Forms Compiler (Python, PyQt4)"), - Utilities.isWindowsPlatform() and - Utilities.getWindowsExecutablePath("pyuic4") or "pyuic4", + Utilities.generatePyQtToolPath("pyuic4"), '--version', 'Python User', 4) - # 2c. Resource Compiler PyQt4 + # 2.1c. Resource Compiler PyQt4 self.__createProgramEntry( self.tr("Resource Compiler (Python, PyQt4)"), - Utilities.isWindowsPlatform() and - Utilities.getWindowsExecutablePath("pyrcc4") or "pyrcc4", + Utilities.generatePyQtToolPath("pyrcc4"), '-version', 'Resource Compiler', -1) - # 2d. Translation Extractor PyQt5 + + # 2.2 do the PyQt5 programs + # 2.2a. Translation Extractor PyQt5 self.__createProgramEntry( self.tr("Translation Extractor (Python, PyQt5)"), - Utilities.isWindowsPlatform() and - Utilities.getWindowsExecutablePath("pylupdate5") or "pylupdate5", + Utilities.generatePyQtToolPath("pylupdate5"), '-version', 'pylupdate', -1) - # 2e. Forms Compiler PyQt5 + # 2.2b. Forms Compiler PyQt5 self.__createProgramEntry( self.tr("Forms Compiler (Python, PyQt5)"), - Utilities.isWindowsPlatform() and - Utilities.getWindowsExecutablePath("pyuic5") or "pyuic5", + Utilities.generatePyQtToolPath("pyuic5"), '--version', 'Python User', 4) - # 2f. Resource Compiler PyQt5 + # 2.2c. Resource Compiler PyQt5 self.__createProgramEntry( self.tr("Resource Compiler (Python, PyQt5)"), - Utilities.isWindowsPlatform() and - Utilities.getWindowsExecutablePath("pyrcc5") or "pyrcc5", + Utilities.generatePyQtToolPath("pyrcc5"), '-version', '', -1, versionRe='Resource Compiler|pyrcc5') # 3. do the PySide programs
--- a/Preferences/__init__.py Sun Apr 09 16:46:35 2017 +0200 +++ b/Preferences/__init__.py Sun Apr 09 19:41:35 2017 +0200 @@ -1221,6 +1221,7 @@ "QtToolsPostfix4": "", "PyuicIndent": 4, "PyuicFromImports": False, + "PyQtToolsDir": "", } # defaults for corba related stuff
--- a/Utilities/__init__.py Sun Apr 09 16:46:35 2017 +0200 +++ b/Utilities/__init__.py Sun Apr 09 19:41:35 2017 +0200 @@ -65,7 +65,7 @@ from Globals import ( # __IGNORE_WARNING__ isWindowsPlatform, isLinuxPlatform, isMacPlatform, getConfigDir, setConfigDir, getPythonModulesDirectory, getPyQt5ModulesDirectory, - getQtBinariesPath) + getQtBinariesPath, getPyQtToolsPath) from E5Gui.E5Application import e5App @@ -1671,7 +1671,34 @@ return ("open", newArgs) ############################################################################### -# Qt utility functions below +# PyQt utility functions below +############################################################################### + + +def generatePyQtToolPath(toolname): + """ + Module function to generate the executable path for a PyQt tool. + + @param toolname base name of the tool + @type str + @return executable path name of the tool + @rtype str + """ + pyqtVariant = int(toolname[-1]) + pyqtToolsPath = getPyQtToolsPath(pyqtVariant) + if pyqtToolsPath: + exe = os.path.join(pyqtToolsPath, toolname) + if isWindowsPlatform(): + exe += ".exe" + else: + if isWindowsPlatform(): + exe = getWindowsExecutablePath(toolname) + else: + exe = toolname + return exe + +############################################################################### +# PySide utility functions below ############################################################################### @@ -1679,7 +1706,7 @@ """ Module function to generate the executable path for a PySide tool. - @param toolname base name of the tool (string or QString) + @param toolname base name of the tool (string) @return the PySide tool path with extension (string) """ if isWindowsPlatform():