scripts/install.py

branch
maintenance
changeset 7922
92297aa58a1d
parent 7850
e64b178499da
child 7924
8a96736d465e
--- a/scripts/install.py	Mon Dec 28 19:43:35 2020 +0100
+++ b/scripts/install.py	Wed Dec 30 10:53:07 2020 +0100
@@ -56,6 +56,7 @@
 macAppBundlePath = defaultMacAppBundlePath
 macPythonExe = defaultMacPythonExe
 
+createInstallInfoFile = True
 installInfoName = "eric6install.json"
 installInfo = {}
 installCwd = ""
@@ -121,15 +122,16 @@
     print("Usage:")
     if sys.platform == "darwin":
         print("    {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
-              " [-m name] [-n path] [-p python] [--no-apis] [--yes]"
+              " [-m name] [-n path] [-p python] [--no-apis] [--no-info]"
+              " [--yes]"
               .format(progName))
     elif sys.platform.startswith(("win", "cygwin")):
         print("    {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]"
-              " [--clean-desktop] [--no-apis] [--no-tools] [--yes]"
+              " [--clean-desktop] [--no-apis] [--no-info] [--no-tools] [--yes]"
               .format(progName))
     else:
         print("    {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
-              " [--no-apis] [--no-tools] [--yes]"
+              " [--no-apis] [--no-info] [--no-tools] [--yes]"
               .format(progName))
     print("where:")
     print("    -h, --help display this help message")
@@ -159,6 +161,7 @@
     print("    -c         don't cleanup old installation first")
     if sys.platform.startswith(("win", "cygwin")):
         print("    --clean-desktop delete desktop links before installation")
+    print("    --no-info  don't create the install info file")
     if sys.platform != "darwin":
         print("    --no-tools don't ask for installation of pyqt5-tools"
               "/qt5-applications")
@@ -1313,31 +1316,32 @@
     """
     Record information about the way eric6 was installed.
     """
-    global installInfo, installCwd, cfg
+    global createInstallInfoFile, installInfo, installCwd, cfg
     
-    installDateTime = datetime.datetime.now(tz=None)
-    try:
-        installInfo["sudo"] = os.getuid() == 0
-    except AttributeError:
-        installInfo["sudo"] = False
-    installInfo["user"] = getpass.getuser()
-    installInfo["exe"] = sys.executable
-    installInfo["argv"] = " ".join(shlex.quote(a) for a in sys.argv[:])
-    installInfo["install_cwd"] = installCwd
-    installInfo["eric"] = cfg["ericDir"]
-    installInfo["virtualenv"] = installInfo["eric"].startswith(
-        os.path.expanduser("~"))
-    installInfo["installed"] = True
-    installInfo["installed_on"] = installDateTime.strftime(
-        "%Y-%m-%d %H:%M:%S")
-    installInfo["guessed"] = False
-    installInfo["edited"] = False
-    installInfo["pip"] = False
-    installInfo["remarks"] = ""
-    installInfo["install_cwd_edited"] = False
-    installInfo["exe_edited"] = False
-    installInfo["argv_edited"] = False
-    installInfo["eric_edited"] = False
+    if createInstallInfoFile:
+        installDateTime = datetime.datetime.now(tz=None)
+        try:
+            installInfo["sudo"] = os.getuid() == 0
+        except AttributeError:
+            installInfo["sudo"] = False
+        installInfo["user"] = getpass.getuser()
+        installInfo["exe"] = sys.executable
+        installInfo["argv"] = " ".join(shlex.quote(a) for a in sys.argv[:])
+        installInfo["install_cwd"] = installCwd
+        installInfo["eric"] = cfg["ericDir"]
+        installInfo["virtualenv"] = installInfo["eric"].startswith(
+            os.path.expanduser("~"))
+        installInfo["installed"] = True
+        installInfo["installed_on"] = installDateTime.strftime(
+            "%Y-%m-%d %H:%M:%S")
+        installInfo["guessed"] = False
+        installInfo["edited"] = False
+        installInfo["pip"] = False
+        installInfo["remarks"] = ""
+        installInfo["install_cwd_edited"] = False
+        installInfo["exe_edited"] = False
+        installInfo["argv_edited"] = False
+        installInfo["eric_edited"] = False
 
 
 def pipInstall(packageName, message):
@@ -1871,7 +1875,8 @@
     global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
     global sourceDir, eric6SourceDir, configName
     global macAppBundlePath, macAppBundleName, macPythonExe
-    global installApis, doCleanDesktopLinks, yes2All, installCwd
+    global installApis, doCleanDesktopLinks, yes2All
+    global createInstallInfoFile, installCwd
     global ignorePyqt5Tools
     
     if sys.version_info < (3, 5, 0) or sys.version_info > (3, 99, 99):
@@ -1891,15 +1896,15 @@
         if sys.platform.startswith(("win", "cygwin")):
             optlist, args = getopt.getopt(
                 argv[1:], "chxza:b:d:f:",
-                ["help", "no-apis", "no-tools", "yes"])
+                ["help", "no-apis", "no-info", "no-tools", "yes"])
         elif sys.platform == "darwin":
             optlist, args = getopt.getopt(
                 argv[1:], "chxza:b:d:f:i:m:n:p:",
-                ["help", "no-apis", "yes"])
+                ["help", "no-apis", "no-info", "yes"])
         else:
             optlist, args = getopt.getopt(
                 argv[1:], "chxza:b:d:f:i:",
-                ["help", "no-apis", "no-tools", "yes"])
+                ["help", "no-apis", "no-info", "no-tools", "yes"])
     except getopt.GetoptError as err:
         print(err)
         usage()
@@ -1949,6 +1954,8 @@
             yes2All = True
         elif opt == "--no-tools":
             ignorePyqt5Tools = True
+        elif opt == "--no-info":
+            createInstallInfoFile = False
     
     infoName = ""
     installFromSource = not os.path.isdir(sourceDir)
@@ -2040,9 +2047,10 @@
     print("\nInstalling eric6 ...")
     res = installEric()
     
-    with open(os.path.join(cfg["ericDir"],
-                           installInfoName), "w") as installInfoFile:
-        json.dump(installInfo, installInfoFile, indent=2)
+    if createInstallInfoFile:
+        with open(os.path.join(cfg["ericDir"],
+                               installInfoName), "w") as installInfoFile:
+            json.dump(installInfo, installInfoFile, indent=2)
     
     # do some cleanup
     try:

eric ide

mercurial