eric6/VirtualEnv/VirtualenvManager.py

Sun, 01 Sep 2019 19:40:53 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 01 Sep 2019 19:40:53 +0200
branch
without_py2_and_pyqt4
changeset 7198
684261ef2165
parent 6975
3325bf3e7b2c
child 7229
53054eb5b15a
permissions
-rw-r--r--

Removed the Qt4 runtime stuff.

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

eric ide

mercurial