install.py

Wed, 13 Nov 2019 18:57:47 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 13 Nov 2019 18:57:47 +0100
changeset 7333
8479201bdf7b
parent 7332
49076c600903
child 7334
be378821131e

install.py
- added the "--yes" flag to allow installation of all missing prerequisites with pip without asking

docs/changelog file | annotate | diff | comparison | revisions
scripts/install.py file | annotate | diff | comparison | revisions
--- a/docs/changelog	Wed Nov 06 22:30:54 2019 +0100
+++ b/docs/changelog	Wed Nov 13 18:57:47 2019 +0100
@@ -6,6 +6,9 @@
   -- added a menu entry to show the local and device time side-by-side
   -- added a PyBoard menu entry to flash a new firmware
   -- added a menu entry to open the firmware download page of a device
+- install script
+  -- added the "--yes" flag to allow installation of all missing prerequisites
+     with pip without asking
 
 Version 19.11:
 - bug fixes
--- a/scripts/install.py	Wed Nov 06 22:30:54 2019 +0100
+++ b/scripts/install.py	Wed Nov 13 18:57:47 2019 +0100
@@ -37,6 +37,7 @@
 doCleanDesktopLinks = False
 forceCleanDesktopLinks = False
 doCompile = True
+yes2All = False
 cfg = {}
 progLanguages = ["Python", "Ruby", "QSS"]
 sourceDir = "eric"
@@ -110,16 +111,16 @@
     print()
     print("Usage:")
     if sys.platform == "darwin":
-        print("    {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
-              " [-m name] [-n path] [-p python] [--no-apis]"
+        print("    {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
+              " [-m name] [-n path] [-p python] [--no-apis] [--yes]"
               .format(progName))
     elif sys.platform.startswith(("win", "cygwin")):
-        print("    {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file]"
-              " [--clean-desktop] [--no-apis]"
+        print("    {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]"
+              " [--clean-desktop] [--no-apis] [--yes]"
               .format(progName))
     else:
-        print("    {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
-              " [--no-apis]"
+        print("    {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
+              " [--no-apis] [--yes]"
               .format(progName))
     print("where:")
     print("    -h, --help display this help message")
@@ -152,6 +153,7 @@
     print("    -x         don't perform dependency checks (use on your own"
           " risk)")
     print("    -z         don't compile the installed python files")
+    print("    --yes      answer 'yes' to all questions")
     print()
     print("The file given to the -f option must be valid Python code"
           " defining a")
@@ -1288,10 +1290,15 @@
     @return flag indicating a successful installation
     @rtype bool
     """
+    global yes2All
+    
     ok = False
-    print("{0}\n\nShall '{1}' be installed using pip? (Y/n)"
-          .format(message, packageName), end=" ")
-    answer = input()
+    if yes2All:
+        answer = "y"
+    else:
+        print("{0}\n\nShall '{1}' be installed using pip? (Y/n)"
+              .format(message, packageName), end=" ")
+        answer = input()
     if answer in ("", "Y", "y"):
         exitCode = subprocess.call(
             [sys.executable, "-m", "pip", "install", packageName])
@@ -1723,7 +1730,7 @@
     global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
     global sourceDir, eric6SourceDir, configName
     global macAppBundlePath, macAppBundleName, macPythonExe
-    global installApis, doCleanDesktopLinks
+    global installApis, doCleanDesktopLinks, yes2All
     
     if sys.version_info < (3, 5, 0) or sys.version_info > (3, 99, 99):
         print('Sorry, eric6 requires at least Python 3.5 for running.')
@@ -1740,15 +1747,15 @@
         if sys.platform.startswith(("win", "cygwin")):
             optlist, args = getopt.getopt(
                 argv[1:], "chxza:b:d:f:",
-                ["help", "no-apis"])
+                ["help", "no-apis", "yes"])
         elif sys.platform == "darwin":
             optlist, args = getopt.getopt(
                 argv[1:], "chxza:b:d:f:i:m:n:p:",
-                ["help", "no-apis"])
+                ["help", "no-apis", "yes"])
         else:
             optlist, args = getopt.getopt(
                 argv[1:], "chxza:b:d:f:i:",
-                ["help", "no-apis"])
+                ["help", "no-apis", "yes"])
     except getopt.GetoptError as err:
         print(err)
         usage()
@@ -1793,6 +1800,8 @@
             installApis = False
         elif opt == "--clean-desktop":
             doCleanDesktopLinks = True
+        elif opt == "--yes":
+            yes2All = True
     
     infoName = ""
     installFromSource = not os.path.isdir(sourceDir)

eric ide

mercurial