src/eric7/VirtualEnv/VirtualenvConfigurationDialog.py

branch
eric7
changeset 11230
8a15b05eeee3
parent 11105
ec86fc991d28
--- a/src/eric7/VirtualEnv/VirtualenvConfigurationDialog.py	Wed Apr 23 17:23:57 2025 +0200
+++ b/src/eric7/VirtualEnv/VirtualenvConfigurationDialog.py	Wed Apr 23 18:02:09 2025 +0200
@@ -14,7 +14,7 @@
 from PyQt6.QtCore import QProcess, QTimer, pyqtSlot
 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
 
-from eric7 import CondaInterface, Preferences
+from eric7 import Preferences
 from eric7.EricWidgets.EricApplication import ericApp
 from eric7.EricWidgets.EricPathPicker import EricPathPickerModes
 from eric7.SystemUtilities import PythonUtilities
@@ -24,8 +24,7 @@
 
 class VirtualenvConfigurationDialog(QDialog, Ui_VirtualenvConfigurationDialog):
     """
-    Class implementing a dialog to enter the parameters for the
-    virtual environment.
+    Class implementing a dialog to enter the parameters for the virtual environment.
     """
 
     def __init__(self, baseDir="", parent=None):
@@ -61,32 +60,12 @@
         self.pythonExecPicker.setWindowTitle(self.tr("Python Interpreter"))
         self.pythonExecPicker.setDefaultDirectory(PythonUtilities.getPythonExecutable())
 
-        self.condaTargetDirectoryPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
-        self.condaTargetDirectoryPicker.setWindowTitle(
-            self.tr("Conda Environment Location")
-        )
-        self.condaTargetDirectoryPicker.setDefaultDirectory(os.path.expanduser("~"))
-
-        self.condaCloneDirectoryPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
-        self.condaCloneDirectoryPicker.setWindowTitle(
-            self.tr("Conda Environment Location")
-        )
-        self.condaCloneDirectoryPicker.setDefaultDirectory(os.path.expanduser("~"))
-
-        self.condaRequirementsFilePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
-        self.condaRequirementsFilePicker.setWindowTitle(
-            self.tr("Conda Requirements File")
-        )
-        self.condaRequirementsFilePicker.setDefaultDirectory(os.path.expanduser("~"))
-        self.condaRequirementsFilePicker.setFilters(
-            self.tr("Text Files (*.txt);;All Files (*)")
-        )
+        self.versionComboBox.addItems(["", "3.13", "3.12", "3.11", "3.10", "3.9"])
 
         self.__versionRe = re.compile(r""".*?(\d+\.\d+\.\d+).*""")
 
         self.__virtualenvFound = False
         self.__pyvenvFound = False
-        self.__condaFound = False
         self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
 
         self.__mandatoryStyleSheet = (
@@ -96,29 +75,26 @@
         )
         self.targetDirectoryPicker.setStyleSheet(self.__mandatoryStyleSheet)
         self.nameEdit.setStyleSheet(self.__mandatoryStyleSheet)
-        self.condaTargetDirectoryPicker.setStyleSheet(self.__mandatoryStyleSheet)
-        self.condaNameEdit.setStyleSheet(self.__mandatoryStyleSheet)
 
         self.__setVirtualenvVersion()
         self.__setPyvenvVersion()
-        self.__setCondaVersion()
         if self.__pyvenvFound:
             self.pyvenvButton.setChecked(True)
         elif self.__virtualenvFound:
             self.virtualenvButton.setChecked(True)
-        elif self.__condaFound:
-            self.condaButton.setChecked(True)
 
-        self.condaInsecureCheckBox.setEnabled(
-            CondaInterface.condaVersion() >= (4, 3, 18)
-        )
+        self.nameEdit.textChanged.connect(self.__updateOK)
+        self.targetDirectoryPicker.textChanged.connect(self.__updateOK)
+        self.virtualenvButton.toggled.connect(self.__updateUi)
+        self.pyvenvButton.toggled.connect(self.__updateUi)
 
         msh = self.minimumSizeHint()
         self.resize(max(self.width(), msh.width()), msh.height())
 
+    @pyqtSlot()
     def __updateOK(self):
         """
-        Private method to update the enabled status of the OK button.
+        Private slot to update the enabled status of the OK button.
         """
         if self.virtualenvButton.isChecked() or self.pyvenvButton.isChecked():
             enable = (
@@ -128,27 +104,15 @@
             )
             enable &= self.targetDirectoryPicker.text() != self.__envBaseDir
             self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable)
-        elif self.condaButton.isChecked():
-            enable = bool(self.condaNameEdit.text()) or bool(
-                self.condaTargetDirectoryPicker.text()
-            )
-            if self.condaSpecialsGroup.isChecked():
-                if self.condaCloneButton.isChecked():
-                    enable &= bool(self.condaCloneNameEdit.text()) or bool(
-                        self.condaCloneDirectoryPicker.text()
-                    )
-                elif self.condaRequirementsButton.isChecked():
-                    enable &= bool(self.condaRequirementsFilePicker.text())
-            self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable)
         else:
             self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
 
+    @pyqtSlot()
     def __updateUi(self):
         """
-        Private method to update the UI depending on the selected
+        Private slot to update the UI depending on the selected
         virtual environment creator (virtualenv or pyvenv).
         """
-        # venv page
         enable = self.virtualenvButton.isChecked()
         self.extraSearchPathLabel.setEnabled(enable)
         self.extraSearchPathPicker.setEnabled(enable)
@@ -158,46 +122,11 @@
         self.verbositySpinBox.setEnabled(enable)
         self.versionLabel.setEnabled(enable)
         self.versionComboBox.setEnabled(enable)
-        self.unzipCheckBox.setEnabled(enable)
+        self.noWheelCheckBox.setEnabled(enable)
         self.noSetuptoolsCheckBox.setEnabled(enable)
         self.symlinkCheckBox.setEnabled(not enable)
         self.upgradeCheckBox.setEnabled(not enable)
 
-        # conda page
-        enable = not self.condaSpecialsGroup.isChecked()
-        self.condaPackagesEdit.setEnabled(enable)
-        self.condaPythonEdit.setEnabled(enable)
-        self.condaInsecureCheckBox.setEnabled(
-            enable and CondaInterface.condaVersion() >= (4, 3, 18)
-        )
-        self.condaDryrunCheckBox.setEnabled(enable)
-
-        # select page
-        if self.condaButton.isChecked():
-            self.venvStack.setCurrentWidget(self.condaPage)
-        else:
-            self.venvStack.setCurrentWidget(self.venvPage)
-
-    @pyqtSlot(str)
-    def on_nameEdit_textChanged(self, _txt):
-        """
-        Private slot handling a change of the virtual environment name.
-
-        @param _txt name of the virtual environment (unused)
-        @type str
-        """
-        self.__updateOK()
-
-    @pyqtSlot(str)
-    def on_targetDirectoryPicker_textChanged(self, _txt):
-        """
-        Private slot handling a change of the target directory.
-
-        @param _txt target directory (unused)
-        @type str
-        """
-        self.__updateOK()
-
     @pyqtSlot(str)
     def on_pythonExecPicker_textChanged(self, _txt):
         """
@@ -210,108 +139,6 @@
         self.__setPyvenvVersion()
         self.__updateOK()
 
-    @pyqtSlot(bool)
-    def on_virtualenvButton_toggled(self, _checked):
-        """
-        Private slot to react to the selection of 'virtualenv'.
-
-        @param _checked state of the checkbox (unused)
-        @type bool
-        """
-        self.__updateUi()
-
-    @pyqtSlot(bool)
-    def on_pyvenvButton_toggled(self, _checked):
-        """
-        Private slot to react to the selection of 'pyvenv'.
-
-        @param _checked state of the checkbox (unused)
-        @type bool
-        """
-        self.__updateUi()
-
-    @pyqtSlot(bool)
-    def on_condaButton_toggled(self, _checked):
-        """
-        Private slot to react to the selection of 'conda'.
-
-        @param _checked state of the checkbox (unused)
-        @type bool
-        """
-        self.__updateUi()
-
-    @pyqtSlot(str)
-    def on_condaNameEdit_textChanged(self, _txt):
-        """
-        Private slot handling a change of the conda environment name.
-
-        @param _txt environment name (unused)
-        @type str
-        """
-        self.__updateOK()
-
-    @pyqtSlot(str)
-    def on_condaTargetDirectoryPicker_textChanged(self, _txt):
-        """
-        Private slot handling a change of the conda target directory.
-
-        @param _txt target directory (unused)
-        @type str
-        """
-        self.__updateOK()
-
-    @pyqtSlot()
-    def on_condaSpecialsGroup_clicked(self):
-        """
-        Private slot handling the selection of the specials group.
-        """
-        self.__updateOK()
-        self.__updateUi()
-
-    @pyqtSlot(str)
-    def on_condaCloneNameEdit_textChanged(self, _txt):
-        """
-        Private slot handling a change of the conda source environment name.
-
-        @param _txt name of the environment to be cloned (unused)
-        @type str
-        """
-        self.__updateOK()
-
-    @pyqtSlot(str)
-    def on_condaCloneDirectoryPicker_textChanged(self, _txt):
-        """
-        Private slot handling a change of the cloned from directory.
-
-        @param _txt target directory (unused)
-        @type str
-        """
-        self.__updateOK()
-
-    @pyqtSlot()
-    def on_condaCloneButton_clicked(self):
-        """
-        Private slot handling the selection of the clone button.
-        """
-        self.__updateOK()
-
-    @pyqtSlot()
-    def on_condaRequirementsButton_clicked(self):
-        """
-        Private slot handling the selection of the requirements button.
-        """
-        self.__updateOK()
-
-    @pyqtSlot(str)
-    def on_condaRequirementsFilePicker_textChanged(self, _txt):
-        """
-        Private slot handling a change of the requirements file entry.
-
-        @param _txt current text of the requirements file entry (unused)
-        @type str
-        """
-        self.__updateOK()
-
     def __setVirtualenvVersion(self):
         """
         Private method to determine the virtualenv version and set the
@@ -430,19 +257,6 @@
         if not self.__pyvenvFound:
             self.pyvenvButton.setChecked(False)
 
-    def __setCondaVersion(self):
-        """
-        Private method to determine the conda version and set the respective
-        label.
-        """
-        self.__condaFound = bool(CondaInterface.condaVersion())
-        self.condaButton.setText(
-            self.tr("conda Version: {0}".format(CondaInterface.condaVersionStr()))
-        )
-        self.condaButton.setEnabled(self.__condaFound)
-        if not self.__condaFound:
-            self.condaButton.setChecked(False)
-
     def __generateTargetDir(self):
         """
         Private method to generate a valid target directory path.
@@ -463,79 +277,54 @@
         @rtype list of str
         """
         args = []
-        if self.condaButton.isChecked():
-            if bool(self.condaNameEdit.text()):
-                args.extend(["--name", self.condaNameEdit.text()])
-            if bool(self.condaTargetDirectoryPicker.text()):
-                args.extend(["--prefix", self.condaTargetDirectoryPicker.text()])
-            if self.condaSpecialsGroup.isChecked():
-                if self.condaCloneButton.isChecked():
-                    if bool(self.condaCloneNameEdit.text()):
-                        args.extend(["--clone", self.condaCloneNameEdit.text()])
-                    elif bool(self.condaCloneDirectoryPicker.text()):
-                        args.extend(["--clone", self.condaCloneDirectoryPicker.text()])
-                elif self.condaRequirementsButton.isChecked():
-                    args.extend(["--file", self.condaRequirementsFilePicker.text()])
-            if self.condaInsecureCheckBox.isChecked():
-                args.append("--insecure")
-            if self.condaDryrunCheckBox.isChecked():
-                args.append("--dry-run")
-            if not self.condaSpecialsGroup.isChecked():
-                if bool(self.condaPythonEdit.text()):
-                    args.append("python={0}".format(self.condaPythonEdit.text()))
-                if bool(self.condaPackagesEdit.text()):
-                    args.extend(self.condaPackagesEdit.text().split())
-        else:
-            if self.virtualenvButton.isChecked():
-                if self.extraSearchPathPicker.text():
-                    args.append(
-                        "--extra-search-dir={0}".format(
-                            self.extraSearchPathPicker.text()
-                        )
-                    )
-                if self.promptPrefixEdit.text():
-                    args.append(
-                        "--prompt={0}".format(
-                            self.promptPrefixEdit.text().replace(" ", "_")
-                        )
+        if self.virtualenvButton.isChecked():
+            if self.extraSearchPathPicker.text():
+                args.append(
+                    "--extra-search-dir={0}".format(self.extraSearchPathPicker.text())
+                )
+            if self.promptPrefixEdit.text():
+                args.append(
+                    "--prompt={0}".format(
+                        self.promptPrefixEdit.text().replace(" ", "_")
                     )
-                if self.pythonExecPicker.text():
-                    args.append("--python={0}".format(self.pythonExecPicker.text()))
-                elif self.versionComboBox.currentText():
-                    args.append(
-                        "--python=python{0}".format(self.versionComboBox.currentText())
-                    )
-                if self.verbositySpinBox.value() == 1:
-                    args.append("--verbose")
-                elif self.verbositySpinBox.value() == -1:
-                    args.append("--quiet")
-                if self.clearCheckBox.isChecked():
-                    args.append("--clear")
-                if self.systemCheckBox.isChecked():
-                    args.append("--system-site-packages")
-                if self.unzipCheckBox.isChecked():
-                    args.append("--unzip-setuptools")
-                if self.noSetuptoolsCheckBox.isChecked():
-                    args.append("--no-setuptools")
-                if self.noPipCcheckBox.isChecked():
-                    args.append("--no-pip")
-                if self.copyCheckBox.isChecked():
-                    args.append("--always-copy")
-            elif self.pyvenvButton.isChecked():
-                if self.clearCheckBox.isChecked():
-                    args.append("--clear")
-                if self.systemCheckBox.isChecked():
-                    args.append("--system-site-packages")
-                if self.noPipCcheckBox.isChecked():
-                    args.append("--without-pip")
-                if self.copyCheckBox.isChecked():
-                    args.append("--copies")
-                if self.symlinkCheckBox.isChecked():
-                    args.append("--symlinks")
-                if self.upgradeCheckBox.isChecked():
-                    args.append("--upgrade")
-            targetDirectory = self.__generateTargetDir()
-            args.append(targetDirectory)
+                )
+            if self.pythonExecPicker.text():
+                args.append("--python={0}".format(self.pythonExecPicker.text()))
+            elif self.versionComboBox.currentText():
+                args.append(
+                    "--python=python{0}".format(self.versionComboBox.currentText())
+                )
+            if self.verbositySpinBox.value() == 1:
+                args.append("--verbose")
+            elif self.verbositySpinBox.value() == -1:
+                args.append("--quiet")
+            if self.clearCheckBox.isChecked():
+                args.append("--clear")
+            if self.systemCheckBox.isChecked():
+                args.append("--system-site-packages")
+            if self.noWheelCheckBox.isChecked():
+                args.append("--no-wheel")
+            if self.noSetuptoolsCheckBox.isChecked():
+                args.append("--no-setuptools")
+            if self.noPipCcheckBox.isChecked():
+                args.append("--no-pip")
+            if self.copyCheckBox.isChecked():
+                args.append("--always-copy")
+        elif self.pyvenvButton.isChecked():
+            if self.clearCheckBox.isChecked():
+                args.append("--clear")
+            if self.systemCheckBox.isChecked():
+                args.append("--system-site-packages")
+            if self.noPipCcheckBox.isChecked():
+                args.append("--without-pip")
+            if self.copyCheckBox.isChecked():
+                args.append("--copies")
+            if self.symlinkCheckBox.isChecked():
+                args.append("--symlinks")
+            if self.upgradeCheckBox.isChecked():
+                args.append("--upgrade")
+        targetDirectory = self.__generateTargetDir()
+        args.append(targetDirectory)
 
         return args
 
@@ -543,44 +332,24 @@
         """
         Public method to retrieve the dialog data.
 
-        @return dictionary containing the data for the two environment
-            variants. The keys for both variants are 'arguments' containing the
-            command line arguments, 'logicalName' containing the environment
-            name to be used with the virtual env manager and 'envType'
-            containing the environment type (virtualenv, pyvenv or conda). The
-            virtualenv/pyvenv specific keys are 'openTarget' containg a flag to
-            open the target directory after creation, 'createLog' containing a
-            flag to write a log file, 'createScript' containing a flag to write
-            a script, 'targetDirectory' containing the target directory and
-            'pythonExe' containing the Python interpreter to be used. The
-            conda specific key is 'command' giving the conda command to be
-            executed (always 'create').
+        @return dictionary containing the data for the new environment. The keys
+            are 'arguments' containing the command line arguments, 'logicalName'
+            containing the environment name to be used with the virtual environment
+            manager and 'envType' containing the environment type (virtualenv or
+            pyvenv). Additional keys are 'openTarget' containg a flag to open the
+            target directory after creation, 'createLog' containing a flag to write
+            a log file, 'createScript' containing a flag to write a script,
+            'targetDirectory' containing the target directory and 'pythonExe'
+            containing the Python interpreter to be used.
         @rtype dict
         """
-        args = self.__generateArguments()
-        resultDict = {
-            "arguments": args,
+        return {
+            "arguments": self.__generateArguments(),
             "logicalName": self.nameEdit.text(),
+            "envType": "pyvenv" if self.pyvenvButton.isChecked() else "virtualenv",
+            "openTarget": self.openCheckBox.isChecked(),
+            "createLog": self.logCheckBox.isChecked(),
+            "createScript": self.scriptCheckBox.isChecked(),
+            "targetDirectory": self.__generateTargetDir(),
+            "pythonExe": self.pythonExecPicker.text(),
         }
-        if self.condaButton.isChecked():
-            resultDict.update(
-                {
-                    "envType": "conda",
-                    "command": "create",
-                }
-            )
-        else:
-            resultDict.update(
-                {
-                    "envType": (
-                        "pyvenv" if self.pyvenvButton.isChecked() else "virtualenv"
-                    ),
-                    "openTarget": self.openCheckBox.isChecked(),
-                    "createLog": self.logCheckBox.isChecked(),
-                    "createScript": self.scriptCheckBox.isChecked(),
-                    "targetDirectory": self.__generateTargetDir(),
-                    "pythonExe": self.pythonExecPicker.text(),
-                }
-            )
-
-        return resultDict

eric ide

mercurial