Fri, 18 Nov 2016 18:34:34 +0100
Fixed an issue locating the right PyQt5 tools executables on Windows.
--- a/Preferences/ProgramsDialog.py Thu Nov 17 18:59:13 2016 +0100 +++ b/Preferences/ProgramsDialog.py Fri Nov 18 18:34:34 2016 +0100 @@ -137,32 +137,38 @@ # 2a. Translation Extractor PyQt4 self.__createProgramEntry( self.tr("Translation Extractor (Python, PyQt4)"), - Utilities.isWindowsPlatform() and "pylupdate4.exe" or "pylupdate4", + Utilities.isWindowsPlatform() and + Utilities.getWindowsExecutablePath("pylupdate4") or "pylupdate4", '-version', 'pylupdate', -1) # 2b. Forms Compiler PyQt4 self.__createProgramEntry( self.tr("Forms Compiler (Python, PyQt4)"), - Utilities.isWindowsPlatform() and "pyuic4.bat" or "pyuic4", + Utilities.isWindowsPlatform() and + Utilities.getWindowsExecutablePath("pyuic4") or "pyuic4", '--version', 'Python User', 4) # 2c. Resource Compiler PyQt4 self.__createProgramEntry( self.tr("Resource Compiler (Python, PyQt4)"), - Utilities.isWindowsPlatform() and "pyrcc4.exe" or "pyrcc4", + Utilities.isWindowsPlatform() and + Utilities.getWindowsExecutablePath("pyrcc4") or "pyrcc4", '-version', 'Resource Compiler', -1) # 2d. Translation Extractor PyQt5 self.__createProgramEntry( self.tr("Translation Extractor (Python, PyQt5)"), - Utilities.isWindowsPlatform() and "pylupdate5.exe" or "pylupdate5", + Utilities.isWindowsPlatform() and + Utilities.getWindowsExecutablePath("pylupdate5") or "pylupdate5", '-version', 'pylupdate', -1) # 2e. Forms Compiler PyQt5 self.__createProgramEntry( self.tr("Forms Compiler (Python, PyQt5)"), - Utilities.isWindowsPlatform() and "pyuic5.bat" or "pyuic5", + Utilities.isWindowsPlatform() and + Utilities.getWindowsExecutablePath("pyuic5") or "pyuic5", '--version', 'Python User', 4) # 2f. Resource Compiler PyQt5 self.__createProgramEntry( self.tr("Resource Compiler (Python, PyQt5)"), - Utilities.isWindowsPlatform() and "pyrcc5.exe" or "pyrcc5", + Utilities.isWindowsPlatform() and + Utilities.getWindowsExecutablePath("pyrcc5") or "pyrcc5", '-version', '', -1, versionRe='Resource Compiler|pyrcc5') # 3. do the PySide programs
--- a/Project/ProjectFormsBrowser.py Thu Nov 17 18:59:13 2016 +0100 +++ b/Project/ProjectFormsBrowser.py Fri Nov 18 18:34:34 2016 +0100 @@ -752,13 +752,13 @@ if self.project.getProjectType() in ["Qt4", ]: self.uicompiler = 'pyuic4' if Utilities.isWindowsPlatform(): - uic = self.uicompiler + '.bat' + uic = Utilities.getWindowsExecutablePath(self.uicompiler) else: uic = self.uicompiler elif self.project.getProjectType() in ["PyQt5"]: self.uicompiler = 'pyuic5' if Utilities.isWindowsPlatform(): - uic = self.uicompiler + '.bat' + uic = Utilities.getWindowsExecutablePath(self.uicompiler) else: uic = self.uicompiler elif self.project.getProjectType() in ["E6Plugin"]: @@ -767,7 +767,7 @@ else: self.uicompiler = 'pyuic5' if Utilities.isWindowsPlatform(): - uic = self.uicompiler + '.bat' + uic = Utilities.getWindowsExecutablePath(self.uicompiler) else: uic = self.uicompiler elif self.project.getProjectType() == "PySide": @@ -779,7 +779,7 @@ if self.project.getProjectType() == "Qt4": self.uicompiler = 'rbuic4' if Utilities.isWindowsPlatform(): - uic = self.uicompiler + '.exe' + uic = Utilities.getWindowsExecutablePath(self.uicompiler) else: uic = self.uicompiler else:
--- a/Project/ProjectResourcesBrowser.py Thu Nov 17 18:59:13 2016 +0100 +++ b/Project/ProjectResourcesBrowser.py Fri Nov 18 18:34:34 2016 +0100 @@ -635,7 +635,8 @@ if self.project.getProjectType() in ["Qt4", "Qt4C"]: self.rccCompiler = 'pyrcc4' if Utilities.isWindowsPlatform(): - self.rccCompiler += '.exe' + self.rccCompiler = \ + Utilities.getWindowsExecutablePath(self.rccCompiler) if PYQT_VERSION >= 0x040500: if self.project.getProjectLanguage() in \ ["Python", "Python2"]: @@ -645,7 +646,8 @@ elif self.project.getProjectType() in ["PyQt5", "PyQt5C"]: self.rccCompiler = 'pyrcc5' if Utilities.isWindowsPlatform(): - self.rccCompiler += '.exe' + self.rccCompiler = \ + Utilities.getWindowsExecutablePath(self.rccCompiler) elif self.project.getProjectType() in ["E6Plugin"]: if PYQT_VERSION < 0x050000: self.rccCompiler = 'pyrcc4' @@ -657,7 +659,8 @@ else: self.rccCompiler = 'pyrcc5' if Utilities.isWindowsPlatform(): - self.rccCompiler += '.exe' + self.rccCompiler = \ + Utilities.getWindowsExecutablePath(self.rccCompiler) elif self.project.getProjectType() in ["PySide", "PySideC"]: self.rccCompiler = Utilities.generatePySideToolPath( 'pyside-rcc')
--- a/Project/ProjectTranslationsBrowser.py Thu Nov 17 18:59:13 2016 +0100 +++ b/Project/ProjectTranslationsBrowser.py Fri Nov 18 18:34:34 2016 +0100 @@ -1037,18 +1037,21 @@ if self.project.getProjectType() in ["Qt4", "Qt4C"]: self.pylupdate = 'pylupdate4' if Utilities.isWindowsPlatform(): - self.pylupdate = self.pylupdate + '.exe' + self.pylupdate = \ + Utilities.getWindowsExecutablePath(self.pylupdate) elif self.project.getProjectType() in ["PyQt5", "PyQt5C"]: self.pylupdate = 'pylupdate5' if Utilities.isWindowsPlatform(): - self.pylupdate = self.pylupdate + '.exe' + self.pylupdate = \ + Utilities.getWindowsExecutablePath(self.pylupdate) elif self.project.getProjectType() in ["E6Plugin"]: if PYQT_VERSION < 0x050000: self.pylupdate = 'pylupdate4' else: self.pylupdate = 'pylupdate5' if Utilities.isWindowsPlatform(): - self.pylupdate = self.pylupdate + '.exe' + self.pylupdate = \ + Utilities.getWindowsExecutablePath(self.pylupdate) elif self.project.getProjectType() in ["PySide", "PySideC"]: self.pylupdate = Utilities.generatePySideToolPath('pyside-lupdate') else:
--- a/Utilities/__init__.py Thu Nov 17 18:59:13 2016 +0100 +++ b/Utilities/__init__.py Fri Nov 18 18:34:34 2016 +0100 @@ -977,6 +977,50 @@ return paths +def getWindowsExecutablePath(file): + """ + Function to build the full path of an executable file from the environment + on Windows platforms. + + First an executable with the extension .exe is searched for, thereafter one + with the extension .bat and finally the given file name as is. The first + match is returned. + + @param file filename of the executable to check (string) + @return full executable name, if the executable file is accessible + via the searchpath defined by the PATH environment variable, or an + empty string otherwise. + """ + if os.path.isabs(file): + if os.access(file, os.X_OK): + return file + else: + return "" + + filenames = [file + ".exe", file + ".bat", file] + + for filename in filenames: + cur_path = os.path.join(os.curdir, filename) + if os.path.exists(cur_path): + if os.access(cur_path, os.X_OK): + return cur_path + + path = os.getenv('PATH') + + # environment variable not defined + if path is None: + return "" + + dirs = path.split(os.pathsep) + for dir in dirs: + for filename in filenames: + exe = os.path.join(dir, filename) + if os.access(exe, os.X_OK): + return exe + + return "" + + def isExecutable(exe): """ Function to check, if a file is executable.