Pip Interface: added an option to not show 'conda' managed environments in the selector.

Wed, 30 Sep 2020 19:34:11 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Sep 2020 19:34:11 +0200
changeset 7726
b1ade4fcf05f
parent 7725
2648f2c894df
child 7727
2322376bd101

Pip Interface: added an option to not show 'conda' managed environments in the selector.

eric6/PipInterface/Pip.py file | annotate | diff | comparison | revisions
eric6/PipInterface/PipPackagesWidget.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/PipPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/PipPage.ui file | annotate | diff | comparison | revisions
eric6/Preferences/__init__.py file | annotate | diff | comparison | revisions
eric6/VirtualEnv/VirtualenvManager.py file | annotate | diff | comparison | revisions
--- a/eric6/PipInterface/Pip.py	Wed Sep 30 19:33:21 2020 +0200
+++ b/eric6/PipInterface/Pip.py	Wed Sep 30 19:34:11 2020 +0200
@@ -206,19 +206,21 @@
         
         return interpreter
     
-    def getVirtualenvNames(self, noRemote=False):
+    def getVirtualenvNames(self, noRemote=False, noConda=False):
         """
         Public method to get a sorted list of virtual environment names.
         
         @param noRemote flag indicating to exclude environments for remote
             debugging
         @type bool
+        @param noConda flag indicating to exclude Conda environments
+        @type bool
         @return sorted list of virtual environment names
         @rtype list of str
         """
         return sorted(
             e5App().getObject("VirtualEnvManager").getVirtualenvNames(
-                noRemote=noRemote))
+                noRemote=noRemote, noConda=noConda))
     
     def installPip(self, venvName, userSite=False):
         """
--- a/eric6/PipInterface/PipPackagesWidget.py	Wed Sep 30 19:33:21 2020 +0200
+++ b/eric6/PipInterface/PipPackagesWidget.py	Wed Sep 30 19:34:11 2020 +0200
@@ -27,6 +27,7 @@
 
 import UI.PixmapCache
 import Globals
+import Preferences
 
 
 class PipPackagesWidget(QWidget, Ui_PipPackagesWidget):
@@ -136,7 +137,11 @@
         if projectVenv:
             self.environmentsComboBox.addItem(projectVenv)
         self.environmentsComboBox.addItems(
-            self.__pip.getVirtualenvNames(noRemote=True))
+            self.__pip.getVirtualenvNames(
+                noRemote=True,
+                noConda=Preferences.getPip("ExcludeCondaEnvironments")
+            )
+        )
     
     def __isPipAvailable(self):
         """
--- a/eric6/Preferences/ConfigurationPages/PipPage.py	Wed Sep 30 19:33:21 2020 +0200
+++ b/eric6/Preferences/ConfigurationPages/PipPage.py	Wed Sep 30 19:34:11 2020 +0200
@@ -35,6 +35,8 @@
         
         # set initial values
         self.indexEdit.setText(Preferences.getPip("PipSearchIndex"))
+        self.noCondaCheckBox.setChecked(
+            Preferences.getPip("ExcludeCondaEnvironments"))
     
     def save(self):
         """
@@ -42,6 +44,8 @@
         """
         Preferences.setPip(
             "PipSearchIndex", self.indexEdit.text().strip())
+        Preferences.setPip(
+            "ExcludeCondaEnvironments", self.noCondaCheckBox.isChecked())
 
 
 def create(dlg):
--- a/eric6/Preferences/ConfigurationPages/PipPage.ui	Wed Sep 30 19:33:21 2020 +0200
+++ b/eric6/Preferences/ConfigurationPages/PipPage.ui	Wed Sep 30 19:34:11 2020 +0200
@@ -10,7 +10,7 @@
     <height>389</height>
    </rect>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2">
+  <layout class="QVBoxLayout" name="verticalLayout_3">
    <item>
     <widget class="QLabel" name="headerLabel">
      <property name="text">
@@ -58,6 +58,25 @@
     </widget>
    </item>
    <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Environment</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_2">
+      <item>
+       <widget class="QCheckBox" name="noCondaCheckBox">
+        <property name="toolTip">
+         <string>Select to exclude conda managed environments</string>
+        </property>
+        <property name="text">
+         <string>Don't show 'Conda' environments</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <spacer name="verticalSpacer">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
--- a/eric6/Preferences/__init__.py	Wed Sep 30 19:33:21 2020 +0200
+++ b/eric6/Preferences/__init__.py	Wed Sep 30 19:34:11 2020 +0200
@@ -1431,7 +1431,9 @@
     
     # defaults for pip
     pipDefaults = {
-        "PipSearchIndex": "",           # used by the search command
+        "PipSearchIndex": "",               # used by the search command
+        "ExcludeCondaEnvironments": True,
+        # don't show conda environments in selector
     }
     
     # defaults for MicroPython
@@ -3527,9 +3529,14 @@
     @param prefClass preferences class used as the storage area
     @return the requested pip value
     """
-    return prefClass.settings.value(
-        "Pip/" + key,
-        prefClass.pipDefaults[key])
+    if key in ("ExcludeCondaEnvironments"):
+        return toBool(prefClass.settings.value(
+            "Pip/" + key,
+            prefClass.pipDefaults[key]))
+    else:
+        return prefClass.settings.value(
+            "Pip/" + key,
+            prefClass.pipDefaults[key])
 
 
 def setPip(key, value, prefClass=Prefs):
--- a/eric6/VirtualEnv/VirtualenvManager.py	Wed Sep 30 19:33:21 2020 +0200
+++ b/eric6/VirtualEnv/VirtualenvManager.py	Wed Sep 30 19:34:11 2020 +0200
@@ -524,13 +524,15 @@
         else:
             return ""
     
-    def getVirtualenvNames(self, noRemote=False):
+    def getVirtualenvNames(self, noRemote=False, noConda=False):
         """
         Public method to get a list of defined virtual environments.
         
         @param noRemote flag indicating to exclude environments for remote
             debugging
         @type bool
+        @param noConda flag indicating to exclude Conda environments
+        @type bool
         @return list of defined virtual environments
         @rtype list of str
         """
@@ -538,6 +540,9 @@
         if noRemote:
             environments = [name for name in environments
                             if not self.isRemoteEnvironment(name)]
+        if noConda:
+            environments = [name for name in environments
+                            if not self.isCondaEnvironment(name)]
         
         return environments
     

eric ide

mercurial