Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python). eric7

Mon, 04 Apr 2022 17:43:43 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 04 Apr 2022 17:43:43 +0200
branch
eric7
changeset 9016
6f079c524e99
parent 9015
dfeefad914ed
child 9017
ab708b168534

Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).

eric7/APIs/Python3/eric7.api file | annotate | diff | comparison | revisions
eric7/Debugger/DebuggerInterfacePython.py file | annotate | diff | comparison | revisions
eric7/Documentation/Help/source.qch file | annotate | diff | comparison | revisions
eric7/Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
eric7/Documentation/Source/eric7.Globals.__init__.html file | annotate | diff | comparison | revisions
eric7/Documentation/Source/eric7.Plugins.DocumentationPlugins.Ericapi.EricapiConfigDialog.html file | annotate | diff | comparison | revisions
eric7/Globals/__init__.py file | annotate | diff | comparison | revisions
eric7/MicroPython/EspDevices.py file | annotate | diff | comparison | revisions
eric7/PipInterface/Pip.py file | annotate | diff | comparison | revisions
eric7/PluginManager/PluginManager.py file | annotate | diff | comparison | revisions
eric7/PluginManager/PluginRepositoryDialog.py file | annotate | diff | comparison | revisions
eric7/Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py file | annotate | diff | comparison | revisions
eric7/Plugins/DocumentationPlugins/Ericdoc/EricdocConfigDialog.py file | annotate | diff | comparison | revisions
eric7/Plugins/VcsPlugins/vcsGit/git.py file | annotate | diff | comparison | revisions
eric7/Plugins/VcsPlugins/vcsMercurial/ConfigurationPage/MercurialPage.py file | annotate | diff | comparison | revisions
eric7/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/histedit.py file | annotate | diff | comparison | revisions
eric7/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py file | annotate | diff | comparison | revisions
eric7/Preferences/ConfigurationPages/EditorFilePage.py file | annotate | diff | comparison | revisions
eric7/Preferences/ConfigurationPages/EmailPage.py file | annotate | diff | comparison | revisions
eric7/Preferences/ProgramsDialog.py file | annotate | diff | comparison | revisions
eric7/Preferences/__init__.py file | annotate | diff | comparison | revisions
eric7/Project/CreateDialogCodeDialog.py file | annotate | diff | comparison | revisions
eric7/Project/ProjectProtocolsBrowser.py file | annotate | diff | comparison | revisions
eric7/QScintilla/ShellWindow.py file | annotate | diff | comparison | revisions
eric7/Tools/TrayStarter.py file | annotate | diff | comparison | revisions
eric7/UI/UserInterface.py file | annotate | diff | comparison | revisions
eric7/Utilities/BackgroundService.py file | annotate | diff | comparison | revisions
eric7/Utilities/__init__.py file | annotate | diff | comparison | revisions
eric7/VirtualEnv/VirtualenvAddEditDialog.py file | annotate | diff | comparison | revisions
eric7/VirtualEnv/VirtualenvConfigurationDialog.py file | annotate | diff | comparison | revisions
eric7/VirtualEnv/VirtualenvExecDialog.py file | annotate | diff | comparison | revisions
eric7/VirtualEnv/VirtualenvManager.py file | annotate | diff | comparison | revisions
eric7/WebBrowser/WebBrowserWindow.py file | annotate | diff | comparison | revisions
scripts/install-dependencies.py file | annotate | diff | comparison | revisions
--- a/eric7/APIs/Python3/eric7.api	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/APIs/Python3/eric7.api	Mon Apr 04 17:43:43 2022 +0200
@@ -1897,6 +1897,7 @@
 eric7.Globals.getInstallInfoFilePath?4()
 eric7.Globals.getPyQt6ModulesDirectory?4()
 eric7.Globals.getPyQtToolsPath?4(version=5)
+eric7.Globals.getPythonExecutable?4()
 eric7.Globals.getPythonLibraryDirectory?4()
 eric7.Globals.getQtBinariesPath?4()
 eric7.Globals.getWebBrowserSupport?4()
--- a/eric7/Debugger/DebuggerInterfacePython.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Debugger/DebuggerInterfacePython.py	Mon Apr 04 17:43:43 2022 +0200
@@ -22,6 +22,7 @@
 
 from . import DebugClientCapabilities
 
+import Globals
 import Preferences
 import Utilities
 
@@ -185,7 +186,7 @@
         execPath = venvManager.getVirtualenvExecPath(venvName)
         if interpreter == "":
             # use the interpreter used to run eric for identical variants
-            interpreter = sys.executable.replace("w.exe", ".exe")
+            interpreter = Globals.getPythonExecutable()
         if interpreter == "":
             EricMessageBox.critical(
                 None,
@@ -390,7 +391,7 @@
             interpreter == "" and
             project.getProjectLanguage().startswith("Python")
         ):
-            interpreter = sys.executable.replace("w.exe", ".exe")
+            interpreter = Globals.getPythonExecutable()
         if interpreter == "":
             EricMessageBox.critical(
                 None,
Binary file eric7/Documentation/Help/source.qch has changed
--- a/eric7/Documentation/Help/source.qhp	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Documentation/Help/source.qhp	Mon Apr 04 17:43:43 2022 +0200
@@ -18638,6 +18638,7 @@
       <keyword name="getPyQt6ModulesDirectory" id="getPyQt6ModulesDirectory" ref="eric7.Globals.__init__.html#getPyQt6ModulesDirectory" />
       <keyword name="getPyQtToolsPath" id="getPyQtToolsPath" ref="eric7.Globals.__init__.html#getPyQtToolsPath" />
       <keyword name="getPython" id="getPython" ref="eric7.Preferences.__init__.html#getPython" />
+      <keyword name="getPythonExecutable" id="getPythonExecutable" ref="eric7.Globals.__init__.html#getPythonExecutable" />
       <keyword name="getPythonLibPath" id="getPythonLibPath" ref="eric7.Utilities.__init__.html#getPythonLibPath" />
       <keyword name="getPythonLibraryDirectory" id="getPythonLibraryDirectory" ref="eric7.Globals.__init__.html#getPythonLibraryDirectory" />
       <keyword name="getPythonVersion" id="getPythonVersion" ref="eric7.Utilities.__init__.html#getPythonVersion" />
--- a/eric7/Documentation/Source/eric7.Globals.__init__.html	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Documentation/Source/eric7.Globals.__init__.html	Mon Apr 04 17:43:43 2022 +0200
@@ -50,6 +50,10 @@
 <td>Module function to get the path of the PyQt tools.</td>
 </tr>
 <tr>
+<td><a href="#getPythonExecutable">getPythonExecutable</a></td>
+<td>Function to determine the path of the (non-windowed) Python executable.</td>
+</tr>
+<tr>
 <td><a href="#getPythonLibraryDirectory">getPythonLibraryDirectory</a></td>
 <td>Function to determine the path to Python's library directory.</td>
 </tr>
@@ -275,6 +279,28 @@
 <div align="right"><a href="#top">Up</a></div>
 <hr />
 <hr />
+<a NAME="getPythonExecutable" ID="getPythonExecutable"></a>
+<h2>getPythonExecutable</h2>
+<b>getPythonExecutable</b>(<i></i>)
+
+<p>
+    Function to determine the path of the (non-windowed) Python executable.
+</p>
+<dl>
+<dt>Return:</dt>
+<dd>
+path of the Python executable
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+str
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr />
+<hr />
 <a NAME="getPythonLibraryDirectory" ID="getPythonLibraryDirectory"></a>
 <h2>getPythonLibraryDirectory</h2>
 <b>getPythonLibraryDirectory</b>(<i></i>)
--- a/eric7/Documentation/Source/eric7.Plugins.DocumentationPlugins.Ericapi.EricapiConfigDialog.html	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Documentation/Source/eric7.Plugins.DocumentationPlugins.Ericapi.EricapiConfigDialog.html	Mon Apr 04 17:43:43 2022 +0200
@@ -68,7 +68,7 @@
 </tr>
 <tr>
 <td><a href="#EricapiConfigDialog.generateParameters">generateParameters</a></td>
-<td>Public method that generates the commandline parameters.</td>
+<td>Public method that generates the command line parameters.</td>
 </tr>
 <tr>
 <td><a href="#EricapiConfigDialog.on_addButton_clicked">on_addButton_clicked</a></td>
@@ -149,7 +149,7 @@
 <b>generateParameters</b>(<i></i>)
 
 <p>
-        Public method that generates the commandline parameters.
+        Public method that generates the command line parameters.
 </p>
 <p>
         It generates a list of strings to be used
--- a/eric7/Globals/__init__.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Globals/__init__.py	Mon Apr 04 17:43:43 2022 +0200
@@ -244,6 +244,21 @@
     configDir = os.path.expanduser(d)
 
 
+def getPythonExecutable():
+    """
+    Function to determine the path of the (non-windowed) Python executable.
+    
+    @return path of the Python executable
+    @rtype str
+    """
+    if sys.platform.startswith("linux"):
+        return sys.executable
+    elif sys.platform == "darwin":
+        return sys.executable.replace("pythonw", "python")
+    else:
+        return sys.executable.replace("pythonw.exe", "python.exe")
+
+
 def getPythonLibraryDirectory():
     """
     Function to determine the path to Python's library directory.
@@ -554,7 +569,7 @@
     scriptPath = os.path.join(getConfig("ericDir"), "Tools",
                               "webBrowserSupport.py")
     proc = QProcess()
-    proc.start(sys.executable, [scriptPath, qVersion()])
+    proc.start(getPythonExecutable(), [scriptPath, qVersion()])
     variant = (
         str(proc.readAllStandardOutput(), "utf-8", 'replace').strip()
         if proc.waitForFinished(10000) else
--- a/eric7/MicroPython/EspDevices.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/MicroPython/EspDevices.py	Mon Apr 04 17:43:43 2022 +0200
@@ -8,8 +8,6 @@
 boards.
 """
 
-import sys
-
 from PyQt6.QtCore import pyqtSlot, QProcess
 from PyQt6.QtWidgets import QDialog
 
@@ -20,6 +18,7 @@
 from .MicroPythonDevices import MicroPythonDevice
 from .MicroPythonWidget import HAS_QTCHART
 
+import Globals
 import Preferences
 
 
@@ -187,7 +186,7 @@
             dlg = EricProcessDialog(self.tr("'esptool erase_flash' Output"),
                                     self.tr("Erase Flash"),
                                     showProgress=True)
-            res = dlg.startProcess(sys.executable, flashArgs)
+            res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs)
             if res:
                 dlg.exec()
     
@@ -222,7 +221,7 @@
             dlg = EricProcessDialog(self.tr("'esptool write_flash' Output"),
                                     self.tr("Flash MicroPython Firmware"),
                                     showProgress=True)
-            res = dlg.startProcess(sys.executable, flashArgs)
+            res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs)
             if res:
                 dlg.exec()
     
@@ -257,7 +256,7 @@
             dlg = EricProcessDialog(self.tr("'esptool write_flash' Output"),
                                     self.tr("Flash Additional Firmware"),
                                     showProgress=True)
-            res = dlg.startProcess(sys.executable, flashArgs)
+            res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs)
             if res:
                 dlg.exec()
     
@@ -285,7 +284,7 @@
             dlg = EricProcessDialog(self.tr("'esptool read_flash' Output"),
                                     self.tr("Backup Firmware"),
                                     showProgress=True)
-            res = dlg.startProcess(sys.executable, flashArgs)
+            res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs)
             if res:
                 dlg.exec()
     
@@ -323,7 +322,7 @@
             dlg = EricProcessDialog(self.tr("'esptool write_flash' Output"),
                                     self.tr("Restore Firmware"),
                                     showProgress=True)
-            res = dlg.startProcess(sys.executable, flashArgs)
+            res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs)
             if res:
                 dlg.exec()
     
@@ -340,7 +339,7 @@
         ]
         dlg = EricProcessDialog(self.tr("'esptool chip_id' Output"),
                                 self.tr("Show Chip ID"))
-        res = dlg.startProcess(sys.executable, args)
+        res = dlg.startProcess(Globals.getPythonExecutable(), args)
         if res:
             dlg.exec()
     
@@ -357,7 +356,7 @@
         ]
         dlg = EricProcessDialog(self.tr("'esptool flash_id' Output"),
                                 self.tr("Show Flash ID"))
-        res = dlg.startProcess(sys.executable, args)
+        res = dlg.startProcess(Globals.getPythonExecutable(), args)
         if res:
             dlg.exec()
     
@@ -374,7 +373,7 @@
         ]
         dlg = EricProcessDialog(self.tr("'esptool read_mac' Output"),
                                 self.tr("Show MAC Address"))
-        res = dlg.startProcess(sys.executable, args)
+        res = dlg.startProcess(Globals.getPythonExecutable(), args)
         if res:
             dlg.exec()
     
@@ -398,7 +397,7 @@
                 "flash_id"
             ]
             proc = QProcess()
-            proc.start(sys.executable, args)
+            proc.start(Globals.getPythonExecutable(), args)
             procStarted = proc.waitForStarted(10000)
             if procStarted:
                 proc.waitForFinished(10000)
@@ -409,7 +408,8 @@
         Private slot to install the esptool package via pip.
         """
         pip = ericApp().getObject("Pip")
-        pip.installPackages(["esptool"], interpreter=sys.executable)
+        pip.installPackages(["esptool"],
+                            interpreter=Globals.getPythonExecutable())
     
     def getDocumentationUrl(self):
         """
--- a/eric7/PipInterface/Pip.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/PipInterface/Pip.py	Mon Apr 04 17:43:43 2022 +0200
@@ -210,7 +210,7 @@
             )
             if not venvName:
                 # fall back to interpreter used to run eric7
-                return sys.executable
+                return Globals.getPythonExecutable()
         
         interpreter = (
             ericApp().getObject("VirtualEnvManager")
@@ -352,7 +352,9 @@
         if not venvName:
             return False
         
-        if self.getVirtualenvInterpreter(venvName) == sys.executable:
+        if self.getVirtualenvInterpreter(venvName) in (
+            sys.executable, Globals.getPythonExecutable()
+        ):
             upgradePyQt = self.__checkUpgradePyQt(packages)
             upgradeEric = self.__checkUpgradeEric(packages)
             if upgradeEric or upgradePyQt:
@@ -961,7 +963,7 @@
                     args.append("--reverse")
                 
                 proc = QProcess()
-                proc.start(sys.executable.replace("w.exe", ".exe"), args)
+                proc.start(Globals.getPythonExecutable(), args)
                 if proc.waitForStarted(15000) and proc.waitForFinished(30000):
                     output = str(proc.readAllStandardOutput(),
                                  Preferences.getSystem("IOEncoding"),
--- a/eric7/PluginManager/PluginManager.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/PluginManager/PluginManager.py	Mon Apr 04 17:43:43 2022 +0200
@@ -1427,7 +1427,8 @@
             # Installation is performed via the plug-in installation script.
             from PipInterface.Pip import Pip
             pip = Pip(self)
-        pip.installPackages(packages, interpreter=sys.executable)
+        pip.installPackages(packages,
+                            interpreter=Globals.getPythonExecutable())
 
 #
 # eflag: noqa = M801
--- a/eric7/PluginManager/PluginRepositoryDialog.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/PluginManager/PluginRepositoryDialog.py	Mon Apr 04 17:43:43 2022 +0200
@@ -7,7 +7,6 @@
 Module implementing a dialog showing the available plugins.
 """
 
-import sys
 import os
 import zipfile
 import glob
@@ -990,7 +989,7 @@
         
         if (
             not os.path.isfile(applPath) or
-            not proc.startDetached(sys.executable, args)
+            not proc.startDetached(Globals.getPythonExecutable(), args)
         ):
             EricMessageBox.critical(
                 self,
--- a/eric7/Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py	Mon Apr 04 17:43:43 2022 +0200
@@ -7,7 +7,6 @@
 Module implementing a dialog to enter the parameters for eric7_api.
 """
 
-import sys
 import os
 import copy
 
@@ -17,6 +16,8 @@
 from EricWidgets.EricPathPicker import EricPathPickerModes
 
 from .Ui_EricapiConfigDialog import Ui_EricapiConfigDialog
+
+import Globals
 import Utilities
 import DocumentationTools
 
@@ -111,7 +112,7 @@
     
     def generateParameters(self):
         """
-        Public method that generates the commandline parameters.
+        Public method that generates the command line parameters.
         
         It generates a list of strings to be used
         to set the QProcess arguments for the ericapi call and
@@ -126,7 +127,7 @@
         args = []
         
         # 1. the program name
-        args.append(sys.executable)
+        args.append(Globals.getPythonExecutable())
         args.append(
             Utilities.normabsjoinpath(getConfig('ericDir'), "eric7_api.py"))
         
--- a/eric7/Plugins/DocumentationPlugins/Ericdoc/EricdocConfigDialog.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Plugins/DocumentationPlugins/Ericdoc/EricdocConfigDialog.py	Mon Apr 04 17:43:43 2022 +0200
@@ -7,7 +7,6 @@
 Module implementing a dialog to enter the parameters for eric7_doc.
 """
 
-import sys
 import os
 import copy
 
@@ -21,6 +20,8 @@
 from DocumentationTools.Config import (
     eric7docDefaultColors, eric7docColorParameterNames
 )
+
+import Globals
 import Utilities
 
 from eric7config import getConfig
@@ -177,7 +178,7 @@
         args = []
         
         # 1. the program name
-        args.append(sys.executable)
+        args.append(Globals.getPythonExecutable())
         args.append(
             Utilities.normabsjoinpath(getConfig('ericDir'), "eric7_doc.py"))
         
--- a/eric7/Plugins/VcsPlugins/vcsGit/git.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Plugins/VcsPlugins/vcsGit/git.py	Mon Apr 04 17:43:43 2022 +0200
@@ -25,6 +25,7 @@
 
 from .GitDialog import GitDialog
 
+import Globals
 import Utilities
 import Preferences
 
@@ -1832,7 +1833,8 @@
         
         import sys
         editor = sys.argv[0].replace(".py", "_editor.py")
-        env = {"GIT_EDITOR": "{0} {1}".format(sys.executable, editor)}
+        env = {"GIT_EDITOR": "{0} {1}".format(
+            Globals.getPythonExecutable(), editor)}
         
         args = self.initCommand("commit")
         
@@ -3221,7 +3223,8 @@
         
         import sys
         editor = sys.argv[0].replace(".py", "_editor.py")
-        env = {"GIT_EDITOR": "{0} {1}".format(sys.executable, editor)}
+        env = {"GIT_EDITOR": "{0} {1}".format(
+            Globals.getPythonExecutable(), editor)}
         
         args = self.initCommand("cherry-pick")
         args.append("--continue")
--- a/eric7/Plugins/VcsPlugins/vcsMercurial/ConfigurationPage/MercurialPage.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Plugins/VcsPlugins/vcsMercurial/ConfigurationPage/MercurialPage.py	Mon Apr 04 17:43:43 2022 +0200
@@ -8,7 +8,6 @@
 """
 
 import os
-import sys
 
 from PyQt6.QtCore import pyqtSlot
 
@@ -20,6 +19,7 @@
 from .Ui_MercurialPage import Ui_MercurialPage
 from .. import HgUtilities
 
+import Globals
 from Utilities import supportedCodecs
 
 
@@ -132,7 +132,8 @@
         Private slot to install Mercurial alongside eric7.
         """
         pip = ericApp().getObject("Pip")
-        pip.installPackages(["mercurial"], interpreter=sys.executable)
+        pip.installPackages(["mercurial"],
+                            interpreter=Globals.getPythonExecutable())
         self.installButton.setEnabled(not self.__mercurialInstalled())
     
     def __mercurialInstalled(self):
--- a/eric7/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/histedit.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/histedit.py	Mon Apr 04 17:43:43 2022 +0200
@@ -8,13 +8,14 @@
 """
 
 import os
-import sys
 
 from PyQt6.QtWidgets import QDialog
 
 from ..HgExtension import HgExtension
 from ..HgDialog import HgDialog
 
+import Globals
+
 
 class Histedit(HgExtension):
     """
@@ -52,7 +53,10 @@
             
             args = self.vcs.initCommand("histedit")
             args.append("-v")
-            args.extend(["--config", f"ui.editor={sys.executable} {editor}"])
+            args.extend([
+                "--config",
+                f"ui.editor={Globals.getPythonExecutable()} {editor}"
+            ])
             if keep:
                 args.append("--keep")
             if rev:
@@ -64,8 +68,10 @@
                 args.append(rev)
             
             env = {
-                "HGEDITOR": "{0} {1}".format(sys.executable, editor),
-                "EDITOR": "{0} {1}".format(sys.executable, editor),
+                "HGEDITOR": "{0} {1}".format(
+                    Globals.getPythonExecutable(), editor),
+                "EDITOR": "{0} {1}".format(
+                    Globals.getPythonExecutable(), editor),
             }
             
             dia = HgDialog(
@@ -92,7 +98,8 @@
         
         editor = os.path.join(
             os.path.dirname(__file__), "HgHisteditEditor.py")
-        env = {"HGEDITOR": "{0} {1}".format(sys.executable, editor)}
+        env = {"HGEDITOR": "{0} {1}".format(
+            Globals.getPythonExecutable(), editor)}
         
         dia = HgDialog(
             self.tr("Continue histedit session"),
@@ -120,7 +127,8 @@
         
         editor = os.path.join(
             os.path.dirname(__file__), "HgHisteditEditor.py")
-        env = {"HGEDITOR": "{0} {1}".format(sys.executable, editor)}
+        env = {"HGEDITOR": "{0} {1}".format(
+            Globals.getPythonExecutable(), editor)}
         
         dia = HgDialog(
             self.tr("Abort histedit session"),
@@ -147,7 +155,8 @@
         
         editor = os.path.join(
             os.path.dirname(__file__), "HgHisteditEditor.py")
-        env = {"HGEDITOR": "{0} {1}".format(sys.executable, editor)}
+        env = {"HGEDITOR": "{0} {1}".format(
+            Globals.getPythonExecutable(), editor)}
         
         dia = HgDialog(
             self.tr("Edit Plan"),
--- a/eric7/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py	Mon Apr 04 17:43:43 2022 +0200
@@ -9,7 +9,6 @@
 
 import os
 import re
-import sys
 import json
 
 from PyQt6.QtCore import QFileInfo, pyqtSlot, QProcess, QByteArray
@@ -28,6 +27,7 @@
 
 import UI.PixmapCache
 
+import Globals
 import Utilities
 import Preferences
 
@@ -83,7 +83,7 @@
         self.__pyqt6Available = False
         self.__pyqt6Server = QProcess(self)
         self.__pyqt6Server.start(
-            sys.executable, [os.path.join(
+            Globals.getPythonExecutable(), [os.path.join(
                 os.path.dirname(__file__), "QRegularExpressionWizardServer.py")
             ])
         if self.__pyqt6Server.waitForStarted(5000):
--- a/eric7/Preferences/ConfigurationPages/EditorFilePage.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Preferences/ConfigurationPages/EditorFilePage.py	Mon Apr 04 17:43:43 2022 +0200
@@ -19,6 +19,7 @@
 from .ConfigurationPageBase import ConfigurationPageBase
 from .Ui_EditorFilePage import Ui_EditorFilePage
 
+import Globals
 from Utilities import supportedCodecs
 import Preferences
 
@@ -361,7 +362,8 @@
         Private slot to install the pymdown extensions package via pip.
         """
         pip = ericApp().getObject("Pip")
-        pip.installPackages(["pymdown-extensions"], interpreter=sys.executable)
+        pip.installPackages(["pymdown-extensions"],
+                            interpreter=Globals.getPythonExecutable())
         self.polishPage()
         
     def polishPage(self):
--- a/eric7/Preferences/ConfigurationPages/EmailPage.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Preferences/ConfigurationPages/EmailPage.py	Mon Apr 04 17:43:43 2022 +0200
@@ -9,7 +9,6 @@
 
 import smtplib
 import socket
-import sys
 
 from PyQt6.QtCore import pyqtSlot
 
@@ -24,6 +23,7 @@
 from .ConfigurationPageBase import ConfigurationPageBase
 from .Ui_EmailPage import Ui_EmailPage
 
+import Globals
 import Preferences
 
 
@@ -266,7 +266,8 @@
         Private slot to install the required packages for use of Google Mail.
         """
         pip = ericApp().getObject("Pip")
-        pip.installPackages(RequiredPackages, interpreter=sys.executable)
+        pip.installPackages(RequiredPackages,
+                            interpreter=Globals.getPythonExecutable())
         self.__checkGoogleMail()
     
     @pyqtSlot()
--- a/eric7/Preferences/ProgramsDialog.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Preferences/ProgramsDialog.py	Mon Apr 04 17:43:43 2022 +0200
@@ -9,7 +9,6 @@
 
 import os
 import re
-import sys
 
 from PyQt6.QtCore import pyqtSlot, Qt, QProcess
 from PyQt6.QtWidgets import (
@@ -21,6 +20,7 @@
 
 from .Ui_ProgramsDialog import Ui_ProgramsDialog
 
+import Globals
 import Preferences
 import Utilities
 
@@ -241,7 +241,7 @@
             # 6c. grpc
             exe = Preferences.getProtobuf("grpcPython")
             if not exe:
-                exe = sys.executable
+                exe = Globals.getPythonExecutable()
             self.__createProgramEntry(
                 self.tr("gRPC Compiler"), exe, '--version', 'libprotoc', -1,
                 exeModule=['-m', 'grpc_tools.protoc'])
@@ -288,7 +288,8 @@
                 self.tr("MicroPython - MPY Cross Compiler"), exe, '--version',
                 'MicroPython', 1)
             self.__createProgramEntry(
-                self.tr("MicroPython - ESP Tool"), sys.executable, 'version',
+                self.tr("MicroPython - ESP Tool"),
+                Globals.getPythonExecutable(), 'version',
                 'esptool', -1, exeModule=['-m', 'esptool'])
             exe = Preferences.getMicroPython("DfuUtilPath")
             if not exe:
--- a/eric7/Preferences/__init__.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Preferences/__init__.py	Mon Apr 04 17:43:43 2022 +0200
@@ -21,7 +21,6 @@
 import fnmatch
 import shutil
 import json
-import sys
 
 from PyQt6.QtCore import (
     QDir, QPoint, QLocale, QSettings, QFileInfo, QCoreApplication, QByteArray,
@@ -1790,7 +1789,7 @@
         else:
             interpreter = ""
         if not interpreter:
-            return sys.executable
+            return Globals.getPythonExecutable()
         return interpreter
     elif key == "DebugClientType3":
         debugClientType = Prefs.settings.value(
--- a/eric7/Project/CreateDialogCodeDialog.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Project/CreateDialogCodeDialog.py	Mon Apr 04 17:43:43 2022 +0200
@@ -7,7 +7,6 @@
 Module implementing a dialog to generate code for a Qt5 dialog.
 """
 
-import sys
 import os
 import json
 import contextlib
@@ -28,6 +27,7 @@
 
 from eric7config import getConfig
 
+import Globals
 import Preferences
 
 
@@ -172,7 +172,7 @@
         execPath = venvManager.getVirtualenvExecPath(venvName)
         
         if not interpreter:
-            interpreter = sys.executable
+            interpreter = Globals.getPythonExecutable()
         
         env = QProcessEnvironment.systemEnvironment()
         if execPath:
--- a/eric7/Project/ProjectProtocolsBrowser.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Project/ProjectProtocolsBrowser.py	Mon Apr 04 17:43:43 2022 +0200
@@ -10,7 +10,6 @@
 
 import os
 import glob
-import sys
 import contextlib
 
 from PyQt6.QtCore import QThread, pyqtSignal, QProcess
@@ -33,6 +32,7 @@
 import UI.PixmapCache
 from UI.NotificationWidget import NotificationTypes
 
+import Globals
 import Preferences
 import Utilities
 
@@ -479,7 +479,7 @@
         if grpc:
             exe = Preferences.getProtobuf("grpcPython")
             if exe == "":
-                exe = sys.executable
+                exe = Globals.getPythonExecutable()
             exeArgs = ['-m', 'grpc_tools.protoc']
         else:
             exe = Preferences.getProtobuf("protoc")
--- a/eric7/QScintilla/ShellWindow.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/QScintilla/ShellWindow.py	Mon Apr 04 17:43:43 2022 +0200
@@ -7,7 +7,6 @@
 Module implementing a stand alone shell window.
 """
 
-import sys
 import os
 
 from PyQt6.QtCore import (
@@ -29,7 +28,7 @@
 import UI.PixmapCache
 import Preferences
 
-from Globals import isMacPlatform
+from Globals import isMacPlatform, getPythonExecutable
 
 from .Shell import Shell
 from .APIsManager import APIsManager
@@ -1055,7 +1054,7 @@
         """
         Private slot to start a new instance of eric.
         """
-        program = sys.executable
+        program = getPythonExecutable()
         eric7 = os.path.join(getConfig("ericDir"), "eric7_shell.py")
         args = [eric7]
         QProcess.startDetached(program, args)
--- a/eric7/Tools/TrayStarter.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Tools/TrayStarter.py	Mon Apr 04 17:43:43 2022 +0200
@@ -280,7 +280,7 @@
         
         if (
             not os.path.isfile(applPath) or
-            not proc.startDetached(sys.executable, args)
+            not proc.startDetached(Globals.getPythonExecutable(), args)
         ):
             EricMessageBox.critical(
                 self,
--- a/eric7/UI/UserInterface.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/UI/UserInterface.py	Mon Apr 04 17:43:43 2022 +0200
@@ -4402,7 +4402,7 @@
         
         if res and self.__shutdown():
             ericApp().closeAllWindows()
-            program = sys.executable
+            program = Globals.getPythonExecutable()
             args = ["-m", "eric7", "--start-session"]
             args.extend(self.__restartArgs)
             QProcess.startDetached(program, args)
@@ -4490,7 +4490,7 @@
         @type str
         """
         ericApp().closeAllWindows()
-        program = sys.executable.replace("w.exe", ".exe")
+        program = Globals.getPythonExecutable()
         ericStartArgs = ["-m", "eric7", "--start-session"]
         ericStartArgs.extend(self.__restartArgs)
         
@@ -4511,7 +4511,7 @@
         """
         if not Preferences.getUI("SingleApplicationMode"):
             # start eric without any arguments
-            program = sys.executable
+            program = Globals.getPythonExecutable()
             eric7 = os.path.join(getConfig("ericDir"), "eric7.py")
             args = [eric7]
             QProcess.startDetached(program, args)
@@ -5677,7 +5677,7 @@
                 
         if (
             not os.path.isfile(viewer) or
-            not proc.startDetached(sys.executable, args)
+            not proc.startDetached(Globals.getPythonExecutable(), args)
         ):
             EricMessageBox.critical(
                 self,
@@ -5734,7 +5734,7 @@
         
         if (
             not os.path.isfile(viewer) or
-            not proc.startDetached(sys.executable, args)
+            not proc.startDetached(Globals.getPythonExecutable(), args)
         ):
             EricMessageBox.critical(
                 self,
@@ -5757,7 +5757,7 @@
         
         if (
             not os.path.isfile(browser) or
-            not proc.startDetached(sys.executable, args)
+            not proc.startDetached(Globals.getPythonExecutable(), args)
         ):
             EricMessageBox.critical(
                 self,
@@ -5842,7 +5842,7 @@
         
         if (
             not os.path.isfile(snap) or
-            not proc.startDetached(sys.executable, args)
+            not proc.startDetached(Globals.getPythonExecutable(), args)
         ):
             EricMessageBox.critical(
                 self,
@@ -6375,7 +6375,7 @@
                     "--name={0}".format(self.__webBrowserSAName),
                     home
                 ]
-                process.start(sys.executable, args)
+                process.start(Globals.getPythonExecutable(), args)
                 if not process.waitForStarted():
                     EricMessageBox.warning(
                         self,
--- a/eric7/Utilities/BackgroundService.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Utilities/BackgroundService.py	Mon Apr 04 17:43:43 2022 +0200
@@ -72,7 +72,7 @@
         interpreter = ericApp().getObject(
             "VirtualEnvManager").getVirtualenvInterpreter(venvName)
         if not interpreter:
-            interpreter = sys.executable.replace("w.exe", ".exe")
+            interpreter = Globals.getPythonExecutable()
         if interpreter:
             process = self.__startExternalClient(interpreter, port)
             if process:
@@ -272,7 +272,7 @@
         interpreter = ericApp().getObject(
             "VirtualEnvManager").getVirtualenvInterpreter(venvName)
         if not interpreter:
-            interpreter = sys.executable.replace("w.exe", ".exe")
+            interpreter = Globals.getPythonExecutable()
         
         # Tweak the processes list to reflect the changed interpreter
         proc, inter = self.processes.pop('Python3', [None, None])
--- a/eric7/Utilities/__init__.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/Utilities/__init__.py	Mon Apr 04 17:43:43 2022 +0200
@@ -55,7 +55,7 @@
     isWindowsPlatform, isLinuxPlatform, isMacPlatform, desktopName,
     sessionType, getConfigDir, setConfigDir, getPythonLibraryDirectory,
     getPyQt6ModulesDirectory, getQtBinariesPath, getPyQtToolsPath,
-    qVersionTuple
+    qVersionTuple, getPythonExecutable
 )
 
 from EricWidgets.EricApplication import ericApp
@@ -1796,7 +1796,7 @@
         interpreter = ericApp().getObject(
             "VirtualEnvManager").getVirtualenvInterpreter(venvName)
         if interpreter == "" or not isinpath(interpreter):
-            interpreter = sys.executable
+            interpreter = getPythonExecutable()
         prefix = os.path.dirname(interpreter)
         return os.path.join(prefix, "Scripts", toolname + '.exe')
     else:
@@ -1829,7 +1829,7 @@
     interpreter = ericApp().getObject(
         "VirtualEnvManager").getVirtualenvInterpreter(venvName)
     if interpreter == "" or not isinpath(interpreter):
-        interpreter = sys.executable
+        interpreter = getPythonExecutable()
     
     checker = os.path.join(
         getConfig('ericDir'), "Utilities", "PySideImporter.py")
--- a/eric7/VirtualEnv/VirtualenvAddEditDialog.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/VirtualEnv/VirtualenvAddEditDialog.py	Mon Apr 04 17:43:43 2022 +0200
@@ -8,7 +8,6 @@
 """
 
 import os
-import sys
 
 from PyQt6.QtCore import pyqtSlot, Qt
 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
@@ -17,6 +16,7 @@
 
 from .Ui_VirtualenvAddEditDialog import Ui_VirtualenvAddEditDialog
 
+import Globals
 import Utilities
 
 
@@ -77,7 +77,7 @@
         self.pythonExecPicker.setWindowTitle(
             self.tr("Python Interpreter"))
         self.pythonExecPicker.setDefaultDirectory(
-            sys.executable.replace("w.exe", ".exe"))
+            Globals.getPythonExecutable())
         
         self.execPathEdit.setToolTip(self.tr(
             "Enter the executable search path to be prepended to the PATH"
@@ -192,7 +192,7 @@
             self.pythonExecPicker.setDefaultDirectory(txt)
         else:
             self.pythonExecPicker.setDefaultDirectory(
-                sys.executable.replace("w.exe", ".exe"))
+                Globals.getPythonExecutable())
         py = self.__detectPythonInterpreter(txt)
         if py:
             self.pythonExecPicker.setText(py)
--- a/eric7/VirtualEnv/VirtualenvConfigurationDialog.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/VirtualEnv/VirtualenvConfigurationDialog.py	Mon Apr 04 17:43:43 2022 +0200
@@ -9,7 +9,6 @@
 """
 
 import os
-import sys
 import re
 
 from PyQt6.QtCore import pyqtSlot, QProcess, QTimer
@@ -20,6 +19,7 @@
 
 from .Ui_VirtualenvConfigurationDialog import Ui_VirtualenvConfigurationDialog
 
+import Globals
 import Preferences
 import Utilities
 
@@ -62,7 +62,7 @@
         self.pythonExecPicker.setWindowTitle(
             self.tr("Python Interpreter"))
         self.pythonExecPicker.setDefaultDirectory(
-            sys.executable.replace("w.exe", ".exe"))
+            Globals.getPythonExecutable())
         
         self.condaTargetDirectoryPicker.setMode(
             EricPathPickerModes.DIRECTORY_MODE)
@@ -332,8 +332,7 @@
             calls.append((self.pythonExecPicker.text(),
                           ["-m", "virtualenv", "--version"]))
         calls.extend([
-            (sys.executable.replace("w.exe", ".exe"),
-             ["-m", "virtualenv", "--version"]),
+            (Globals.getPythonExecutable(), ["-m", "virtualenv", "--version"]),
             ("virtualenv", ["--version"]),
         ])
         
@@ -385,8 +384,7 @@
             calls.append((self.pythonExecPicker.text(),
                           ["-m", "venv"]))
         calls.extend([
-            (sys.executable.replace("w.exe", ".exe"),
-             ["-m", "venv"]),
+            (Globals.getPythonExecutable(), ["-m", "venv"]),
             ("python3", ["-m", "venv"]),
             ("python", ["-m", "venv"]),
         ])
--- a/eric7/VirtualEnv/VirtualenvExecDialog.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/VirtualEnv/VirtualenvExecDialog.py	Mon Apr 04 17:43:43 2022 +0200
@@ -7,7 +7,6 @@
 Module implementing the virtualenv execution dialog.
 """
 
-import sys
 import os
 
 from PyQt6.QtCore import QProcess, QTimer, QUrl
@@ -17,7 +16,7 @@
 from .Ui_VirtualenvExecDialog import Ui_VirtualenvExecDialog
 
 import Preferences
-from Globals import isWindowsPlatform
+from Globals import isWindowsPlatform, getPythonExecutable
 
 
 class VirtualenvExecDialog(QDialog, Ui_VirtualenvExecDialog):
@@ -64,15 +63,13 @@
                 self.__calls.append((configuration["pythonExe"],
                                      ["-m", "venv"]))
             self.__calls.extend([
-                (sys.executable.replace("w.exe", ".exe"),
-                 ["-m", "venv"]),
+                (getPythonExecutable(), ["-m", "venv"]),
                 ("python3", ["-m", "venv"]),
                 ("python", ["-m", "venv"]),
             ])
         else:
             self.__calls = [
-                (sys.executable.replace("w.exe", ".exe"),
-                 ["-m", "virtualenv"]),
+                (getPythonExecutable(), ["-m", "virtualenv"]),
                 ("virtualenv", []),
             ]
         self.__callIndex = 0
--- a/eric7/VirtualEnv/VirtualenvManager.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/VirtualEnv/VirtualenvManager.py	Mon Apr 04 17:43:43 2022 +0200
@@ -19,6 +19,7 @@
 from EricWidgets import EricMessageBox
 from EricWidgets.EricApplication import ericApp
 
+import Globals
 import Preferences
 
 
@@ -101,7 +102,7 @@
             del environments[venvName]
         
         # check, if the interpreter used to run eric is in the environments
-        defaultPy = sys.executable.replace("w.exe", ".exe")
+        defaultPy = Globals.getPythonExecutable()
         found = False
         for venvName in self.__virtualEnvironments:
             if (defaultPy ==
@@ -513,7 +514,10 @@
         @rtype str
         """
         if venvName in self.__virtualEnvironments:
-            return self.__virtualEnvironments[venvName]["interpreter"]
+            return (
+                self.__virtualEnvironments[venvName]["interpreter"]
+                .replace("w.exe", ".exe")
+            )
         else:
             return ""
     
--- a/eric7/WebBrowser/WebBrowserWindow.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/eric7/WebBrowser/WebBrowserWindow.py	Mon Apr 04 17:43:43 2022 +0200
@@ -9,7 +9,6 @@
 
 import os
 import shutil
-import sys
 import functools
 import contextlib
 
@@ -2474,7 +2473,7 @@
         
         if (
             not os.path.isfile(applPath) or
-            not QProcess.startDetached(sys.executable, args)
+            not QProcess.startDetached(Globals.getPythonExecutable(), args)
         ):
             EricMessageBox.critical(
                 self,
--- a/scripts/install-dependencies.py	Sun Apr 03 17:23:31 2022 +0200
+++ b/scripts/install-dependencies.py	Mon Apr 04 17:43:43 2022 +0200
@@ -56,6 +56,7 @@
         "parso",
         "jedi",
         "packaging",
+        "pipdeptree",
     )
     
     failedPackages = []

eric ide

mercurial