src/eric7/VirtualEnv/VirtualenvConfigurationDialog.py

Wed, 13 Jul 2022 14:55:47 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 13 Jul 2022 14:55:47 +0200
branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
permissions
-rw-r--r--

Reformatted the source code using the 'Black' utility.

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
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
14 from PyQt6.QtCore import pyqtSlot, QProcess, QTimer
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
8358
144a6b854f70 Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8356
diff changeset
17 from EricWidgets.EricPathPicker import EricPathPickerModes
8862
99459beb81b1 Adapted some style sheet usages to observe the palette lightness (dark/light).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8838
diff changeset
18 from EricWidgets.EricApplication import ericApp
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 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
21
9016
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
22 import Globals
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 import Preferences
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 import Utilities
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
6681
9c1513b488ef CondaInterface, VirtualenvConfigurationDialog: moved the version related functions to the CondaInterface package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6678
diff changeset
26 import CondaInterface
9c1513b488ef CondaInterface, VirtualenvConfigurationDialog: moved the version related functions to the CondaInterface package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6678
diff changeset
27
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 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
30 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 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
32 virtual environment.
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
34
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
35 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
36 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
38
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
39 @param baseDir base directory for the virtual environments
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
40 @type str
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
41 @param parent reference to the parent widget
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
42 @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
43 """
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
44 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
45 self.setupUi(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
46
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
47 if not baseDir:
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
48 baseDir = Utilities.getHomeDir()
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
49 self.__envBaseDir = baseDir
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
50
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
51 self.targetDirectoryPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
52 self.targetDirectoryPicker.setWindowTitle(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
53 self.tr("Virtualenv Target Directory")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
54 )
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
55 self.targetDirectoryPicker.setText(baseDir)
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
56 self.targetDirectoryPicker.setDefaultDirectory(baseDir)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
57
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
58 self.extraSearchPathPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
59 self.extraSearchPathPicker.setWindowTitle(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
60 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
61 )
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
62 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
63
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
64 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
65 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
66 self.pythonExecPicker.setDefaultDirectory(Globals.getPythonExecutable())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
67
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
68 self.condaTargetDirectoryPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
69 self.condaTargetDirectoryPicker.setWindowTitle(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
70 self.tr("Conda Environment Location")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
71 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
72 self.condaTargetDirectoryPicker.setDefaultDirectory(Utilities.getHomeDir())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
73
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
74 self.condaCloneDirectoryPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
75 self.condaCloneDirectoryPicker.setWindowTitle(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
76 self.tr("Conda Environment Location")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
77 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
78 self.condaCloneDirectoryPicker.setDefaultDirectory(Utilities.getHomeDir())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
79
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
80 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
81 self.condaRequirementsFilePicker.setWindowTitle(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
82 self.tr("Conda Requirements File")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
83 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
84 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
85 self.condaRequirementsFilePicker.setFilters(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
86 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
87 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
88
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 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
90
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 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
92 self.__pyvenvFound = False
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
93 self.__condaFound = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
94 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
95
8862
99459beb81b1 Adapted some style sheet usages to observe the palette lightness (dark/light).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8838
diff changeset
96 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
97 "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
98 if ericApp().usesDarkPalette()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
99 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
100 )
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
101 self.targetDirectoryPicker.setStyleSheet(self.__mandatoryStyleSheet)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
102 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
103 self.condaTargetDirectoryPicker.setStyleSheet(self.__mandatoryStyleSheet)
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
104 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
105
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.__setVirtualenvVersion()
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.__setPyvenvVersion()
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
108 self.__setCondaVersion()
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
109 if self.__pyvenvFound:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
110 self.pyvenvButton.setChecked(True)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
111 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
112 self.virtualenvButton.setChecked(True)
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
113 elif self.__condaFound:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
114 self.condaButton.setChecked(True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
115
6681
9c1513b488ef CondaInterface, VirtualenvConfigurationDialog: moved the version related functions to the CondaInterface package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6678
diff changeset
116 self.condaInsecureCheckBox.setEnabled(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
117 CondaInterface.condaVersion() >= (4, 3, 18)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
118 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
119
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 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
121 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
122
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 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
124 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 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
126 """
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
127 if self.virtualenvButton.isChecked() or self.pyvenvButton.isChecked():
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
128 enable = (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
129 (self.__virtualenvFound or self.__pyvenvFound)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
130 and bool(self.targetDirectoryPicker.text())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
131 and bool(self.nameEdit.text())
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
132 )
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7827
diff changeset
133 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
134 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
135 elif self.condaButton.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.condaNameEdit.text()) or bool(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
137 self.condaTargetDirectoryPicker.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 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
140 if self.condaCloneButton.isChecked():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
141 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
142 self.condaCloneDirectoryPicker.text()
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
143 )
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
144 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
145 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
146 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
147 else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
148 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
149
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 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
151 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 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
153 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
154 """
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
155 # 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
156 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
157 self.extraSearchPathLabel.setEnabled(enable)
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166 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
167 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
168 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
169
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
170 # 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
171 enable = not self.condaSpecialsGroup.isChecked()
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
172 self.condaPackagesEdit.setEnabled(enable)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
173 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
174 self.condaInsecureCheckBox.setEnabled(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
175 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
176 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
177 self.condaDryrunCheckBox.setEnabled(enable)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
178
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
179 # select page
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
180 if self.condaButton.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
181 self.venvStack.setCurrentWidget(self.condaPage)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
182 else:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
183 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
184
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 @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
186 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
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 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
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 @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
191 @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
192 """
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
193 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
194
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
195 @pyqtSlot(str)
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
196 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
197 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 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
199
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
200 @param txt target directory
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
201 @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
202 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
204
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 @pyqtSlot(str)
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
206 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
207 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 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
209
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
210 @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
211 @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
212 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 self.__setVirtualenvVersion()
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 self.__setPyvenvVersion()
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
216
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 @pyqtSlot(bool)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 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
219 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 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
221
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
222 @param checked state of the checkbox
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
223 @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
224 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 self.__updateUi()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
226
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 @pyqtSlot(bool)
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 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
229 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 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
231
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
232 @param checked state of the checkbox
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
233 @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
234 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 self.__updateUi()
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 @pyqtSlot(bool)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
238 def on_condaButton_toggled(self, checked):
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 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
241
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
242 @param checked state of the checkbox
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
243 @type bool
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 self.__updateUi()
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 @pyqtSlot(str)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
248 def on_condaNameEdit_textChanged(self, txt):
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 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
251
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
252 @param txt environment name
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
253 @type str
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 self.__updateOK()
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 @pyqtSlot(str)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
258 def on_condaTargetDirectoryPicker_textChanged(self, txt):
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 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
261
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
262 @param txt target directory
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
263 @type str
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
264 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
265 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
266
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
267 @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
268 def on_condaSpecialsGroup_clicked(self):
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
269 """
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
270 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
271 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
272 self.__updateOK()
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
273 self.__updateUi()
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 @pyqtSlot(str)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
276 def on_condaCloneNameEdit_textChanged(self, txt):
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 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
279
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
280 @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
281 @type str
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 self.__updateOK()
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 @pyqtSlot(str)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
286 def on_condaCloneDirectoryPicker_textChanged(self, txt):
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 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
289
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
290 @param txt target directory
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
291 @type str
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
292 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
293 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
294
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
295 @pyqtSlot()
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
296 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
297 """
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
298 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
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 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
301
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
302 @pyqtSlot()
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
303 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
304 """
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
305 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
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 self.__updateOK()
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 @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
310 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
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 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
313
6739
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
314 @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
315 @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
316 """
110ab101766a VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6736
diff changeset
317 self.__updateOK()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
318
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 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
320 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 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
322 respective label.
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 """
8648
c908f66b9d19 Small correction to the Virtual Environment Configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
324 calls = []
c908f66b9d19 Small correction to the Virtual Environment Configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
325 if self.pythonExecPicker.text():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
326 calls.append(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
327 (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
328 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
329 calls.extend(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
330 [
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
331 (Globals.getPythonExecutable(), ["-m", "virtualenv", "--version"]),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
332 ("virtualenv", ["--version"]),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
333 ]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
334 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
335
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 proc = QProcess()
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 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
338 proc.start(prog, args)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
339
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 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
341 # 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
342 continue
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
343
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 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
345 # 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
346 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
347 proc.waitForFinished(3000)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
348 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
349 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
350 break
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
351
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 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
353 # 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
354 continue
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
355
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
356 output = str(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
357 proc.readAllStandardOutput(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
358 Preferences.getSystem("IOEncoding"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
359 "replace",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
360 ).strip()
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 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
362 if match:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 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
364 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
365 break
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 else:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 self.__virtualenvFound = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
368 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
369
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
370 self.virtualenvButton.setText(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
371 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
372 )
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 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
374 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
375 self.virtualenvButton.setChecked(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
376
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 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
378 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 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
380 label.
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 calls = []
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
383 if self.pythonExecPicker.text():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
384 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
385 calls.extend(
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 (Globals.getPythonExecutable(), ["-m", "venv"]),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
388 ("python3", ["-m", "venv"]),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
389 ("python", ["-m", "venv"]),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
390 ]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
391 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
392
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 proc = QProcess()
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 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
395 proc.start(prog, args)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
396
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 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
398 # 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
399 continue
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
400
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 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
402 # 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
403 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
404 proc.waitForFinished(3000)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
405 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
406 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
407 break
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
408
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 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
410 # 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
411 continue
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
412
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 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
414 proc.waitForFinished(5000)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
415 output = str(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
416 proc.readAllStandardOutput(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
417 Preferences.getSystem("IOEncoding"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
418 "replace",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
419 ).strip()
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 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
421 if match:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 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
423 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
424 break
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 else:
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 self.__pyvenvFound = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
427 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
428
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
429 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
430 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
431 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
432 self.pyvenvButton.setChecked(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
433
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
434 def __setCondaVersion(self):
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
435 """
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
436 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
437 label.
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
438 """
6681
9c1513b488ef CondaInterface, VirtualenvConfigurationDialog: moved the version related functions to the CondaInterface package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6678
diff changeset
439 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
440 self.condaButton.setText(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
441 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
442 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
443 self.condaButton.setEnabled(self.__condaFound)
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
444 if not self.__condaFound:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
445 self.condaButton.setChecked(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
446
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 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
448 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 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
450
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
451 @return target directory path
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
452 @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
453 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 targetDirectory = Utilities.toNativeSeparators(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
455 self.targetDirectoryPicker.text()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
456 )
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 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
458 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
459 return targetDirectory
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
460
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 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
462 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 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
464
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
465 @return process arguments
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
466 @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
467 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 args = []
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
469 if self.condaButton.isChecked():
6677
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
470 if bool(self.condaNameEdit.text()):
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
471 args.extend(["--name", self.condaNameEdit.text()])
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
472 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
473 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
474 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
475 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
476 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
477 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
478 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
479 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
480 elif self.condaRequirementsButton.isChecked():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
481 args.extend(["--file", self.condaRequirementsFilePicker.text()])
6677
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
482 if self.condaInsecureCheckBox.isChecked():
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
483 args.append("--insecure")
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
484 if self.condaDryrunCheckBox.isChecked():
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
485 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
486 if not self.condaSpecialsGroup.isChecked():
6677
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
487 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
488 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
489 if bool(self.condaPackagesEdit.text()):
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6672
diff changeset
490 args.extend(self.condaPackagesEdit.text().split())
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
491 else:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
492 if self.virtualenvButton.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
493 if self.extraSearchPathPicker.text():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
494 args.append(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
495 "--extra-search-dir={0}".format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
496 Utilities.toNativeSeparators(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
497 self.extraSearchPathPicker.text()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
498 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
499 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
500 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
501 if self.promptPrefixEdit.text():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
502 args.append(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
503 "--prompt={0}".format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
504 self.promptPrefixEdit.text().replace(" ", "_")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
505 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
506 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
507 if self.pythonExecPicker.text():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
508 args.append(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
509 "--python={0}".format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
510 Utilities.toNativeSeparators(self.pythonExecPicker.text())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
511 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
512 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
513 elif self.versionComboBox.currentText():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
514 args.append(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
515 "--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
516 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
517 if self.verbositySpinBox.value() == 1:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
518 args.append("--verbose")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
519 elif self.verbositySpinBox.value() == -1:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
520 args.append("--quiet")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
521 if self.clearCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
522 args.append("--clear")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
523 if self.systemCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
524 args.append("--system-site-packages")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
525 if self.unzipCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
526 args.append("--unzip-setuptools")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
527 if self.noSetuptoolsCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
528 args.append("--no-setuptools")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
529 if self.noPipCcheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
530 args.append("--no-pip")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
531 if self.copyCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
532 args.append("--always-copy")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
533 elif self.pyvenvButton.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
534 if self.clearCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
535 args.append("--clear")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
536 if self.systemCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
537 args.append("--system-site-packages")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
538 if self.noPipCcheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
539 args.append("--without-pip")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
540 if self.copyCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
541 args.append("--copies")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
542 if self.symlinkCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
543 args.append("--symlinks")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
544 if self.upgradeCheckBox.isChecked():
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
545 args.append("--upgrade")
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
546 targetDirectory = self.__generateTargetDir()
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
547 args.append(targetDirectory)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
548
6014
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 return args
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 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
552 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 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
554
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
555 @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
556 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
557 command line arguments, 'logicalName' containing the environment
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
558 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
559 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
560 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
561 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
562 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
563 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
564 '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
565 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
566 executed (always 'create').
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
567 @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
568 """
d3375a0a3240 Added the virtualenv/pyvenv interface plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 args = self.__generateArguments()
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
570 resultDict = {
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
571 "arguments": args,
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
572 "logicalName": self.nameEdit.text(),
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
573 }
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
574 if self.condaButton.isChecked():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
575 resultDict.update(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
576 {
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
577 "envType": "conda",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
578 "command": "create",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
579 }
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
580 )
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
581 else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
582 resultDict.update(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
583 {
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
584 "envType": (
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
585 "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
586 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
587 "openTarget": self.openCheckBox.isChecked(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
588 "createLog": self.logCheckBox.isChecked(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
589 "createScript": self.scriptCheckBox.isChecked(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
590 "targetDirectory": self.__generateTargetDir(),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
591 "pythonExe": Utilities.toNativeSeparators(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
592 self.pythonExecPicker.text()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
593 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
594 }
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
595 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
596
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
597 return resultDict

eric ide

mercurial