src/eric7/VirtualEnv/VirtualenvConfigurationDialog.py

Fri, 04 Nov 2022 13:52:26 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 04 Nov 2022 13:52:26 +0100
branch
eric7
changeset 9473
3f23dbf37dbe
parent 9413
80c06d472826
child 9624
b47dfa7a137d
permissions
-rw-r--r--

Resorted the import statements using isort.

6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8862
diff changeset
3 # Copyright (c) 2014 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter the parameters for the
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 virtual environment.
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import os
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import re
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
14 from PyQt6.QtCore import QProcess, QTimer, pyqtSlot
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
15 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
17 from eric7 import CondaInterface, Globals, Preferences, Utilities
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
18 from eric7.EricWidgets.EricApplication import ericApp
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
19 from eric7.EricWidgets.EricPathPicker import EricPathPickerModes
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 from .Ui_VirtualenvConfigurationDialog import Ui_VirtualenvConfigurationDialog
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 class VirtualenvConfigurationDialog(QDialog, Ui_VirtualenvConfigurationDialog):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Class implementing a dialog to enter the parameters for the
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 virtual environment.
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
29
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
30 def __init__(self, baseDir="", parent=None):
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
33
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
34 @param baseDir base directory for the virtual environments
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
35 @type str
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
36 @param parent reference to the parent widget
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
37 @type QWidget
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
39 super().__init__(parent)
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.setupUi(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
41
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
42 if not baseDir:
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
43 baseDir = Utilities.getHomeDir()
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
44 self.__envBaseDir = baseDir
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
45
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
46 self.targetDirectoryPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
47 self.targetDirectoryPicker.setWindowTitle(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
48 self.tr("Virtualenv Target Directory")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
49 )
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
50 self.targetDirectoryPicker.setText(baseDir)
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
51 self.targetDirectoryPicker.setDefaultDirectory(baseDir)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
52
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
53 self.extraSearchPathPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
54 self.extraSearchPathPicker.setWindowTitle(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
55 self.tr("Extra Search Path for setuptools/pip")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
56 )
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
57 self.extraSearchPathPicker.setDefaultDirectory(Utilities.getHomeDir())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
58
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
59 self.pythonExecPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
60 self.pythonExecPicker.setWindowTitle(self.tr("Python Interpreter"))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
61 self.pythonExecPicker.setDefaultDirectory(Globals.getPythonExecutable())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
62
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
63 self.condaTargetDirectoryPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
64 self.condaTargetDirectoryPicker.setWindowTitle(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
65 self.tr("Conda Environment Location")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
66 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
67 self.condaTargetDirectoryPicker.setDefaultDirectory(Utilities.getHomeDir())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
68
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
69 self.condaCloneDirectoryPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
70 self.condaCloneDirectoryPicker.setWindowTitle(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
71 self.tr("Conda Environment Location")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
72 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
73 self.condaCloneDirectoryPicker.setDefaultDirectory(Utilities.getHomeDir())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
74
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
75 self.condaRequirementsFilePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
76 self.condaRequirementsFilePicker.setWindowTitle(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
77 self.tr("Conda Requirements File")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
78 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
79 self.condaRequirementsFilePicker.setDefaultDirectory(Utilities.getHomeDir())
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
80 self.condaRequirementsFilePicker.setFilters(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
81 self.tr("Text Files (*.txt);;All Files (*)")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
82 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
83
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.__versionRe = re.compile(r""".*?(\d+\.\d+\.\d+).*""")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
85
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.__virtualenvFound = False
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.__pyvenvFound = False
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
88 self.__condaFound = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
89 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
90
8862
99459beb81b1 Adapted some style sheet usages to observe the palette lightness (dark/light).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8838
diff changeset
91 self.__mandatoryStyleSheet = (
99459beb81b1 Adapted some style sheet usages to observe the palette lightness (dark/light).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8838
diff changeset
92 "QLineEdit {border: 2px solid; border-color: #dd8888}"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
93 if ericApp().usesDarkPalette()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
94 else "QLineEdit {border: 2px solid; border-color: #800000}"
8862
99459beb81b1 Adapted some style sheet usages to observe the palette lightness (dark/light).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8838
diff changeset
95 )
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
96 self.targetDirectoryPicker.setStyleSheet(self.__mandatoryStyleSheet)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
97 self.nameEdit.setStyleSheet(self.__mandatoryStyleSheet)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
98 self.condaTargetDirectoryPicker.setStyleSheet(self.__mandatoryStyleSheet)
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
99 self.condaNameEdit.setStyleSheet(self.__mandatoryStyleSheet)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
100
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.__setVirtualenvVersion()
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.__setPyvenvVersion()
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
103 self.__setCondaVersion()
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
104 if self.__pyvenvFound:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
105 self.pyvenvButton.setChecked(True)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
106 elif self.__virtualenvFound:
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.virtualenvButton.setChecked(True)
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
108 elif self.__condaFound:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
109 self.condaButton.setChecked(True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
110
6681
9c1513b488ef CondaInterface, VirtualenvConfigurationDialog: moved the version related functions to the CondaInterface package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6678
diff changeset
111 self.condaInsecureCheckBox.setEnabled(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
112 CondaInterface.condaVersion() >= (4, 3, 18)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
113 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
114
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 msh = self.minimumSizeHint()
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.resize(max(self.width(), msh.width()), msh.height())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
117
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 def __updateOK(self):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 Private method to update the enabled status of the OK button.
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 """
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
122 if self.virtualenvButton.isChecked() or self.pyvenvButton.isChecked():
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
123 enable = (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
124 (self.__virtualenvFound or self.__pyvenvFound)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
125 and bool(self.targetDirectoryPicker.text())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
126 and bool(self.nameEdit.text())
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
127 )
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
128 enable &= self.targetDirectoryPicker.text() != self.__envBaseDir
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
129 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable)
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
130 elif self.condaButton.isChecked():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
131 enable = bool(self.condaNameEdit.text()) or bool(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
132 self.condaTargetDirectoryPicker.text()
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
133 )
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
134 if self.condaSpecialsGroup.isChecked():
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
135 if self.condaCloneButton.isChecked():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
136 enable &= bool(self.condaCloneNameEdit.text()) or bool(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
137 self.condaCloneDirectoryPicker.text()
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
138 )
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
139 elif self.condaRequirementsButton.isChecked():
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
140 enable &= bool(self.condaRequirementsFilePicker.text())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
141 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable)
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
142 else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
143 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
144
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 def __updateUi(self):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 Private method to update the UI depending on the selected
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 virtual environment creator (virtualenv or pyvenv).
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 """
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
150 # venv page
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 enable = self.virtualenvButton.isChecked()
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 self.extraSearchPathLabel.setEnabled(enable)
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
153 self.extraSearchPathPicker.setEnabled(enable)
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 self.promptPrefixLabel.setEnabled(enable)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 self.promptPrefixEdit.setEnabled(enable)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self.verbosityLabel.setEnabled(enable)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 self.verbositySpinBox.setEnabled(enable)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 self.versionLabel.setEnabled(enable)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.versionComboBox.setEnabled(enable)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 self.unzipCheckBox.setEnabled(enable)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 self.noSetuptoolsCheckBox.setEnabled(enable)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 self.symlinkCheckBox.setEnabled(not enable)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 self.upgradeCheckBox.setEnabled(not enable)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
164
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
165 # conda page
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
166 enable = not self.condaSpecialsGroup.isChecked()
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
167 self.condaPackagesEdit.setEnabled(enable)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
168 self.condaPythonEdit.setEnabled(enable)
6681
9c1513b488ef CondaInterface, VirtualenvConfigurationDialog: moved the version related functions to the CondaInterface package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6678
diff changeset
169 self.condaInsecureCheckBox.setEnabled(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
170 enable and CondaInterface.condaVersion() >= (4, 3, 18)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
171 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
172 self.condaDryrunCheckBox.setEnabled(enable)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
173
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
174 # select page
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
175 if self.condaButton.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
176 self.venvStack.setCurrentWidget(self.condaPage)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
177 else:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
178 self.venvStack.setCurrentWidget(self.venvPage)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
179
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 @pyqtSlot(str)
7827
3d42837a8b66 VirtualenvConfigurationDialog: fixed an issue causing the OK button not being enabled if the name of the virtual environment was changed second.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
181 def on_nameEdit_textChanged(self, txt):
3d42837a8b66 VirtualenvConfigurationDialog: fixed an issue causing the OK button not being enabled if the name of the virtual environment was changed second.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
182 """
3d42837a8b66 VirtualenvConfigurationDialog: fixed an issue causing the OK button not being enabled if the name of the virtual environment was changed second.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
183 Private slot handling a change of the virtual environment name.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
184
7827
3d42837a8b66 VirtualenvConfigurationDialog: fixed an issue causing the OK button not being enabled if the name of the virtual environment was changed second.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
185 @param txt name of the virtual environment
3d42837a8b66 VirtualenvConfigurationDialog: fixed an issue causing the OK button not being enabled if the name of the virtual environment was changed second.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
186 @type str
3d42837a8b66 VirtualenvConfigurationDialog: fixed an issue causing the OK button not being enabled if the name of the virtual environment was changed second.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
187 """
3d42837a8b66 VirtualenvConfigurationDialog: fixed an issue causing the OK button not being enabled if the name of the virtual environment was changed second.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
188 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
189
7827
3d42837a8b66 VirtualenvConfigurationDialog: fixed an issue causing the OK button not being enabled if the name of the virtual environment was changed second.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
190 @pyqtSlot(str)
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
191 def on_targetDirectoryPicker_textChanged(self, txt):
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 Private slot handling a change of the target directory.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
194
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
195 @param txt target directory
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
196 @type str
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
199
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 @pyqtSlot(str)
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
201 def on_pythonExecPicker_textChanged(self, txt):
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 Private slot to react to a change of the Python executable.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
204
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
205 @param txt contents of the picker's line edit
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
206 @type str
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 self.__setVirtualenvVersion()
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 self.__setPyvenvVersion()
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
211
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 @pyqtSlot(bool)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 def on_virtualenvButton_toggled(self, checked):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 Private slot to react to the selection of 'virtualenv'.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
216
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
217 @param checked state of the checkbox
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
218 @type bool
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 self.__updateUi()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
221
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 @pyqtSlot(bool)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 def on_pyvenvButton_toggled(self, checked):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 Private slot to react to the selection of 'pyvenv'.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
226
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
227 @param checked state of the checkbox
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
228 @type bool
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 self.__updateUi()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
231
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
232 @pyqtSlot(bool)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
233 def on_condaButton_toggled(self, checked):
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
234 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
235 Private slot to react to the selection of 'conda'.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
236
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
237 @param checked state of the checkbox
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
238 @type bool
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
239 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
240 self.__updateUi()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
241
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
242 @pyqtSlot(str)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
243 def on_condaNameEdit_textChanged(self, txt):
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
244 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
245 Private slot handling a change of the conda environment name.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
246
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
247 @param txt environment name
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
248 @type str
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
249 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
250 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
251
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
252 @pyqtSlot(str)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
253 def on_condaTargetDirectoryPicker_textChanged(self, txt):
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
254 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
255 Private slot handling a change of the conda target directory.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
256
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
257 @param txt target directory
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
258 @type str
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
259 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
260 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
261
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
262 @pyqtSlot()
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
263 def on_condaSpecialsGroup_clicked(self):
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
264 """
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
265 Private slot handling the selection of the specials group.
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
266 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
267 self.__updateOK()
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
268 self.__updateUi()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
269
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
270 @pyqtSlot(str)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
271 def on_condaCloneNameEdit_textChanged(self, txt):
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
272 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
273 Private slot handling a change of the conda source environment name.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
274
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
275 @param txt name of the environment to be cloned
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
276 @type str
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
277 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
278 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
279
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
280 @pyqtSlot(str)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
281 def on_condaCloneDirectoryPicker_textChanged(self, txt):
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
282 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
283 Private slot handling a change of the cloned from directory.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
284
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
285 @param txt target directory
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
286 @type str
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
287 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
288 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
289
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
290 @pyqtSlot()
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
291 def on_condaCloneButton_clicked(self):
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
292 """
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
293 Private slot handling the selection of the clone button.
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
294 """
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
295 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
296
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
297 @pyqtSlot()
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
298 def on_condaRequirementsButton_clicked(self):
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
299 """
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
300 Private slot handling the selection of the requirements button.
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
301 """
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
302 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
303
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
304 @pyqtSlot(str)
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
305 def on_condaRequirementsFilePicker_textChanged(self, txt):
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
306 """
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
307 Private slot handling a change of the requirements file entry.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
308
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
309 @param txt current text of the requirements file entry
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
310 @type str
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
311 """
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
312 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
313
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 def __setVirtualenvVersion(self):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 Private method to determine the virtualenv version and set the
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 respective label.
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 """
8648
c908f66b9d19 Small correction to the Virtual Environment Configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
319 calls = []
c908f66b9d19 Small correction to the Virtual Environment Configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
320 if self.pythonExecPicker.text():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
321 calls.append(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
322 (self.pythonExecPicker.text(), ["-m", "virtualenv", "--version"])
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
323 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
324 calls.extend(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
325 [
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
326 (Globals.getPythonExecutable(), ["-m", "virtualenv", "--version"]),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
327 ("virtualenv", ["--version"]),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
328 ]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
329 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
330
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 proc = QProcess()
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 for prog, args in calls:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 proc.start(prog, args)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
334
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 if not proc.waitForStarted(5000):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 # try next entry
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 continue
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
338
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 if not proc.waitForFinished(5000):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 # process hangs, kill it
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 QTimer.singleShot(2000, proc.kill)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 proc.waitForFinished(3000)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
343 version = self.tr("<virtualenv did not finish within 5s.>")
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 self.__virtualenvFound = False
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 break
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
346
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 if proc.exitCode() != 0:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 # returned with error code, try next
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 continue
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
350
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
351 output = str(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
352 proc.readAllStandardOutput(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
353 Preferences.getSystem("IOEncoding"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
354 "replace",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
355 ).strip()
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 match = re.match(self.__versionRe, output)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 if match:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 self.__virtualenvFound = True
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 version = match.group(1)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 break
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 else:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 self.__virtualenvFound = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
363 version = self.tr("<No suitable virtualenv found.>")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
364
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
365 self.virtualenvButton.setText(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
366 self.tr("virtualenv Version: {0}".format(version))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
367 )
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 self.virtualenvButton.setEnabled(self.__virtualenvFound)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 if not self.__virtualenvFound:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 self.virtualenvButton.setChecked(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
371
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 def __setPyvenvVersion(self):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 Private method to determine the pyvenv version and set the respective
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 label.
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 calls = []
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
378 if self.pythonExecPicker.text():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
379 calls.append((self.pythonExecPicker.text(), ["-m", "venv"]))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
380 calls.extend(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
381 [
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
382 (Globals.getPythonExecutable(), ["-m", "venv"]),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
383 ("python3", ["-m", "venv"]),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
384 ("python", ["-m", "venv"]),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
385 ]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
386 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
387
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 proc = QProcess()
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 for prog, args in calls:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 proc.start(prog, args)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
391
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 if not proc.waitForStarted(5000):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 # try next entry
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 continue
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
395
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 if not proc.waitForFinished(5000):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 # process hangs, kill it
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 QTimer.singleShot(2000, proc.kill)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 proc.waitForFinished(3000)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
400 version = self.tr("<pyvenv did not finish within 5s.>")
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 self.__pyvenvFound = False
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 break
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
403
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 if proc.exitCode() not in [0, 2]:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 # returned with error code, try next
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 continue
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
407
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 proc.start(prog, ["--version"])
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 proc.waitForFinished(5000)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
410 output = str(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
411 proc.readAllStandardOutput(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
412 Preferences.getSystem("IOEncoding"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
413 "replace",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
414 ).strip()
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 match = re.match(self.__versionRe, output)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 if match:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 self.__pyvenvFound = True
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 version = match.group(1)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 break
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 else:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 self.__pyvenvFound = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
422 version = self.tr("<No suitable pyvenv found.>")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
423
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
424 self.pyvenvButton.setText(self.tr("pyvenv Version: {0}".format(version)))
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 self.pyvenvButton.setEnabled(self.__pyvenvFound)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 if not self.__pyvenvFound:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 self.pyvenvButton.setChecked(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
428
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
429 def __setCondaVersion(self):
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
430 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
431 Private method to determine the conda version and set the respective
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
432 label.
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
433 """
6681
9c1513b488ef CondaInterface, VirtualenvConfigurationDialog: moved the version related functions to the CondaInterface package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6678
diff changeset
434 self.__condaFound = bool(CondaInterface.condaVersion())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
435 self.condaButton.setText(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
436 self.tr("conda Version: {0}".format(CondaInterface.condaVersionStr()))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
437 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
438 self.condaButton.setEnabled(self.__condaFound)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
439 if not self.__condaFound:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
440 self.condaButton.setChecked(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
441
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 def __generateTargetDir(self):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 Private method to generate a valid target directory path.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
445
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
446 @return target directory path
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
447 @rtype str
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 targetDirectory = Utilities.toNativeSeparators(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
450 self.targetDirectoryPicker.text()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
451 )
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 if not os.path.isabs(targetDirectory):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
453 targetDirectory = os.path.join(os.path.expanduser("~"), targetDirectory)
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 return targetDirectory
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
455
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 def __generateArguments(self):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 Private method to generate the process arguments.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
459
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
460 @return process arguments
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
461 @rtype list of str
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 args = []
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
464 if self.condaButton.isChecked():
6677
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
465 if bool(self.condaNameEdit.text()):
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
466 args.extend(["--name", self.condaNameEdit.text()])
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
467 if bool(self.condaTargetDirectoryPicker.text()):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
468 args.extend(["--prefix", self.condaTargetDirectoryPicker.text()])
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
469 if self.condaSpecialsGroup.isChecked():
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
470 if self.condaCloneButton.isChecked():
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
471 if bool(self.condaCloneNameEdit.text()):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
472 args.extend(["--clone", self.condaCloneNameEdit.text()])
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
473 elif bool(self.condaCloneDirectoryPicker.text()):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
474 args.extend(["--clone", self.condaCloneDirectoryPicker.text()])
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
475 elif self.condaRequirementsButton.isChecked():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
476 args.extend(["--file", self.condaRequirementsFilePicker.text()])
6677
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
477 if self.condaInsecureCheckBox.isChecked():
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
478 args.append("--insecure")
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
479 if self.condaDryrunCheckBox.isChecked():
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
480 args.append("--dry-run")
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
481 if not self.condaSpecialsGroup.isChecked():
6677
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
482 if bool(self.condaPythonEdit.text()):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
483 args.append("python={0}".format(self.condaPythonEdit.text()))
6677
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
484 if bool(self.condaPackagesEdit.text()):
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
485 args.extend(self.condaPackagesEdit.text().split())
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
486 else:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
487 if self.virtualenvButton.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
488 if self.extraSearchPathPicker.text():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
489 args.append(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
490 "--extra-search-dir={0}".format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
491 Utilities.toNativeSeparators(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
492 self.extraSearchPathPicker.text()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
493 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
494 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
495 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
496 if self.promptPrefixEdit.text():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
497 args.append(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
498 "--prompt={0}".format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
499 self.promptPrefixEdit.text().replace(" ", "_")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
500 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
501 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
502 if self.pythonExecPicker.text():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
503 args.append(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
504 "--python={0}".format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
505 Utilities.toNativeSeparators(self.pythonExecPicker.text())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
506 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
507 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
508 elif self.versionComboBox.currentText():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
509 args.append(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
510 "--python=python{0}".format(self.versionComboBox.currentText())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
511 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
512 if self.verbositySpinBox.value() == 1:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
513 args.append("--verbose")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
514 elif self.verbositySpinBox.value() == -1:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
515 args.append("--quiet")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
516 if self.clearCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
517 args.append("--clear")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
518 if self.systemCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
519 args.append("--system-site-packages")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
520 if self.unzipCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
521 args.append("--unzip-setuptools")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
522 if self.noSetuptoolsCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
523 args.append("--no-setuptools")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
524 if self.noPipCcheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
525 args.append("--no-pip")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
526 if self.copyCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
527 args.append("--always-copy")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
528 elif self.pyvenvButton.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
529 if self.clearCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
530 args.append("--clear")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
531 if self.systemCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
532 args.append("--system-site-packages")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
533 if self.noPipCcheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
534 args.append("--without-pip")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
535 if self.copyCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
536 args.append("--copies")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
537 if self.symlinkCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
538 args.append("--symlinks")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
539 if self.upgradeCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
540 args.append("--upgrade")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
541 targetDirectory = self.__generateTargetDir()
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
542 args.append(targetDirectory)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
543
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 return args
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 def getData(self):
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 Public method to retrieve the dialog data.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
549
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
550 @return dictionary containing the data for the two environment
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
551 variants. The keys for both variants are 'arguments' containing the
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
552 command line arguments, 'logicalName' containing the environment
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
553 name to be used with the virtual env manager and 'envType'
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
554 containing the environment type (virtualenv, pyvenv or conda). The
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
555 virtualenv/pyvenv specific keys are 'openTarget' containg a flag to
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
556 open the target directory after creation, 'createLog' containing a
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
557 flag to write a log file, 'createScript' containing a flag to write
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
558 a script, 'targetDirectory' containing the target directory and
6684
37e280d711af VirtualenvConfigurationDialog: added the 'command' key to the conda specific part of the result dictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6681
diff changeset
559 'pythonExe' containing the Python interpreter to be used. The
37e280d711af VirtualenvConfigurationDialog: added the 'command' key to the conda specific part of the result dictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6681
diff changeset
560 conda specific key is 'command' giving the conda command to be
37e280d711af VirtualenvConfigurationDialog: added the 'command' key to the conda specific part of the result dictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6681
diff changeset
561 executed (always 'create').
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
562 @rtype dict
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 args = self.__generateArguments()
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
565 resultDict = {
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
566 "arguments": args,
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
567 "logicalName": self.nameEdit.text(),
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
568 }
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
569 if self.condaButton.isChecked():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
570 resultDict.update(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
571 {
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
572 "envType": "conda",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
573 "command": "create",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
574 }
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
575 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
576 else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
577 resultDict.update(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
578 {
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
579 "envType": (
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
580 "pyvenv" if self.pyvenvButton.isChecked() else "virtualenv"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
581 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
582 "openTarget": self.openCheckBox.isChecked(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
583 "createLog": self.logCheckBox.isChecked(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
584 "createScript": self.scriptCheckBox.isChecked(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
585 "targetDirectory": self.__generateTargetDir(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
586 "pythonExe": Utilities.toNativeSeparators(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
587 self.pythonExecPicker.text()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
588 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
589 }
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
590 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
591
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
592 return resultDict

eric ide

mercurial