eric6/VirtualEnv/VirtualenvManager.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7960
e8fc383322f7
child 8043
0acf98cd089a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7910
diff changeset
3 # Copyright (c) 2018 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a class to manage Python virtual environments.
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import sys
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import shutil
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
13 import json
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
14 import copy
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
16 from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from PyQt5.QtWidgets import QDialog
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from E5Gui import E5MessageBox
6697
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
20 from E5Gui.E5Application import e5App
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Preferences
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 class VirtualenvManager(QObject):
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Class implementing an object to manage Python virtual environments.
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
28
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
29 @signal virtualEnvironmentAdded() emitted to indicate the addition of
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
30 a virtual environment
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
31 @signal virtualEnvironmentRemoved() emitted to indicate the removal and
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
32 deletion of a virtual environment
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
33 @signal virtualEnvironmentChanged(name) emitted to indicate a change of
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
34 a virtual environment
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
6503
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
36 DefaultKey = "<default>"
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
37
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
38 virtualEnvironmentAdded = pyqtSignal()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
39 virtualEnvironmentRemoved = pyqtSignal()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
40 virtualEnvironmentChanged = pyqtSignal(str)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
41
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 def __init__(self, parent=None):
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 Constructor
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 @param parent reference to the parent object
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @type QWidget
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 super(VirtualenvManager, self).__init__(parent)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.__ui = parent
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
53 self.__loadSettings()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
54
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
55 self.__virtualenvManagerDialog = None
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
57 def __loadSettings(self):
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
58 """
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
59 Private slot to load the virtual environments.
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
60 """
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
61 self.__virtualEnvironmentsBaseDir = Preferences.Prefs.settings.value(
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
62 "PyVenv/VirtualEnvironmentsBaseDir", "")
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
63
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
64 venvString = Preferences.Prefs.settings.value(
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
65 "PyVenv/VirtualEnvironments", "{}") # __IGNORE_WARNING_M613__
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
66 environments = json.loads(venvString)
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
67
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
68 self.__virtualEnvironments = {}
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
69 # each environment entry is a dictionary:
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
70 # path: the directory of the virtual environment
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
71 # (empty for a global environment)
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
72 # interpreter: the path of the Python interpreter
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
73 # variant: Python variant (always 3)
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
74 # is_global: a flag indicating a global environment
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
75 # is_conda: a flag indicating an Anaconda environment
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
76 # is_remote: a flag indicating a remotely accessed environment
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
77 # exec_path: a string to be prefixed to the PATH environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
78 # setting
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
79 #
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
80 envsToDelete = []
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
81 for venvName in environments:
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
82 environment = environments[venvName]
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
83 if environment["variant"] == 2:
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
84 # Python2 environment are not supported anymore, delete them
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
85 envsToDelete.append(venvName)
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
86 continue
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
87
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
88 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
89 ("is_remote" in environment and environment["is_remote"]) or
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
90 os.access(environment["interpreter"], os.X_OK)
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
91 ):
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
92 if "is_global" not in environment:
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
93 environment["is_global"] = environment["path"] == ""
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
94 if "is_conda" not in environment:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
95 environment["is_conda"] = False
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
96 if "is_remote" not in environment:
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
97 environment["is_remote"] = False
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
98 if "exec_path" not in environment:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
99 environment["exec_path"] = ""
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
100 self.__virtualEnvironments[venvName] = environment
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
101
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
102 # now remove unsupported environments
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
103 for venvName in envsToDelete:
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
104 del environments[venvName]
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
105
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
106 # check, if the interpreter used to run eric is in the environments
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
107 defaultPy = sys.executable.replace("w.exe", ".exe")
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
108 found = False
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
109 for venvName in self.__virtualEnvironments:
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
110 if (defaultPy ==
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
111 self.__virtualEnvironments[venvName]["interpreter"]):
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
112 found = True
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
113 break
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
114 if not found:
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
115 # add an environment entry for the default interpreter
6503
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
116 self.__virtualEnvironments[VirtualenvManager.DefaultKey] = {
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
117 "path": "",
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
118 "interpreter": defaultPy,
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
119 "variant": 3,
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
120 "is_global": True,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
121 "is_conda": False,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
122 "is_remote": False,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
123 "exec_path": "",
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
124 }
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
125
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
126 self.__saveSettings()
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
127
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
128 def __saveSettings(self):
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 Private slot to save the virtual environments.
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 Preferences.Prefs.settings.setValue(
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
133 "PyVenv/VirtualEnvironmentsBaseDir",
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
134 self.__virtualEnvironmentsBaseDir)
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
135
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
136 Preferences.Prefs.settings.setValue(
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
137 "PyVenv/VirtualEnvironments",
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
138 json.dumps(self.__virtualEnvironments)
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
139 )
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
140 Preferences.syncPreferences()
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
6503
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
142 def getDefaultEnvironment(self):
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
143 """
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
144 Public method to get the default virtual environment.
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
145
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
146 Default is an environment with the key '<default>' or the first one
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
147 having an interpreter matching sys.executable (i.e. the one used to
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
148 execute eric with)
6503
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
149
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
150 @return tuple containing the environment name and a dictionary
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
151 containing a copy of the default virtual environment
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
152 @rtype tuple of (str, dict)
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
153 """
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
154 if VirtualenvManager.DefaultKey in self.__virtualEnvironments:
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
155 return (
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
156 VirtualenvManager.DefaultKey,
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
157 copy.copy(
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
158 self.__virtualEnvironments[VirtualenvManager.DefaultKey])
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
159 )
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
160
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
161 else:
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
162 defaultPy = sys.executable.replace("w.exe", ".exe")
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
163 for venvName in self.__virtualEnvironments:
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
164 if (defaultPy ==
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
165 self.__virtualEnvironments[venvName]["interpreter"]):
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
166 return (
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
167 venvName,
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
168 copy.copy(self.__virtualEnvironments[venvName])
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
169 )
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
170
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
171 return ("", {})
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
172
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 @pyqtSlot()
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
174 def createVirtualEnv(self, baseDir=""):
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 Public slot to create a new virtual environment.
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
177
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
178 @param baseDir base directory for the virtual environments
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
179 @type str
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 """
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
181 from .VirtualenvConfigurationDialog import (
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 VirtualenvConfigurationDialog
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
183 )
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
185 if not baseDir:
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
186 baseDir = self.__virtualEnvironmentsBaseDir
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
187
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
188 dlg = VirtualenvConfigurationDialog(baseDir=baseDir)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7726
diff changeset
189 if dlg.exec() == QDialog.Accepted:
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
190 resultDict = dlg.getData()
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
192 if resultDict["envType"] == "conda":
6697
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
193 # create the conda environment
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
194 conda = e5App().getObject("Conda")
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
195 ok, prefix, interpreter = conda.createCondaEnvironment(
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
196 resultDict["arguments"])
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
197 if ok and "--dry-run" not in resultDict["arguments"]:
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
198 self.addVirtualEnv(resultDict["logicalName"],
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
199 prefix,
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
200 venvInterpreter=interpreter,
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
201 isConda=True)
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
202 else:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
203 # now do the call
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
204 from .VirtualenvExecDialog import VirtualenvExecDialog
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
205 dia = VirtualenvExecDialog(resultDict, self)
6697
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
206 dia.show()
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
207 dia.start(resultDict["arguments"])
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7726
diff changeset
208 dia.exec()
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
210 def addVirtualEnv(self, venvName, venvDirectory, venvInterpreter="",
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
211 isGlobal=False, isConda=False, isRemote=False,
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
212 execPath=""):
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 Public method to add a virtual environment.
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 @param venvName logical name for the virtual environment
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 @type str
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
218 @param venvDirectory directory of the virtual environment
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 @type str
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
220 @param venvInterpreter interpreter of the virtual environment
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
221 @type str
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
222 @param isGlobal flag indicating a global environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
223 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
224 @param isConda flag indicating an Anaconda virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
225 @type bool
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
226 @param isRemote flag indicating a remotely accessed environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
227 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
228 @param execPath search path string to be prepended to the PATH
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
229 environment variable
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
230 @type str
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 if venvName in self.__virtualEnvironments:
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 ok = E5MessageBox.yesNo(
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 None,
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 self.tr("Add Virtual Environment"),
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 self.tr("""A virtual environment named <b>{0}</b> exists"""
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 """ already. Shall it be replaced?""")
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 .format(venvName),
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 icon=E5MessageBox.Warning)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 if not ok:
6677
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
241 from .VirtualenvNameDialog import VirtualenvNameDialog
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
242 dlg = VirtualenvNameDialog(
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
243 list(self.__virtualEnvironments.keys()),
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
244 venvName)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7726
diff changeset
245 if dlg.exec() != QDialog.Accepted:
6677
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
246 return
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
247
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
248 venvName = dlg.getName()
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
250 if not venvInterpreter:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
251 from .VirtualenvInterpreterSelectionDialog import (
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
252 VirtualenvInterpreterSelectionDialog
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
253 )
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
254 dlg = VirtualenvInterpreterSelectionDialog(venvName, venvDirectory)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7726
diff changeset
255 if dlg.exec() == QDialog.Accepted:
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
256 venvInterpreter = dlg.getData()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
257
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
258 if venvInterpreter:
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
259 self.__virtualEnvironments[venvName] = {
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
260 "path": venvDirectory,
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
261 "interpreter": venvInterpreter,
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
262 "variant": 3, # always 3
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
263 "is_global": isGlobal,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
264 "is_conda": isConda,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
265 "is_remote": isRemote,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
266 "exec_path": execPath,
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
267 }
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
269 self.__saveSettings()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
270
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
271 self.virtualEnvironmentAdded.emit()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
272 if self.__virtualenvManagerDialog:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
273 self.__virtualenvManagerDialog.refresh()
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
275 def setVirtualEnv(self, venvName, venvDirectory, venvInterpreter,
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
276 isGlobal, isConda, isRemote, execPath):
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
277 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
278 Public method to change a virtual environment.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
279
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
280 @param venvName logical name of the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
281 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
282 @param venvDirectory directory of the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
283 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
284 @param venvInterpreter interpreter of the virtual environment
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
285 @type str
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
286 @param isGlobal flag indicating a global environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
287 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
288 @param isConda flag indicating an Anaconda virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
289 @type bool
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
290 @param isRemote flag indicating a remotely accessed environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
291 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
292 @param execPath search path string to be prepended to the PATH
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
293 environment variable
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
294 @type str
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
295 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
296 if venvName not in self.__virtualEnvironments:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
297 E5MessageBox.yesNo(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
298 None,
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
299 self.tr("Change Virtual Environment"),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
300 self.tr("""A virtual environment named <b>{0}</b> does not"""
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
301 """ exist. Aborting!""")
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
302 .format(venvName),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
303 icon=E5MessageBox.Warning)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
304 return
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
305
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
306 self.__virtualEnvironments[venvName] = {
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
307 "path": venvDirectory,
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
308 "interpreter": venvInterpreter,
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
309 "variant": 3, # always 3
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
310 "is_global": isGlobal,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
311 "is_conda": isConda,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
312 "is_remote": isRemote,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
313 "exec_path": execPath,
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
314 }
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
315
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
316 self.__saveSettings()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
317
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
318 self.virtualEnvironmentChanged.emit(venvName)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
319 if self.__virtualenvManagerDialog:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
320 self.__virtualenvManagerDialog.refresh()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
321
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
322 def renameVirtualEnv(self, oldVenvName, venvName, venvDirectory,
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
323 venvInterpreter, isGlobal, isConda,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
324 isRemote, execPath):
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
325 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
326 Public method to substitute a virtual environment entry with a new
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
327 name.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
328
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
329 @param oldVenvName old name of the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
330 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
331 @param venvName logical name for the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
332 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
333 @param venvDirectory directory of the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
334 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
335 @param venvInterpreter interpreter of the virtual environment
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
336 @type str
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
337 @param isGlobal flag indicating a global environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
338 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
339 @param isConda flag indicating an Anaconda virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
340 @type bool
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
341 @param isRemote flag indicating a remotely accessed environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
342 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
343 @param execPath search path string to be prepended to the PATH
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
344 environment variable
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
345 @type str
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
346 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
347 if oldVenvName not in self.__virtualEnvironments:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
348 E5MessageBox.yesNo(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
349 None,
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
350 self.tr("Rename Virtual Environment"),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
351 self.tr("""A virtual environment named <b>{0}</b> does not"""
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
352 """ exist. Aborting!""")
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
353 .format(oldVenvName),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
354 icon=E5MessageBox.Warning)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
355 return
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
356
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
357 del self.__virtualEnvironments[oldVenvName]
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
358 self.addVirtualEnv(venvName, venvDirectory, venvInterpreter,
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
359 isGlobal, isConda, isRemote, execPath)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
360
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
361 def deleteVirtualEnvs(self, venvNames):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
362 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
363 Public method to delete virtual environments from the list and disk.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
364
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
365 @param venvNames list of logical names for the virtual environments
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
366 @type list of str
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 """
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
368 venvMessages = []
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
369 for venvName in venvNames:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
370 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
371 venvName in self.__virtualEnvironments and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
372 bool(self.__virtualEnvironments[venvName]["path"])
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
373 ):
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
374 venvMessages.append(self.tr("{0} - {1}").format(
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
375 venvName, self.__virtualEnvironments[venvName]["path"]))
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
376 if venvMessages:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
377 from UI.DeleteFilesConfirmationDialog import (
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
378 DeleteFilesConfirmationDialog
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
379 )
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
380 dlg = DeleteFilesConfirmationDialog(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
381 None,
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
382 self.tr("Delete Virtual Environments"),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
383 self.tr("""Do you really want to delete these virtual"""
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
384 """ environments?"""),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
385 venvMessages
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
386 )
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7726
diff changeset
387 if dlg.exec() == QDialog.Accepted:
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
388 for venvName in venvNames:
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
389 if self.__isEnvironmentDeleteable(venvName):
6697
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
390 if self.isCondaEnvironment(venvName):
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
391 conda = e5App().getObject("Conda")
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
392 path = self.__virtualEnvironments[venvName]["path"]
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
393 res = conda.removeCondaEnvironment(prefix=path)
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
394 if res:
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
395 del self.__virtualEnvironments[venvName]
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
396 else:
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
397 shutil.rmtree(
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
398 self.__virtualEnvironments[venvName]["path"],
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
399 True)
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
400 del self.__virtualEnvironments[venvName]
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
401
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
402 self.__saveSettings()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
403
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
404 self.virtualEnvironmentRemoved.emit()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
405 if self.__virtualenvManagerDialog:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
406 self.__virtualenvManagerDialog.refresh()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
407
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
408 def __isEnvironmentDeleteable(self, venvName):
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
409 """
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
410 Private method to check, if a virtual environment can be deleted from
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
411 disk.
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
412
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
413 @param venvName name of the virtual environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
414 @type str
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
415 @return flag indicating it can be deleted
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
416 @rtype bool
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
417 """
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
418 ok = False
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
419 if venvName in self.__virtualEnvironments:
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
420 ok = True
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
421 ok &= bool(self.__virtualEnvironments[venvName]["path"])
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
422 ok &= not self.__virtualEnvironments[venvName]["is_global"]
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
423 ok &= not self.__virtualEnvironments[venvName]["is_remote"]
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
424 ok &= os.access(self.__virtualEnvironments[venvName]["path"],
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
425 os.W_OK)
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
426
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
427 return ok
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
428
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
429 def removeVirtualEnvs(self, venvNames):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
430 """
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
431 Public method to delete virtual environment from the list.
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
432
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
433 @param venvNames list of logical names for the virtual environments
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
434 @type list of str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
435 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
436 venvMessages = []
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
437 for venvName in venvNames:
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
438 if venvName in self.__virtualEnvironments:
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
439 venvMessages.append(self.tr("{0} - {1}").format(
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
440 venvName, self.__virtualEnvironments[venvName]["path"]))
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
441 if venvMessages:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
442 from UI.DeleteFilesConfirmationDialog import (
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
443 DeleteFilesConfirmationDialog
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
444 )
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
445 dlg = DeleteFilesConfirmationDialog(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
446 None,
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
447 self.tr("Remove Virtual Environments"),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
448 self.tr("""Do you really want to remove these virtual"""
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
449 """ environments?"""),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
450 venvMessages
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
451 )
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7726
diff changeset
452 if dlg.exec() == QDialog.Accepted:
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
453 for venvName in venvNames:
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
454 if venvName in self.__virtualEnvironments:
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
455 del self.__virtualEnvironments[venvName]
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
456
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
457 self.__saveSettings()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
458
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
459 self.virtualEnvironmentRemoved.emit()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
460 if self.__virtualenvManagerDialog:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
461 self.__virtualenvManagerDialog.refresh()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
462
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
463 def getEnvironmentEntries(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
464 """
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
465 Public method to get a dictionary containing the defined virtual
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
466 environment entries.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
467
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
468 @return dictionary containing a copy of the defined virtual
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
469 environments
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
470 @rtype dict
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
471 """
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
472 return copy.deepcopy(self.__virtualEnvironments)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
473
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
474 @pyqtSlot()
6381
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
475 def showVirtualenvManagerDialog(self, modal=False):
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
476 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
477 Public slot to show the virtual environment manager dialog.
6381
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
478
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
479 @param modal flag indicating that the dialog should be shown in
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
480 a blocking mode
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
481 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
482 if self.__virtualenvManagerDialog is None:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
483 from .VirtualenvManagerDialog import VirtualenvManagerDialog
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
484 self.__virtualenvManagerDialog = VirtualenvManagerDialog(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
485 self, self.__ui)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
486
6381
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
487 if modal:
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7726
diff changeset
488 self.__virtualenvManagerDialog.exec()
6381
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
489 else:
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
490 self.__virtualenvManagerDialog.show()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
491
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
492 def shutdown(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
493 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
494 Public method to shutdown the manager.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
495 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
496 if self.__virtualenvManagerDialog is not None:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
497 self.__virtualenvManagerDialog.close()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
498 self.__virtualenvManagerDialog = None
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
499
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
500 def isUnique(self, venvName):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
501 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
502 Public method to check, if the give logical name is unique.
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 @param venvName logical name for the virtual environment
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 @type str
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
506 @return flag indicating uniqueness
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
507 @rtype bool
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 """
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
509 return venvName not in self.__virtualEnvironments
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
510
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
511 def getVirtualenvInterpreter(self, venvName):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
512 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
513 Public method to get the interpreter for a virtual environment.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
514
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
515 @param venvName logical name for the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
516 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
517 @return interpreter path
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
518 @rtype str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
519 """
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
520 if venvName in self.__virtualEnvironments:
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
521 return self.__virtualEnvironments[venvName]["interpreter"]
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
522 else:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
523 return ""
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
524
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
525 def getVirtualenvDirectory(self, venvName):
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
526 """
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
527 Public method to get the directory of a virtual environment.
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
528
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
529 @param venvName logical name for the virtual environment
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
530 @type str
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
531 @return directory path
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
532 @rtype str
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
533 """
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
534 if venvName in self.__virtualEnvironments:
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
535 return self.__virtualEnvironments[venvName]["path"]
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
536 else:
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
537 return ""
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
538
7726
b1ade4fcf05f Pip Interface: added an option to not show 'conda' managed environments in the selector.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
539 def getVirtualenvNames(self, noRemote=False, noConda=False):
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
540 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
541 Public method to get a list of defined virtual environments.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
542
6975
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
543 @param noRemote flag indicating to exclude environments for remote
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
544 debugging
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
545 @type bool
7726
b1ade4fcf05f Pip Interface: added an option to not show 'conda' managed environments in the selector.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
546 @param noConda flag indicating to exclude Conda environments
b1ade4fcf05f Pip Interface: added an option to not show 'conda' managed environments in the selector.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
547 @type bool
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
548 @return list of defined virtual environments
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
549 @rtype list of str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
550 """
6975
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
551 environments = list(self.__virtualEnvironments.keys())
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
552 if noRemote:
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
553 environments = [name for name in environments
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
554 if not self.isRemoteEnvironment(name)]
7726
b1ade4fcf05f Pip Interface: added an option to not show 'conda' managed environments in the selector.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
555 if noConda:
b1ade4fcf05f Pip Interface: added an option to not show 'conda' managed environments in the selector.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
556 environments = [name for name in environments
b1ade4fcf05f Pip Interface: added an option to not show 'conda' managed environments in the selector.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
557 if not self.isCondaEnvironment(name)]
6975
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
558
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
559 return environments
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
560
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
561 def isGlobalEnvironment(self, venvName):
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
562 """
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
563 Public method to test, if a given environment is a global one.
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
564
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
565 @param venvName logical name of the virtual environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
566 @type str
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
567 @return flag indicating a global environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
568 @rtype bool
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
569 """
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
570 if venvName in self.__virtualEnvironments:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
571 return self.__virtualEnvironments[venvName]["is_global"]
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
572 else:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
573 return False
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
574
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
575 def isCondaEnvironment(self, venvName):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
576 """
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
577 Public method to test, if a given environment is an Anaconda
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
578 environment.
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
579
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
580 @param venvName logical name of the virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
581 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
582 @return flag indicating an Anaconda environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
583 @rtype bool
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
584 """
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
585 if venvName in self.__virtualEnvironments:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
586 return self.__virtualEnvironments[venvName]["is_conda"]
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
587 else:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
588 return False
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
589
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
590 def isRemoteEnvironment(self, venvName):
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
591 """
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
592 Public method to test, if a given environment is a remotely accessed
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
593 environment.
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
594
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
595 @param venvName logical name of the virtual environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
596 @type str
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
597 @return flag indicating a remotely accessed environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
598 @rtype bool
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
599 """
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
600 if venvName in self.__virtualEnvironments:
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
601 return self.__virtualEnvironments[venvName]["is_remote"]
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
602 else:
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
603 return False
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
604
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
605 def getVirtualenvExecPath(self, venvName):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
606 """
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
607 Public method to get the search path prefix of a virtual environment.
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
608
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
609 @param venvName logical name for the virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
610 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
611 @return search path prefix
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
612 @rtype str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
613 """
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
614 if venvName in self.__virtualEnvironments:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
615 return self.__virtualEnvironments[venvName]["exec_path"]
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
616 else:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
617 return ""
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
618
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
619 def setVirtualEnvironmentsBaseDir(self, baseDir):
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
620 """
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
621 Public method to set the base directory for the virtual environments.
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
622
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
623 @param baseDir base directory for the virtual environments
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
624 @type str
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
625 """
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
626 self.__virtualEnvironmentsBaseDir = baseDir
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
627 self.__saveSettings()
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
628
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
629 def getVirtualEnvironmentsBaseDir(self):
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
630 """
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
631 Public method to set the base directory for the virtual environments.
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
632
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
633 @return base directory for the virtual environments
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
634 @rtype str
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
635 """
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
636 return self.__virtualEnvironmentsBaseDir

eric ide

mercurial