scripts/install-debugclients.py

Wed, 29 May 2019 22:14:02 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Wed, 29 May 2019 22:14:02 +0200
branch
Variables Viewer
changeset 7030
73779c4c135a
parent 6959
dfb8a57de154
child 7192
a22eee00b052
permissions
-rw-r--r--

Bugfix displaying to many characters as default_factory type.

5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 #!/usr/bin/env python3
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6365
diff changeset
4 # Copyright (c) 2016 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5 #
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 # This is the install script for the eric6 debug client. It may be used
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 # to just install the debug clients for remote debugging.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 #
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 Installation script for the eric6 debug clients.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from __future__ import unicode_literals, print_function
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import cStringIO as io
6364
6a496f0886ad Prepared the "import sip" statements for PyQt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6304
diff changeset
17 try:
6365
85f8745427a6 Redid the "import sip" statements for PyQt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6364
diff changeset
18 from PyQt5 import sip
6364
6a496f0886ad Prepared the "import sip" statements for PyQt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6304
diff changeset
19 except ImportError:
6365
85f8745427a6 Redid the "import sip" statements for PyQt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6364
diff changeset
20 import sip
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 sip.setapi('QString', 2)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 sip.setapi('QVariant', 2)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 sip.setapi('QTextStream', 2)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 except (ImportError):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 import io # __IGNORE_WARNING__
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 import sys
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 import os
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 import re
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 import compileall
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 import shutil
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 import fnmatch
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 # Define the globals.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 progName = None
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 currDir = os.getcwd()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 modDir = None
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 pyModDir = None
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 distDir = None
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 installPackage = "eric6DebugClients"
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 doCleanup = True
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 doCompile = True
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 sourceDir = "eric"
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
44 eric6SourceDir = os.path.join(sourceDir, "eric6")
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def exit(rcode=0):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Exit the install script.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 @param rcode result code to report back (integer)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 global currDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 if sys.platform.startswith("win"):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 # different meaning of input between Py2 and Py3
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 input("Press enter to continue...")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 except (EOFError, SyntaxError):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 pass
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 os.chdir(currDir)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 sys.exit(rcode)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 def usage(rcode=2):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 Display a usage message and exit.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 @param rcode the return code passed back to the calling process.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 global progName, modDir, distDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 print()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 print("Usage:")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 if sys.platform == "darwin":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 print(" {0} [-chz] [-d dir] [-i dir]".format(progName))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 elif sys.platform.startswith("win"):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 print(" {0} [-chz] [-d dir]".format(progName))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 print(" {0} [-chz][-d dir] [-i dir]".format(progName))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 print("where:")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 print(" -h, --help display this help message")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 print(" -d dir where eric6 debug client files will be installed")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 print(" (default: {0})".format(modDir))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 if not sys.platform.startswith("win"):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 print(" -i dir temporary install prefix")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 print(" (default: {0})".format(distDir))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 print(" -c don't cleanup old installation first")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 print(" -z don't compile the installed python files")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 exit(rcode)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 def initGlobals():
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 Module function to set the values of globals that need more than a
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 simple assignment.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 global modDir, pyModDir
6304
68f9aa03bf75 install: show a message to the user if the distutile package cannot be imported.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
102
68f9aa03bf75 install: show a message to the user if the distutile package cannot be imported.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
103 try:
68f9aa03bf75 install: show a message to the user if the distutile package cannot be imported.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
104 import distutils.sysconfig
68f9aa03bf75 install: show a message to the user if the distutile package cannot be imported.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
105 except ImportError:
68f9aa03bf75 install: show a message to the user if the distutile package cannot be imported.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
106 print("Please install the 'distutils' package first.")
68f9aa03bf75 install: show a message to the user if the distutile package cannot be imported.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
107 exit(5)
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 modDir = distutils.sysconfig.get_python_lib(True)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 pyModDir = modDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
5651
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
113 def copyTree(src, dst, filters, excludeDirs=None, excludePatterns=None):
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 Copy files of a directory tree.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 @param src name of the source directory
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 @param dst name of the destination directory
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 @param filters list of filter pattern determining the files to be copied
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 @param excludeDirs list of (sub)directories to exclude from copying
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 @keyparam excludePatterns list of filter pattern determining the files to
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 be skipped
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 """
5651
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
124 if excludeDirs is None:
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
125 excludeDirs = []
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
126 if excludePatterns is None:
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
127 excludePatterns = []
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 names = os.listdir(src)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 except OSError:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 # ignore missing directories
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 return
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 for name in names:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 skipIt = False
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 for excludePattern in excludePatterns:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 if fnmatch.fnmatch(name, excludePattern):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 skipIt = True
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 break
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 if not skipIt:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 srcname = os.path.join(src, name)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 dstname = os.path.join(dst, name)
5597
3d88d53f8c2b Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
143 for fileFilter in filters:
3d88d53f8c2b Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
144 if fnmatch.fnmatch(srcname, fileFilter):
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 if not os.path.isdir(dst):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 os.makedirs(dst)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 shutil.copy2(srcname, dstname)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 os.chmod(dstname, 0o644)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 break
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 if os.path.isdir(srcname) and srcname not in excludeDirs:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 copyTree(srcname, dstname, filters,
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 excludePatterns=excludePatterns)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 def cleanupSource(dirName):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 Cleanup the sources directory to get rid of leftover files
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 and directories.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 @param dirName name of the directory to prune (string)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 # step 1: delete the __pycache__ directory and all *.pyc files
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 if os.path.exists(os.path.join(dirName, "__pycache__")):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 shutil.rmtree(os.path.join(dirName, "__pycache__"))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 for name in [f for f in os.listdir(dirName)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 if fnmatch.fnmatch(f, "*.pyc")]:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 os.remove(os.path.join(dirName, name))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 # step 2: descent into subdirectories and delete them if empty
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 for name in os.listdir(dirName):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 name = os.path.join(dirName, name)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 if os.path.isdir(name):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 cleanupSource(name)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 if len(os.listdir(name)) == 0:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 os.rmdir(name)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 def cleanUp():
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 Uninstall the old eric debug client files.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 global pyModDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 # Cleanup the install directories
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 dirname = os.path.join(pyModDir, installPackage)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 if os.path.exists(dirname):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 shutil.rmtree(dirname, True)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 except (IOError, OSError) as msg:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 sys.stderr.write(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 'Error: {0}\nTry install with admin rights.\n'.format(msg))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 exit(7)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 def shutilCopy(src, dst, perm=0o644):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 Wrapper function around shutil.copy() to ensure the permissions.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 @param src source file name (string)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 @param dst destination file name or directory name (string)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 @keyparam perm permissions to be set (integer)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 shutil.copy(src, dst)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 if os.path.isdir(dst):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 dst = os.path.join(dst, os.path.basename(src))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 os.chmod(dst, perm)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 def installEricDebugClients():
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 Actually perform the installation steps.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 @return result code (integer)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 global distDir, doCleanup, sourceDir, modDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 # set install prefix, if not None
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 if distDir:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 targetDir = os.path.normpath(os.path.join(distDir, installPackage))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 targetDir = os.path.join(modDir, installPackage)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 # Install the files
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 # copy the various parts of eric6 debug clients
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 copyTree(
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
228 os.path.join(eric6SourceDir, "DebugClients"), targetDir,
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 ['*.py', '*.pyc', '*.pyo', '*.pyw'],
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
230 [os.path.join(sourceDir, ".ropeproject")],
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 excludePatterns=["eric6config.py*"])
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 # copy the license file
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
234 shutilCopy(os.path.join(sourceDir, "docs", "LICENSE.GPL3"), targetDir)
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 except (IOError, OSError) as msg:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 sys.stderr.write(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 'Error: {0}\nTry install with admin rights.\n'.format(msg))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 return(7)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 return 0
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 def main(argv):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 The main function of the script.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 @param argv the list of command line arguments.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 import getopt
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 # Parse the command line.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 global progName, modDir, doCleanup, doCompile, distDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 global sourceDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 if sys.version_info < (2, 7, 0) or sys.version_info > (3, 9, 9):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 print('Sorry, eric6 requires at least Python 2.7 or '
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 'Python 3 for running.')
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 exit(5)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 progName = os.path.basename(argv[0])
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 if os.path.dirname(argv[0]):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 os.chdir(os.path.dirname(argv[0]))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 initGlobals()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 if sys.platform.startswith("win"):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 optlist, args = getopt.getopt(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 argv[1:], "chzd:", ["help"])
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 elif sys.platform == "darwin":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 optlist, args = getopt.getopt(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 argv[1:], "chzd:i:", ["help"])
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 optlist, args = getopt.getopt(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 argv[1:], "chzd:i:", ["help"])
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 except getopt.GetoptError as err:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 print(err)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 usage()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 for opt, arg in optlist:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 if opt in ["-h", "--help"]:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 usage(0)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 elif opt == "-d":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 modDir = arg
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 elif opt == "-i":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 distDir = os.path.normpath(arg)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 elif opt == "-c":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 doCleanup = False
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 elif opt == "-z":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 doCompile = False
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 installFromSource = not os.path.isdir(sourceDir)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 if installFromSource:
6959
dfb8a57de154 install-debugclients: fixed an issue causing cleanup to fail.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
296 sourceDir = os.path.abspath("..")
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
297 eric6SourceDir = os.path.join(sourceDir, "eric6")
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 # cleanup source if installing from source
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 if installFromSource:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 print("Cleaning up source ...")
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
302 cleanupSource(os.path.join(eric6SourceDir, "DebugClients"))
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 print()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 # cleanup old installation
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 if doCleanup:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 print("Cleaning up old installation ...")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 if distDir:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 shutil.rmtree(distDir, True)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 cleanUp()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 except (IOError, OSError) as msg:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 sys.stderr.write('Error: {0}\nTry install as root.\n'.format(msg))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 exit(7)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 if doCompile:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 print("\nCompiling source files ...")
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5145
diff changeset
319 skipRe = re.compile(r"DebugClients[\\/]Python[\\/]")
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 # Hide compile errors (mainly because of Py2/Py3 differences)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 sys.stdout = io.StringIO()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 if distDir:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 compileall.compile_dir(
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
324 os.path.join(eric6SourceDir, "DebugClients"),
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 ddir=os.path.join(distDir, modDir, installPackage),
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 rx=skipRe,
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 quiet=True)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 compileall.compile_dir(
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
330 os.path.join(eric6SourceDir, "DebugClients"),
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 ddir=os.path.join(modDir, installPackage),
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 rx=skipRe,
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 quiet=True)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 sys.stdout = sys.__stdout__
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 print("\nInstalling eric6 debug clients ...")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 res = installEricDebugClients()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 print("\nInstallation complete.")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 print()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 exit(res)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 if __name__ == "__main__":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 main(sys.argv)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 except SystemExit:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 raise
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 except Exception:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 print("""An internal error occured. Please report all the output"""
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 """ of the program,\nincluding the following traceback, to"""
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 """ eric-bugs@eric-ide.python-projects.org.\n""")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 raise
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 #
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 # eflag: noqa = M801

eric ide

mercurial