Fixed the install script logic with respect to installation of pywin32 because that package does some magic when python.exe is started. eric7

Wed, 16 Oct 2024 17:38:35 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 16 Oct 2024 17:38:35 +0200
branch
eric7
changeset 10983
8b9913066b8c
parent 10979
960fe726594c
child 10984
21c0a3d40d69

Fixed the install script logic with respect to installation of pywin32 because that package does some magic when python.exe is started.

scripts/create_windows_links.py file | annotate | diff | comparison | revisions
scripts/install.py file | annotate | diff | comparison | revisions
--- a/scripts/create_windows_links.py	Tue Oct 15 16:29:36 2024 +0200
+++ b/scripts/create_windows_links.py	Wed Oct 16 17:38:35 2024 +0200
@@ -19,7 +19,10 @@
     print("This script is to be used on Windows platforms only. Aborting...")
     sys.exit(1)
 
-from eric7.Globals import getConfig
+try:
+    from eric7.eric7config import getConfig
+except ImportError:
+    from eric7config import getConfig
 
 
 def main():
--- a/scripts/install.py	Tue Oct 15 16:29:36 2024 +0200
+++ b/scripts/install.py	Wed Oct 16 17:38:35 2024 +0200
@@ -69,6 +69,9 @@
 installInfo = {}
 installCwd = ""
 
+# Windows specific stuff
+pywin32_installed = False
+
 # Define blocklisted versions of the prerequisites
 BlockLists = {
     "sip": [],
@@ -1119,25 +1122,14 @@
     """
     Create Desktop and Start Menu links.
     """
-    if importlib.util.find_spec("win32com") is None:
-        installed = pipInstall(
-            "pywin32",
-            "\nThe Python package 'pywin32' could not be imported.",
-            force=False,
-        )
-        if installed:
-            # create the links via an external script to get around some
-            # startup magic done by pywin32.pth
-            args = [
-                sys.executable,
-                os.path.join(os.path.dirname(__file__), "create_windows_links.py"),
-            ]
-            subprocess.run(args)  # secok
-        else:
-            print(
-                "\nThe Python package 'pywin32' is not installed. Desktop and"
-                " Start Menu entries will not be created."
-            )
+    if pywin32_installed:
+        # create the links via an external script to get around some
+        # startup magic done by pywin32.pth
+        args = [
+            sys.executable,
+            os.path.join(os.path.dirname(__file__), "create_windows_links.py"),
+        ]
+        subprocess.run(args)  # secok
         return
 
     regPath = (
@@ -1587,7 +1579,7 @@
     """
     Perform some dependency checks.
     """
-    global verbose
+    global pywin32_installed, verbose
 
     requiredVersions = {
         "pyqt6": 0x60200,  # v6.2.0
@@ -1808,7 +1800,9 @@
                 msg = "Optional '{0}' could not be detected.{1}".format(
                     optPackage, "\nError: {0}".format(err) if verbose else ""
                 )
-                pipInstall(optPackage + optModulesDict[optPackage][1], msg)
+                ok = pipInstall(optPackage + optModulesDict[optPackage][1], msg)
+                if optPackage == "pywin32" and ok:
+                    pywin32_installed = True
     if optionalMissing:
         print("Some optional packages are missing and could not be installed.")
         print("Install them manually with:")

eric ide

mercurial